diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lldockablefloater.cpp | 15 | ||||
-rw-r--r-- | indra/llui/lldockablefloater.h | 2 | ||||
-rw-r--r-- | indra/llui/lldockcontrol.cpp | 43 | ||||
-rw-r--r-- | indra/llui/lldockcontrol.h | 1 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 63 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 5 |
6 files changed, 105 insertions, 24 deletions
diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp index aea58be12a..0fcd937361 100644 --- a/indra/llui/lldockablefloater.cpp +++ b/indra/llui/lldockablefloater.cpp @@ -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("windows/Flyout_Left.png"); + break; + case LLDockControl::RIGHT: + mDockTongue = LLUI::getUIImage("windows/Flyout_Right.png"); + break; + default: + mDockTongue = LLUI::getUIImage("windows/Flyout_Pointer.png"); + break; + } + return mDockTongue; } diff --git a/indra/llui/lldockablefloater.h b/indra/llui/lldockablefloater.h index 1484ea3978..89c9852f4a 100644 --- a/indra/llui/lldockablefloater.h +++ b/indra/llui/lldockablefloater.h @@ -124,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..8cb2e57b98 100644 --- a/indra/llui/lldockcontrol.cpp +++ b/indra/llui/lldockcontrol.cpp @@ -203,21 +203,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 +327,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); } diff --git a/indra/llui/lldockcontrol.h b/indra/llui/lldockcontrol.h index 2e7359245f..463223fafd 100644 --- a/indra/llui/lldockcontrol.h +++ b/indra/llui/lldockcontrol.h @@ -43,6 +43,7 @@ public: { TOP, LEFT, + RIGHT, BOTTOM }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 97dc1e3316..287e3e2b41 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -114,6 +114,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mHandleDropCallback(NULL), mButtonAddSignal(NULL), mButtonEnterSignal(NULL), + mButtonLeaveSignal(NULL), + mButtonRemoveSignal(NULL), mDragAndDropTarget(false) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; @@ -125,6 +127,8 @@ LLToolBar::~LLToolBar() delete mPopupMenuHandle.get(); delete mButtonAddSignal; delete mButtonEnterSignal; + delete mButtonLeaveSignal; + delete mButtonRemoveSignal; } void LLToolBar::createContextMenu() @@ -239,13 +243,16 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank) mButtons.insert(it_button,button); } + mNeedsLayout = true; + + updateLayoutAsNeeded(); + + if (mButtonAddSignal) { (*mButtonAddSignal)(button); } - mNeedsLayout = true; - return true; } @@ -272,6 +279,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); @@ -815,6 +827,11 @@ void LLToolBar::createButtons() { BOOST_FOREACH(LLToolBarButton* button, mButtons) { + if (mButtonRemoveSignal) + { + (*mButtonRemoveSignal)(button); + } + delete button; } mButtons.clear(); @@ -826,6 +843,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; } @@ -922,16 +944,34 @@ 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) { - if (!mButtonAddSignal) mButtonAddSignal = new button_signal_t(); - return mButtonAddSignal->connect(cb); + return connectSignal(mButtonAddSignal, cb); } boost::signals2::connection LLToolBar::setButtonEnterCallback(const button_signal_t::slot_type& cb) { - if (!mButtonEnterSignal) mButtonEnterSignal = new button_signal_t(); - return mButtonEnterSignal->connect(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, @@ -1067,6 +1107,17 @@ void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) } } +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() { mIsDragged = false; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 7ceb75aeed..f10f39adc3 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -71,6 +71,7 @@ public: 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(); @@ -202,6 +203,8 @@ public: 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); void setTooltipButtonSuffix(const std::string& suffix) { mButtonTooltipSuffix = suffix; } @@ -269,6 +272,8 @@ private: button_signal_t* mButtonAddSignal; button_signal_t* mButtonEnterSignal; + button_signal_t* mButtonLeaveSignal; + button_signal_t* mButtonRemoveSignal; std::string mButtonTooltipSuffix; }; |