summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2011-10-09 15:52:45 -0700
committerMerov Linden <merov@lindenlab.com>2011-10-09 15:52:45 -0700
commitec5ea33c8113a63e956c195ccf051b2a03979be9 (patch)
tree035e4ac326165d48eb6dc5f454fa6bc65fcbc1b6 /indra/llui
parent60c85dff83918876b23ab1ff1dfd336fc9dbc839 (diff)
EXP-1300 : drop tool animation. First shot. Works but still a bit hacky and with some bugs (tools can be duplicated at times).
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llcommandmanager.cpp2
-rw-r--r--indra/llui/llcommandmanager.h11
-rw-r--r--indra/llui/lltoolbar.cpp83
-rw-r--r--indra/llui/lltoolbar.h4
4 files changed, 84 insertions, 16 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 1b87f20d12..d8e035a320 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -41,7 +41,7 @@
// LLCommandId class
//
-const LLCommandId LLCommandId::null("null command");
+const LLCommandId LLCommandId::null = LLCommandId();
//
// LLCommand class
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index 8f9f956ec7..fdad7cd1b5 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -50,6 +50,12 @@ public:
{}
};
+ LLCommandId()
+ : mName("null command")
+ {
+ mUUID = LLUUID::generateNewID(mName);
+ }
+
LLCommandId(const std::string& name)
: mName(name)
{
@@ -62,10 +68,9 @@ public:
mUUID = LLUUID::generateNewID(p.name);
}
- LLCommandId(const LLUUID& uuid)
- : mName(""),
+ LLCommandId(const std::string& name, const LLUUID& uuid)
+ : mName(name),
mUUID(uuid)
-
{
}
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 5f7afb07fc..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!
@@ -113,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()
@@ -203,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
@@ -228,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);
}
@@ -241,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;
@@ -276,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());
}
@@ -289,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);
@@ -507,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;
@@ -592,6 +618,12 @@ void LLToolBar::draw()
}
}
}
+ // HACK!!!
+ if (!mDragAndDropTarget)
+ {
+ removeCommand(mDraggedCommand);
+ mDraggedCommand = LLCommandId::null;
+ }
updateLayoutAsNeeded();
// rect may have shifted during layout
@@ -622,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;
}
@@ -713,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;
}
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index be0589f3c6..9e48dee608 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -184,6 +184,8 @@ protected:
tool_handledrag_callback_t mHandleDragItemCallback;
tool_handledrop_callback_t mHandleDropCallback;
bool mDragAndDropTarget;
+ int mRank;
+ LLCommandId mDraggedCommand;
public:
// Methods used in loading and saving toolbar settings
@@ -205,7 +207,7 @@ private:
typedef std::list<LLToolBarButton*> toolbar_button_list;
toolbar_button_list mButtons;
command_id_list_t mButtonCommands;
- typedef std::map<LLCommandId, LLToolBarButton*> command_id_map;
+ typedef std::map<LLUUID, LLToolBarButton*> command_id_map;
command_id_map mButtonMap;
LLToolBarEnums::ButtonType mButtonType;