diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lldockablefloater.cpp | 17 | ||||
-rw-r--r-- | indra/llui/lldockablefloater.h | 4 | ||||
-rw-r--r-- | indra/llui/lldockcontrol.cpp | 62 | ||||
-rw-r--r-- | indra/llui/lldockcontrol.h | 4 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llkeywords.h | 2 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 5 | ||||
-rw-r--r-- | indra/llui/llmenugl.h | 4 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 169 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 102 |
10 files changed, 280 insertions, 93 deletions
diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp index aea58be12a..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(); } @@ -239,8 +239,21 @@ void LLDockableFloater::setDockControl(LLDockControl* dockControl) setDocked(isDocked()); } -const LLUIImagePtr& LLDockableFloater::getDockTongue() +const LLUIImagePtr& LLDockableFloater::getDockTongue(LLDockControl::DocAt dock_side) { + switch(dock_side) + { + case LLDockControl::LEFT: + mDockTongue = LLUI::getUIImage("Flyout_Left"); + break; + case LLDockControl::RIGHT: + mDockTongue = LLUI::getUIImage("Flyout_Right"); + break; + default: + mDockTongue = LLUI::getUIImage("Flyout_Pointer"); + break; + } + return mDockTongue; } diff --git a/indra/llui/lldockablefloater.h b/indra/llui/lldockablefloater.h index 8deb6c1159..89c9852f4a 100644 --- a/indra/llui/lldockablefloater.h +++ b/indra/llui/lldockablefloater.h @@ -113,6 +113,8 @@ public: bool getUniqueDocking() { return mUniqueDocking; } bool getUseTongue() { return mUseTongue; } + + void setUseTongue(bool use_tongue) { mUseTongue = use_tongue;} private: /** * Provides unique of dockable floater. @@ -122,7 +124,7 @@ private: protected: void setDockControl(LLDockControl* dockControl); - const LLUIImagePtr& getDockTongue(); + const LLUIImagePtr& getDockTongue(LLDockControl::DocAt dock_side = LLDockControl::TOP); // Checks if docking should be forced. // It may be useful e.g. if floater created in mouselook mode (see EXT-5609) diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp index 6397bbd0de..af39e41fa6 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -100,12 +100,16 @@ void LLDockControl::repositionDockable() if (!mDockWidget) return; LLRect dockRect = mDockWidget->calcScreenRect(); LLRect rootRect; + LLRect floater_rect = mDockableFloater->calcScreenRect(); mGetAllowedRectCallback(rootRect); - // recalculate dockable position if dock position changed, dock visibility changed, - // root view rect changed or recalculation is forced - if (mPrevDockRect != dockRect || mDockWidgetVisible != isDockVisible() - || mRootRect != rootRect || mRecalculateDocablePosition) + // recalculate dockable position if: + if (mPrevDockRect != dockRect //dock position changed + || mDockWidgetVisible != isDockVisible() //dock visibility changed + || mRootRect != rootRect //root view rect changed + || mFloaterRect != floater_rect //floater rect changed + || mRecalculateDockablePosition //recalculation is forced + ) { // undock dockable and off() if dock not visible if (!isDockVisible()) @@ -136,7 +140,8 @@ void LLDockControl::repositionDockable() mPrevDockRect = dockRect; mRootRect = rootRect; - mRecalculateDocablePosition = false; + mFloaterRect = floater_rect; + mRecalculateDockablePosition = false; mDockWidgetVisible = isDockVisible(); } } @@ -203,21 +208,33 @@ void LLDockControl::moveDockable() switch (mDockAt) { case LEFT: - x = dockRect.mLeft; - y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight(); - // check is dockable inside root view rect - if (x < rootRect.mLeft) + + x = dockRect.mLeft - dockableRect.getWidth(); + y = dockRect.getCenterY() + dockableRect.getHeight() / 2; + + if (use_tongue) { - x = rootRect.mLeft; + x -= mDockTongue->getWidth(); } - if (x + dockableRect.getWidth() > rootRect.mRight) + + mDockTongueX = dockableRect.mRight; + mDockTongueY = dockableRect.getCenterY() - mDockTongue->getHeight() / 2; + + break; + + case RIGHT: + + x = dockRect.mRight; + y = dockRect.getCenterY() + dockableRect.getHeight() / 2; + + if (use_tongue) { - x = rootRect.mRight - dockableRect.getWidth(); + x += mDockTongue->getWidth(); } - - mDockTongueX = x + dockableRect.getWidth()/2 - mDockTongue->getWidth() / 2; - - mDockTongueY = dockRect.mTop; + + mDockTongueX = dockRect.mRight; + mDockTongueY = dockableRect.getCenterY() - mDockTongue->getHeight() / 2; + break; case TOP: @@ -315,13 +332,12 @@ void LLDockControl::moveDockable() dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), dockableRect.getHeight()); } + LLRect localDocableParentRect; - mDockableFloater->getParent()->screenRectToLocal(dockableRect, - &localDocableParentRect); - mDockableFloater->setRect(localDocableParentRect); - mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY, - &mDockTongueX, &mDockTongueY); + mDockableFloater->getParent()->screenRectToLocal(dockableRect, &localDocableParentRect); + mDockableFloater->setRect(localDocableParentRect); + mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY, &mDockTongueX, &mDockTongueY); } @@ -330,7 +346,7 @@ void LLDockControl::on() if (isDockVisible()) { mEnabled = true; - mRecalculateDocablePosition = true; + mRecalculateDockablePosition = true; } } @@ -341,7 +357,7 @@ void LLDockControl::off() void LLDockControl::forceRecalculatePosition() { - mRecalculateDocablePosition = true; + mRecalculateDockablePosition = true; } void LLDockControl::drawToungue() diff --git a/indra/llui/lldockcontrol.h b/indra/llui/lldockcontrol.h index 2e7359245f..c9602011f6 100644 --- a/indra/llui/lldockcontrol.h +++ b/indra/llui/lldockcontrol.h @@ -43,6 +43,7 @@ public: { TOP, LEFT, + RIGHT, BOTTOM }; @@ -79,12 +80,13 @@ private: private: get_allowed_rect_callback_t mGetAllowedRectCallback; bool mEnabled; - bool mRecalculateDocablePosition; + bool mRecalculateDockablePosition; bool mDockWidgetVisible; DocAt mDockAt; LLView* mDockWidget; LLRect mPrevDockRect; LLRect mRootRect; + LLRect mFloaterRect; LLFloater* mDockableFloater; LLUIImagePtr mDockTongue; S32 mDockTongueX; diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 7100ea13a7..432397d3e9 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -935,7 +935,7 @@ void LLFloater::applyPositioning(LLFloater* other) case LLFloaterEnums::OPEN_POSITIONING_CASCADE_GROUP: case LLFloaterEnums::OPEN_POSITIONING_CASCADING: - if (other != NULL) + if (other != NULL && other != this) { stackWith(*other); } @@ -1070,7 +1070,7 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) const LLRect old_rect = getRect(); LLView::handleReshape(new_rect, by_user); - if (by_user) + if (by_user && !isMinimized()) { storeRectControl(); mOpenPositioning = LLFloaterEnums::OPEN_POSITIONING_NONE; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index d050cd7d7c..ac34015393 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -51,7 +51,7 @@ public: * - TWO_SIDED_DELIMITER are for delimiters that end with a different delimiter than they open with. * - DOUBLE_QUOTATION_MARKS are for delimiting areas using the same delimiter to open and close. */ - typedef enum TOKEN_TYPE + enum TOKEN_TYPE { WORD, LINE, 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 515605200e..e7642ae190 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -109,9 +109,14 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mPadBetween(p.pad_between), mMinGirth(p.min_girth), mPopupMenuHandle(), + mRightMouseTargetButton(NULL), mStartDragItemCallback(NULL), mHandleDragItemCallback(NULL), mHandleDropCallback(NULL), + mButtonAddSignal(NULL), + mButtonEnterSignal(NULL), + mButtonLeaveSignal(NULL), + mButtonRemoveSignal(NULL), mDragAndDropTarget(false) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; @@ -121,6 +126,10 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) LLToolBar::~LLToolBar() { delete mPopupMenuHandle.get(); + delete mButtonAddSignal; + delete mButtonEnterSignal; + delete mButtonLeaveSignal; + delete mButtonRemoveSignal; } void LLToolBar::createContextMenu() @@ -131,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)); @@ -212,7 +222,6 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) mButtonPanel->addChild(button); mButtonMap.insert(std::make_pair(commandId.uuid(), button)); - // Insert the command and button in the right place in their respective lists if ((rank >= mButtonCommands.size()) || (rank == RANK_NONE)) { @@ -238,6 +247,14 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) mNeedsLayout = true; + updateLayoutAsNeeded(); + + + if (mButtonAddSignal) + { + (*mButtonAddSignal)(button); + } + return true; } @@ -264,6 +281,11 @@ int LLToolBar::removeCommand(const LLCommandId& commandId) ++rank; } + if (mButtonRemoveSignal) + { + (*mButtonRemoveSignal)(*it_button); + } + // Delete the button and erase the command and button records delete (*it_button); mButtonCommands.erase(it_command); @@ -352,6 +374,23 @@ bool LLToolBar::stopCommandInProgress(const LLCommandId& commandId) return (command_button != NULL); } +bool LLToolBar::flashCommand(const LLCommandId& commandId, bool flash) +{ + LLButton * command_button = NULL; + + if (commandId != LLCommandId::null) + { + command_id_map::iterator it = mButtonMap.find(commandId.uuid()); + if (it != mButtonMap.end()) + { + command_button = it->second; + command_button->setFlashing(flash ? TRUE : FALSE); + } + } + + return (command_button != NULL); +} + BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) { LLRect button_panel_rect; @@ -360,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(); @@ -409,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); @@ -487,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; @@ -518,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; } @@ -790,10 +855,16 @@ void LLToolBar::createButtons() { BOOST_FOREACH(LLToolBarButton* button, mButtons) { + if (mButtonRemoveSignal) + { + (*mButtonRemoveSignal)(button); + } + delete button; } mButtons.clear(); mButtonMap.clear(); + mRightMouseTargetButton = NULL; BOOST_FOREACH(LLCommandId& command_id, mButtonCommands) { @@ -801,6 +872,11 @@ void LLToolBar::createButtons() mButtons.push_back(button); mButtonPanel->addChild(button); mButtonMap.insert(std::make_pair(command_id.uuid(), button)); + + if (mButtonAddSignal) + { + (*mButtonAddSignal)(button); + } } mNeedsLayout = true; } @@ -870,8 +946,7 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) button->setCommitCallback(executeParam); } - - + // Set up "is running" query callback const std::string& isRunningFunction = commandp->isRunningFunctionName(); if (isRunningFunction.length() > 0) { @@ -898,6 +973,36 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) return button; } +boost::signals2::connection connectSignal(LLToolBar::button_signal_t*& signal, const LLToolBar::button_signal_t::slot_type& cb) +{ + if (!signal) + { + signal = new LLToolBar::button_signal_t(); + } + + return signal->connect(cb); +} + +boost::signals2::connection LLToolBar::setButtonAddCallback(const button_signal_t::slot_type& cb) +{ + return connectSignal(mButtonAddSignal, cb); +} + +boost::signals2::connection LLToolBar::setButtonEnterCallback(const button_signal_t::slot_type& cb) +{ + return connectSignal(mButtonEnterSignal, cb); +} + +boost::signals2::connection LLToolBar::setButtonLeaveCallback(const button_signal_t::slot_type& cb) +{ + return connectSignal(mButtonLeaveSignal, cb); +} + +boost::signals2::connection LLToolBar::setButtonRemoveCallback(const button_signal_t::slot_type& cb) +{ + return connectSignal(mButtonRemoveSignal, cb); +} + BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, @@ -969,8 +1074,6 @@ LLToolBarButton::LLToolBarButton(const Params& p) mOriginalImageOverlayColor(p.image_overlay_color), mOriginalImageOverlaySelectedColor(p.image_overlay_selected_color) { - mButtonFlashRate = 0.0; - mButtonFlashCount = 0; } LLToolBarButton::~LLToolBarButton() @@ -1012,6 +1115,7 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) { handled = LLButton::handleHover(x, y, mask); } + return handled; } @@ -1024,6 +1128,23 @@ void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) { mNeedsHighlight = TRUE; } + + LLToolBar* parent_toolbar = getParentByType<LLToolBar>(); + if (parent_toolbar && parent_toolbar->mButtonEnterSignal) + { + (*(parent_toolbar->mButtonEnterSignal))(this); + } +} + +void LLToolBarButton::onMouseLeave(S32 x, S32 y, MASK mask) +{ + LLButton::onMouseLeave(x, y, mask); + + LLToolBar* parent_toolbar = getParentByType<LLToolBar>(); + if (parent_toolbar && parent_toolbar->mButtonLeaveSignal) + { + (*(parent_toolbar->mButtonLeaveSignal))(this); + } } void LLToolBarButton::onMouseCaptureLost() @@ -1072,25 +1193,25 @@ void LLToolBarButton::setEnabled(BOOL enabled) } } - const std::string LLToolBarButton::getToolTip() const { std::string tooltip; + if (labelIsTruncated() || getCurrentLabel().empty()) { - return LLTrans::getString(LLCommandManager::instance().getCommand(mId)->labelRef()) + " -- " + LLView::getToolTip(); + tooltip = LLTrans::getString(LLCommandManager::instance().getCommand(mId)->labelRef()) + " -- " + LLView::getToolTip(); } else { - return LLView::getToolTip(); + tooltip = LLView::getToolTip(); } -} - - - - - - + LLToolBar* parent_toolbar = getParentByType<LLToolBar>(); + if (parent_toolbar && parent_toolbar->mButtonTooltipSuffix.length() > 0) + { + tooltip = tooltip + "\n(" + parent_toolbar->mButtonTooltipSuffix + ")"; + } + return tooltip; +} diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index e634e57f93..51fe23ddd1 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -63,14 +63,17 @@ 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; } void onMouseEnter(S32 x, S32 y, MASK mask); + void onMouseLeave(S32 x, S32 y, MASK mask); void onMouseCaptureLost(); void onCommit(); @@ -120,6 +123,8 @@ namespace LLToolBarEnums SIDE_RIGHT, SIDE_TOP, }; + + LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType); } // NOTE: This needs to occur before Param block declaration for proper compilation. @@ -142,6 +147,7 @@ namespace LLInitParam class LLToolBar : public LLUICtrl { + friend class LLToolBarButton; public: struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { @@ -160,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; @@ -171,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, @@ -181,80 +186,103 @@ 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 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; } LLToolBarButton* createButton(const LLCommandId& id); + typedef boost::signals2::signal<void (LLView* button)> button_signal_t; + boost::signals2::connection setButtonAddCallback(const button_signal_t::slot_type& cb); + boost::signals2::connection setButtonEnterCallback(const button_signal_t::slot_type& cb); + boost::signals2::connection setButtonLeaveCallback(const button_signal_t::slot_type& cb); + boost::signals2::connection setButtonRemoveCallback(const button_signal_t::slot_type& cb); + + // 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; + LLHandle<class LLContextMenu> mPopupMenuHandle; + + LLToolBarButton* mRightMouseTargetButton; + bool mNeedsLayout; bool mModified; - S32 mPadLeft, - mPadRight, - mPadTop, - mPadBottom, - mPadBetween, - mMinGirth; - LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; + button_signal_t* mButtonAddSignal; + button_signal_t* mButtonEnterSignal; + button_signal_t* mButtonLeaveSignal; + button_signal_t* mButtonRemoveSignal; - LLHandle<class LLContextMenu> mPopupMenuHandle; + std::string mButtonTooltipSuffix; }; |