summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/lldockablefloater.cpp8
-rw-r--r--indra/llui/llmenugl.cpp5
-rw-r--r--indra/llui/llmenugl.h4
-rw-r--r--indra/llui/lltoolbar.cpp47
-rw-r--r--indra/llui/lltoolbar.h89
5 files changed, 97 insertions, 56 deletions
diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp
index 0fcd937361..3396213f1c 100644
--- a/indra/llui/lldockablefloater.cpp
+++ b/indra/llui/lldockablefloater.cpp
@@ -82,7 +82,7 @@ BOOL LLDockableFloater::postBuild()
mForceDocking = true;
}
- mDockTongue = LLUI::getUIImage("windows/Flyout_Pointer.png");
+ mDockTongue = LLUI::getUIImage("Flyout_Pointer");
LLFloater::setDocked(true);
return LLView::postBuild();
}
@@ -244,13 +244,13 @@ const LLUIImagePtr& LLDockableFloater::getDockTongue(LLDockControl::DocAt dock_s
switch(dock_side)
{
case LLDockControl::LEFT:
- mDockTongue = LLUI::getUIImage("windows/Flyout_Left.png");
+ mDockTongue = LLUI::getUIImage("Flyout_Left");
break;
case LLDockControl::RIGHT:
- mDockTongue = LLUI::getUIImage("windows/Flyout_Right.png");
+ mDockTongue = LLUI::getUIImage("Flyout_Right");
break;
default:
- mDockTongue = LLUI::getUIImage("windows/Flyout_Pointer.png");
+ mDockTongue = LLUI::getUIImage("Flyout_Pointer");
break;
}
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 3ef8d8ff35..cb237fca7c 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -1686,7 +1686,8 @@ LLMenuGL::LLMenuGL(const LLMenuGL::Params& p)
mSpilloverMenu(NULL),
mJumpKey(p.jump_key),
mCreateJumpKeys(p.create_jump_keys),
- mNeedsArrange(FALSE),
+ mNeedsArrange(FALSE),
+ mResetScrollPositionOnShow(true),
mShortcutPad(p.shortcut_pad)
{
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
@@ -3043,7 +3044,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
S32 mouse_x, mouse_y;
// Resetting scrolling position
- if (menu->isScrollable())
+ if (menu->isScrollable() && menu->isScrollPositionOnShowReset())
{
menu->mFirstVisibleItem = NULL;
}
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index 77db588390..bdae899933 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -516,6 +516,9 @@ public:
static class LLMenuHolderGL* sMenuContainer;
+ void resetScrollPositionOnShow(bool reset_scroll_pos) { mResetScrollPositionOnShow = reset_scroll_pos; }
+ bool isScrollPositionOnShowReset() { return mResetScrollPositionOnShow; }
+
protected:
void createSpilloverBranch();
void cleanupSpilloverBranch();
@@ -565,6 +568,7 @@ private:
KEY mJumpKey;
BOOL mCreateJumpKeys;
S32 mShortcutPad;
+ bool mResetScrollPositionOnShow;
}; // end class LLMenuGL
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 287e3e2b41..e7642ae190 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -109,6 +109,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
mPadBetween(p.pad_between),
mMinGirth(p.min_girth),
mPopupMenuHandle(),
+ mRightMouseTargetButton(NULL),
mStartDragItemCallback(NULL),
mHandleDragItemCallback(NULL),
mHandleDropCallback(NULL),
@@ -139,6 +140,7 @@ void LLToolBar::createContextMenu()
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar commit_reg;
commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2));
+ commit_reg.add("Toolbars.RemoveSelectedCommand", boost::bind(&LLToolBar::onRemoveSelectedCommand, this));
LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_reg;
enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2));
@@ -397,6 +399,20 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
if (handle_it_here)
{
+ // Determine which button the mouse was over during the click in case the context menu action
+ // is intended to affect the button.
+ BOOST_FOREACH(LLToolBarButton* button, mButtons)
+ {
+ LLRect button_rect;
+ button->localRectToOtherView(button->getLocalRect(), &button_rect, this);
+
+ if (button_rect.pointInRect(x, y))
+ {
+ mRightMouseTargetButton = button;
+ break;
+ }
+ }
+
createContextMenu();
LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get();
@@ -446,6 +462,18 @@ void LLToolBar::onSettingEnable(const LLSD& userdata)
}
}
+void LLToolBar::onRemoveSelectedCommand()
+{
+ llassert(!mReadOnly);
+
+ if (mRightMouseTargetButton)
+ {
+ removeCommand(mRightMouseTargetButton->getCommandId());
+
+ mRightMouseTargetButton = NULL;
+ }
+}
+
void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type)
{
bool regenerate_buttons = (mButtonType != button_type);
@@ -524,11 +552,11 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
S32 mid_point = (button_rect.mRight + button_rect.mLeft) / 2;
if (button_panel_x < mid_point)
{
- mDragx = button_rect.mLeft - mPadLeft;
- mDragy = button_rect.mTop + mPadTop;
- }
- else
- {
+ mDragx = button_rect.mLeft - mPadLeft;
+ mDragy = button_rect.mTop + mPadTop;
+ }
+ else
+ {
rank++;
mDragx = button_rect.mRight + mPadRight - 1;
mDragy = button_rect.mTop + mPadTop;
@@ -555,12 +583,12 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
{
// We hit passed the end of the list so put the insertion point at the end
if (orientation == LLLayoutStack::HORIZONTAL)
- {
+ {
mDragx = button_rect.mRight + mPadRight;
mDragy = button_rect.mTop + mPadTop;
- }
- else
- {
+ }
+ else
+ {
mDragx = button_rect.mLeft - mPadLeft;
mDragy = button_rect.mBottom - mPadBottom;
}
@@ -836,6 +864,7 @@ void LLToolBar::createButtons()
}
mButtons.clear();
mButtonMap.clear();
+ mRightMouseTargetButton = NULL;
BOOST_FOREACH(LLCommandId& command_id, mButtonCommands)
{
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index f10f39adc3..51fe23ddd1 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -63,9 +63,11 @@ public:
BOOL handleMouseDown(S32 x, S32 y, MASK mask);
BOOL handleHover(S32 x, S32 y, MASK mask);
+
void reshape(S32 width, S32 height, BOOL called_from_parent = true);
void setEnabled(BOOL enabled);
void setCommandId(const LLCommandId& id) { mId = id; }
+ LLCommandId getCommandId() { return mId; }
void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; }
void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
@@ -164,7 +166,8 @@ public:
pad_bottom,
pad_between,
min_girth;
- // get rid of this
+
+ // default command set
Multiple<LLCommandId::Params> commands;
Optional<LLPanel::Params> button_panel;
@@ -175,8 +178,6 @@ public:
// virtuals
void draw();
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
- int getRankFromPosition(S32 x, S32 y);
- int getRankFromPosition(const LLCommandId& id);
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
@@ -185,15 +186,14 @@ public:
std::string& tooltip_msg);
static const int RANK_NONE = -1;
-
bool addCommand(const LLCommandId& commandId, int rank = RANK_NONE);
int removeCommand(const LLCommandId& commandId); // Returns the rank the removed command was at, RANK_NONE if not found
- bool hasCommand(const LLCommandId& commandId) const;
- bool enableCommand(const LLCommandId& commandId, bool enabled);
- bool stopCommandInProgress(const LLCommandId& commandId);
- bool flashCommand(const LLCommandId& commandId, bool flash);
+ bool hasCommand(const LLCommandId& commandId) const; // is this command bound to a button in this toolbar
+ bool enableCommand(const LLCommandId& commandId, bool enabled); // enable/disable button bound to the specified command, if it exists in this toolbar
+ bool stopCommandInProgress(const LLCommandId& commandId); // stop command if it is currently active
+ bool flashCommand(const LLCommandId& commandId, bool flash); // flash button associated with given command, if in this toolbar
- void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; }
+ void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } // connects drag and drop behavior to external logic
void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
void setHandleDropCallback(tool_handledrop_callback_t cb) { mHandleDropCallback = cb; }
bool isReadOnly() const { return mReadOnly; }
@@ -206,69 +206,76 @@ public:
boost::signals2::connection setButtonLeaveCallback(const button_signal_t::slot_type& cb);
boost::signals2::connection setButtonRemoveCallback(const button_signal_t::slot_type& cb);
- void setTooltipButtonSuffix(const std::string& suffix) { mButtonTooltipSuffix = suffix; }
+ // append the specified string to end of tooltip
+ void setTooltipButtonSuffix(const std::string& suffix) { mButtonTooltipSuffix = suffix; }
LLToolBarEnums::SideType getSideType() const { return mSideType; }
bool hasButtons() const { return !mButtons.empty(); }
bool isModified() const { return mModified; }
-protected:
- friend class LLUICtrlFactory;
- LLToolBar(const Params&);
- ~LLToolBar();
-
- void initFromParams(const Params&);
- tool_startdrag_callback_t mStartDragItemCallback;
- tool_handledrag_callback_t mHandleDragItemCallback;
- tool_handledrop_callback_t mHandleDropCallback;
- bool mDragAndDropTarget;
- int mDragRank;
- S32 mDragx,
- mDragy,
- mDragGirth;
+ int getRankFromPosition(S32 x, S32 y);
+ int getRankFromPosition(const LLCommandId& id);
-public:
// Methods used in loading and saving toolbar settings
void setButtonType(LLToolBarEnums::ButtonType button_type);
LLToolBarEnums::ButtonType getButtonType() { return mButtonType; }
command_id_list_t& getCommandsList() { return mButtonCommands; }
void clearCommandsList();
-
+
private:
+ friend class LLUICtrlFactory;
+ LLToolBar(const Params&);
+ ~LLToolBar();
+
+ void initFromParams(const Params&);
void createContextMenu();
void updateLayoutAsNeeded();
void createButtons();
void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth);
BOOL isSettingChecked(const LLSD& userdata);
void onSettingEnable(const LLSD& userdata);
+ void onRemoveSelectedCommand();
+private:
+ // static layout state
const bool mReadOnly;
+ const LLToolBarEnums::SideType mSideType;
+ const bool mWrap;
+ const S32 mPadLeft,
+ mPadRight,
+ mPadTop,
+ mPadBottom,
+ mPadBetween,
+ mMinGirth;
+
+ // drag and drop state
+ tool_startdrag_callback_t mStartDragItemCallback;
+ tool_handledrag_callback_t mHandleDragItemCallback;
+ tool_handledrop_callback_t mHandleDropCallback;
+ bool mDragAndDropTarget;
+ int mDragRank;
+ S32 mDragx,
+ mDragy,
+ mDragGirth;
typedef std::list<LLToolBarButton*> toolbar_button_list;
+ typedef std::map<LLUUID, LLToolBarButton*> command_id_map;
toolbar_button_list mButtons;
command_id_list_t mButtonCommands;
- typedef std::map<LLUUID, LLToolBarButton*> command_id_map;
command_id_map mButtonMap;
LLToolBarEnums::ButtonType mButtonType;
+ LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT];
+
+ // related widgets
LLLayoutStack* mCenteringStack;
- LLLayoutStack* mWrapStack;
LLPanel* mButtonPanel;
- LLToolBarEnums::SideType mSideType;
-
- bool mWrap;
- bool mNeedsLayout;
- bool mModified;
- S32 mPadLeft,
- mPadRight,
- mPadTop,
- mPadBottom,
- mPadBetween,
- mMinGirth;
+ LLHandle<class LLContextMenu> mPopupMenuHandle;
- LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT];
+ LLToolBarButton* mRightMouseTargetButton;
- LLHandle<class LLContextMenu> mPopupMenuHandle;
+ bool mNeedsLayout;
+ bool mModified;
button_signal_t* mButtonAddSignal;
button_signal_t* mButtonEnterSignal;