summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llcommandmanager.cpp18
-rw-r--r--indra/llui/llcommandmanager.h13
-rw-r--r--indra/llui/lllineeditor.cpp1
-rw-r--r--indra/llui/lltoolbar.cpp106
-rw-r--r--indra/llui/lltoolbar.h34
5 files changed, 140 insertions, 32 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 922f243806..2bd50af7af 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -124,9 +124,25 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId)
return command_match;
}
+LLCommand * LLCommandManager::getCommand(const LLUUID& commandUUID)
+{
+ LLCommand * command_match = NULL;
+
+ CommandUUIDMap::const_iterator found = mCommandUUIDs.find(commandUUID);
+
+ if (found != mCommandUUIDs.end())
+ {
+ command_match = mCommands[found->second];
+ }
+
+ return command_match;
+}
+
void LLCommandManager::addCommand(LLCommand * command)
{
- mCommandIndices[command->id()] = mCommands.size();
+ LLCommandId command_id = command->id();
+ mCommandIndices[command_id] = mCommands.size();
+ mCommandUUIDs[command_id.uuid()] = mCommands.size();
mCommands.push_back(command);
lldebugs << "Successfully added command: " << command->id().name() << llendl;
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index 3ac5548a0d..8e5abd6461 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -52,13 +52,18 @@ public:
LLCommandId(const std::string& name)
: mName(name)
- {}
+ {
+ mUUID = LLUUID::generateNewID(name);
+ }
LLCommandId(const Params& p)
: mName(p.name)
- {}
+ {
+ mUUID = LLUUID::generateNewID(p.name);
+ }
const std::string& name() const { return mName; }
+ const LLUUID& uuid() const { return mUUID; }
bool operator!=(const LLCommandId& command) const
{
@@ -79,6 +84,7 @@ public:
private:
std::string mName;
+ LLUUID mUUID;
};
typedef std::list<LLCommandId> command_id_list_t;
@@ -172,6 +178,7 @@ public:
U32 commandCount() const;
LLCommand * getCommand(U32 commandIndex);
LLCommand * getCommand(const LLCommandId& commandId);
+ LLCommand * getCommand(const LLUUID& commandUUID);
static bool load();
@@ -179,11 +186,13 @@ protected:
void addCommand(LLCommand * command);
private:
+ typedef std::map<LLUUID, U32> CommandUUIDMap;
typedef std::map<LLCommandId, U32> CommandIndexMap;
typedef std::vector<LLCommand *> CommandVector;
CommandVector mCommands;
CommandIndexMap mCommandIndices;
+ CommandUUIDMap mCommandUUIDs;
};
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index ebdd47ae80..06dfc90d83 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -198,6 +198,7 @@ LLLineEditor::~LLLineEditor()
void LLLineEditor::onFocusReceived()
{
+ gEditMenuHandler = this;
LLUICtrl::onFocusReceived();
updateAllowingLanguageInput();
}
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 0ec2eefc19..62217a664a 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -107,7 +107,6 @@ 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;
- mUUID = LLUUID::generateNewID(p.name);
}
LLToolBar::~LLToolBar()
@@ -193,16 +192,66 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
mNeedsLayout = true;
}
-bool LLToolBar::addCommand(const LLCommandId& commandId)
+bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
{
LLCommand * command = LLCommandManager::instance().getCommand(commandId);
if (!command) return false;
- mButtonCommands.push_back(commandId);
+ // Create the button and do the things that don't need ordering
LLToolBarButton* button = createButton(commandId);
- mButtons.push_back(button);
mButtonPanel->addChild(button);
mButtonMap.insert(std::make_pair(commandId, 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);
+ mButtons.push_back(button);
+ }
+ else
+ {
+ // Insert in place: iterate to the right spot...
+ std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
+ command_id_list_t::iterator it_command = mButtonCommands.begin();
+ while (rank > 0)
+ {
+ ++it_button;
+ ++it_command;
+ rank--;
+ }
+ // ...then insert
+ mButtonCommands.insert(it_command,commandId);
+ mButtons.insert(it_button,button);
+ }
+
+ mNeedsLayout = true;
+
+ return true;
+}
+
+bool LLToolBar::removeCommand(const LLCommandId& commandId)
+{
+ if (!hasCommand(commandId)) return false;
+
+ // First erase the map record
+ command_id_map::iterator it = mButtonMap.find(commandId);
+ 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)
+ {
+ ++it_button;
+ ++it_command;
+ }
+
+ // Delete the button and erase the command and button records
+ delete (*it_button);
+ mButtonCommands.erase(it_command);
+ mButtons.erase(it_button);
+
mNeedsLayout = true;
return true;
@@ -328,6 +377,37 @@ void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row
}
}
+int LLToolBar::getRankFromPosition(S32 x, S32 y)
+{
+ int rank = 0;
+
+ LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType);
+ S32 button_panel_x = 0;
+ S32 button_panel_y = 0;
+ localPointToOtherView(x, y, &button_panel_x, &button_panel_y, mButtonPanel);
+
+ //llinfos << "Merov debug : rank compute: orientation = " << orientation << ", x = " << button_panel_x << ", y = " << button_panel_y << llendl;
+
+ // Simply compare the passed coord with the buttons outbound box
+ std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
+ std::list<LLToolBarButton*>::iterator end_button = mButtons.end();
+ while (it_button != end_button)
+ {
+ LLRect button_rect = (*it_button)->getRect();
+ //llinfos << "Merov debug : rank compute: rect = " << button_rect.mLeft << ", " << button_rect.mTop << ", " << button_rect.mRight << ", " << button_rect.mBottom << llendl;
+ if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > button_panel_x)) ||
+ ((orientation == LLLayoutStack::VERTICAL) && (button_rect.mBottom < button_panel_y)) )
+ {
+ break;
+ }
+ rank++;
+ ++it_button;
+ }
+ //llinfos << "Merov debug : rank = " << rank << llendl;
+
+ return rank;
+}
+
void LLToolBar::updateLayoutAsNeeded()
{
if (!mNeedsLayout) return;
@@ -520,6 +600,7 @@ void LLToolBar::createButtons()
delete button;
}
mButtons.clear();
+ mButtonMap.clear();
BOOST_FOREACH(LLCommandId& command_id, mButtonCommands)
{
@@ -529,7 +610,6 @@ void LLToolBar::createButtons()
mButtonMap.insert(std::make_pair(command_id, button));
}
mNeedsLayout = true;
-
}
LLToolBarButton* LLToolBar::createButton(const LLCommandId& id)
@@ -602,20 +682,20 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EAcceptance* accept,
std::string& tooltip_msg)
{
- llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", tooltip = " << tooltip_msg << llendl;
+ //llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl;
// If we have a drop callback, that means that we can handle the drop
BOOL handled = (mHandleDropCallback ? TRUE : FALSE);
- // if drop, time to call the drop callback to get the operation done
+ // if drop is set, it's time to call the callback to get the operation done
if (handled && drop)
{
- handled = mHandleDropCallback(cargo_type,cargo_data,mUUID);
+ handled = mHandleDropCallback(cargo_data, x, y ,this);
}
- // We accept multi drop by default
- *accept = (handled ? ACCEPT_YES_MULTI : ACCEPT_NO);
+ // We accept only single tool drop on toolbars
+ *accept = (handled ? ACCEPT_YES_SINGLE : ACCEPT_NO);
- // We'll use that flag to change the visual aspect of the target on draw()
+ // We'll use that flag to change the visual aspect of the toolbar target on draw()
mDragAndDropTarget = handled;
return handled;
@@ -661,13 +741,13 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask)
{
if (!mIsDragged)
{
- mStartDragItemCallback(x,y,mUUID);
+ mStartDragItemCallback(x,y,mId.uuid());
mIsDragged = true;
handled = TRUE;
}
else
{
- handled = mHandleDragItemCallback(x,y,mUUID,LLAssetType::AT_WIDGET);
+ handled = mHandleDragItemCallback(x,y,mId.uuid(),LLAssetType::AT_WIDGET);
}
}
else
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index b649ab28ff..ac99e23aae 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -35,9 +35,11 @@
#include "llcommandmanager.h"
#include "llassettype.h"
-typedef boost::function<void (S32 x, S32 y, const LLUUID& uuid)> startdrag_callback_t;
-typedef boost::function<BOOL (S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type)> handledrag_callback_t;
-typedef boost::function<BOOL (EDragAndDropType type, void* data, const LLUUID& uuid)> handledrop_callback_t;
+class LLToolBar;
+
+typedef boost::function<void (S32 x, S32 y, const LLUUID& uuid)> tool_startdrag_callback_t;
+typedef boost::function<BOOL (S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type)> tool_handledrag_callback_t;
+typedef boost::function<BOOL (void* data, S32 x, S32 y, LLToolBar* toolbar)> tool_handledrop_callback_t;
class LLToolBarButton : public LLButton
{
@@ -62,8 +64,8 @@ public:
BOOL handleHover(S32 x, S32 y, MASK mask);
void setCommandId(const LLCommandId& id) { mId = id; }
- void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; }
- void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
+ void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; }
+ void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
void onMouseEnter(S32 x, S32 y, MASK mask);
@@ -74,9 +76,8 @@ private:
LLUI::RangeS32 mWidthRange;
S32 mDesiredHeight;
bool mIsDragged;
- startdrag_callback_t mStartDragItemCallback;
- handledrag_callback_t mHandleDragItemCallback;
- LLUUID mUUID;
+ tool_startdrag_callback_t mStartDragItemCallback;
+ tool_handledrag_callback_t mHandleDragItemCallback;
enable_signal_t* mIsEnabledSignal;
enable_signal_t* mIsRunningSignal;
@@ -151,6 +152,7 @@ public:
// virtuals
void draw();
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
+ int getRankFromPosition(S32 x, S32 y);
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
@@ -158,13 +160,14 @@ public:
EAcceptance* accept,
std::string& tooltip_msg);
- bool addCommand(const LLCommandId& commandId);
+ bool addCommand(const LLCommandId& commandId, int rank = -1);
+ bool removeCommand(const LLCommandId& commandId);
bool hasCommand(const LLCommandId& commandId) const;
bool enableCommand(const LLCommandId& commandId, bool enabled);
- void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; }
- void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
- void setHandleDropCallback(handledrop_callback_t cb) { mHandleDropCallback = cb; }
+ void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; }
+ void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
+ void setHandleDropCallback(tool_handledrop_callback_t cb) { mHandleDropCallback = cb; }
LLToolBarButton* createButton(const LLCommandId& id);
@@ -174,9 +177,9 @@ protected:
~LLToolBar();
void initFromParams(const Params&);
- startdrag_callback_t mStartDragItemCallback;
- handledrag_callback_t mHandleDragItemCallback;
- handledrop_callback_t mHandleDropCallback;
+ tool_startdrag_callback_t mStartDragItemCallback;
+ tool_handledrag_callback_t mHandleDragItemCallback;
+ tool_handledrop_callback_t mHandleDropCallback;
bool mDragAndDropTarget;
public:
@@ -194,7 +197,6 @@ private:
BOOL isSettingChecked(const LLSD& userdata);
void onSettingEnable(const LLSD& userdata);
- LLUUID mUUID;
const bool mReadOnly;
typedef std::list<LLToolBarButton*> toolbar_button_list;