summaryrefslogtreecommitdiff
path: root/indra/llui/lltoolbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r--indra/llui/lltoolbar.cpp92
1 files changed, 80 insertions, 12 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index c34fbcd4f5..6332b2674a 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -33,6 +33,7 @@
#include "llcommandmanager.h"
#include "llmenugl.h"
#include "lltrans.h"
+#include "llinventory.h"
// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit
// thanks, MSVC!
@@ -86,6 +87,7 @@ LLToolBar::Params::Params()
pad_right("pad_right"),
pad_bottom("pad_bottom"),
pad_between("pad_between"),
+ min_girth("min_girth"),
button_panel("button_panel")
{}
@@ -103,6 +105,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
mPadTop(p.pad_top),
mPadBottom(p.pad_bottom),
mPadBetween(p.pad_between),
+ mMinGirth(p.min_girth),
mPopupMenuHandle(),
mStartDragItemCallback(NULL),
mHandleDragItemCallback(NULL),
@@ -111,6 +114,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
{
mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text;
mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon;
+ mDraggedCommand = LLCommandId::null;
+ mRank = 0;
}
LLToolBar::~LLToolBar()
@@ -201,17 +206,24 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
{
LLCommand * command = LLCommandManager::instance().getCommand(commandId);
if (!command) return false;
-
+ llinfos << "Merov debug : addCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
+
// Create the button and do the things that don't need ordering
LLToolBarButton* button = createButton(commandId);
mButtonPanel->addChild(button);
- mButtonMap.insert(std::make_pair(commandId, button));
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
+
// Insert the command and button in the right place in their respective lists
if ((rank >= mButtonCommands.size()) || (rank < 0))
{
// In that case, back load
- mButtonCommands.push_back(commandId);
+ mButtonCommands.push_back(temp_command);
mButtons.push_back(button);
}
else
@@ -226,7 +238,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
rank--;
}
// ...then insert
- mButtonCommands.insert(it_command,commandId);
+ mButtonCommands.insert(it_command,temp_command);
mButtons.insert(it_button,button);
}
@@ -239,14 +251,20 @@ bool LLToolBar::removeCommand(const LLCommandId& commandId)
{
if (!hasCommand(commandId)) return false;
+ llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
// First erase the map record
- command_id_map::iterator it = mButtonMap.find(commandId);
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
mButtonMap.erase(it);
// Now iterate on the commands and buttons to identify the relevant records
std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
command_id_list_t::iterator it_command = mButtonCommands.begin();
- while (*it_command != commandId)
+ while (*it_command != temp_command)
{
++it_button;
++it_command;
@@ -274,7 +292,12 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const
{
if (commandId != LLCommandId::null)
{
- command_id_map::const_iterator it = mButtonMap.find(commandId);
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ command_id_map::const_iterator it = mButtonMap.find(temp_command.uuid());
return (it != mButtonMap.end());
}
@@ -287,7 +310,12 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled)
if (commandId != LLCommandId::null)
{
- command_id_map::iterator it = mButtonMap.find(commandId);
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
if (it != mButtonMap.end())
{
it->second->setEnabled(enabled);
@@ -505,7 +533,7 @@ void LLToolBar::updateLayoutAsNeeded()
button_rect.setLeftTopAndSize(cur_row, panel_rect.mTop - cur_start, button_clamped_width, button->getRect().getHeight());
}
button->setShape(button_rect);
-
+
buttons_in_row.push_back(button);
row_running_length += button_length + mPadBetween;
@@ -517,6 +545,8 @@ void LLToolBar::updateLayoutAsNeeded()
S32 total_girth = cur_row // current row position...
+ max_row_girth // ...incremented by size of final row...
+ girth_pad_end; // ...plus padding reserved on end
+ total_girth = llmax(total_girth,mMinGirth);
+
max_row_length = llmax(max_row_length, row_running_length - mPadBetween + row_pad_end);
resizeButtonsInRow(buttons_in_row, max_row_girth);
@@ -588,6 +618,12 @@ void LLToolBar::draw()
}
}
}
+ // HACK!!!
+ if (!mDragAndDropTarget)
+ {
+ removeCommand(mDraggedCommand);
+ mDraggedCommand = LLCommandId::null;
+ }
updateLayoutAsNeeded();
// rect may have shifted during layout
@@ -618,7 +654,12 @@ void LLToolBar::createButtons()
LLToolBarButton* button = createButton(command_id);
mButtons.push_back(button);
mButtonPanel->addChild(button);
- mButtonMap.insert(std::make_pair(command_id, button));
+ LLCommandId temp_command = command_id;
+ if (command_id.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
}
mNeedsLayout = true;
}
@@ -709,7 +750,31 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
*accept = (handled ? ACCEPT_YES_SINGLE : ACCEPT_NO);
// We'll use that flag to change the visual aspect of the toolbar target on draw()
- mDragAndDropTarget = handled;
+ mDragAndDropTarget = false;
+
+ // HACK!!!
+ if (!isReadOnly() && handled)
+ {
+ if (!drop)
+ {
+ LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
+ LLAssetType::EType type = inv_item->getType();
+ if (type == LLAssetType::AT_WIDGET)
+ {
+ mRank = getRankFromPosition(x, y);
+ mDraggedCommand = LLCommandId("Drag Tool",inv_item->getUUID());
+ removeCommand(mDraggedCommand);
+ addCommand(mDraggedCommand,mRank);
+ mDragAndDropTarget = true;
+ }
+ }
+ else
+ {
+ removeCommand(mDraggedCommand);
+ mDraggedCommand = LLCommandId::null;
+ }
+
+ }
return handled;
}
@@ -723,7 +788,10 @@ LLToolBarButton::LLToolBarButton(const Params& p)
mId(""),
mIsEnabledSignal(NULL),
mIsRunningSignal(NULL),
- mIsStartingSignal(NULL)
+ mIsStartingSignal(NULL),
+ mIsDragged(false),
+ mStartDragItemCallback(NULL),
+ mHandleDragItemCallback(NULL)
{
mButtonFlashRate = 0.0;
mButtonFlashCount = 0;