diff options
author | Leslie Linden <leslie@lindenlab.com> | 2011-10-05 16:28:40 -0700 |
---|---|---|
committer | Leslie Linden <leslie@lindenlab.com> | 2011-10-05 16:28:40 -0700 |
commit | 93e3c8e4a51dd60c202bc2e3f11b9ae850b2b6c8 (patch) | |
tree | fddefdec4836432e37ec062fc29ff88711abd9be /indra/llui/lltoolbar.cpp | |
parent | 1c4d540afd488c5b64102fc14ea65433855f802a (diff) |
EXP-1280 FIX -- Minimized floaters associated with toolbar buttons should change the state of their parent button
* Toolbar buttons now display green when its corresponding floater is open or
minimized.
* Made changes to buttons so flash time and rate is configurable
* Removed unused "highlight_color" attribute from LLButton
* Implemented "isVisible" function for toolbar button floaters. It returns true
when the floater is visible or minimized.
* Toolbar floater unminimize now also puts focus to the floater
* All commands now specify their "is_running_function" for toolbar button state
* ButtonFlashCount and ButtonFlashRate have been moved to button.xml settings
and are now configurable on the button. Toolbar buttons are set to never
flash and this functionality is used to show which buttons have windows open.
* All toybox buttons show hover glow even when disabled
Reviewed by Richard.
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 89 |
1 files changed, 84 insertions, 5 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a544aa9ec7..0ec2eefc19 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -471,7 +471,33 @@ void LLToolBar::updateLayoutAsNeeded() void LLToolBar::draw() { - if (mButtons.empty()) return; + if (mButtons.empty()) + { + return; + } + + // Update enable/disable state and highlight state for editable toolbars + if (!mReadOnly) + { + for (toolbar_button_list::iterator btn_it = mButtons.begin(); btn_it != mButtons.end(); ++btn_it) + { + LLToolBarButton* btn = *btn_it; + LLCommand* command = LLCommandManager::instance().getCommand(btn->mId); + + if (command && btn->mIsEnabledSignal) + { + const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); + btn->setEnabled(button_command_enabled); + } + + if (command && btn->mIsRunningSignal) + { + const bool button_command_running = (*btn->mIsRunningSignal)(btn, command->isRunningParameters()); + btn->setFlashing(button_command_running); + } + } + } + updateLayoutAsNeeded(); // rect may have shifted during layout LLUI::popMatrix(); @@ -527,14 +553,47 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) LLUICtrl::CommitCallbackParam cbParam; cbParam.function_name = commandp->executeFunctionName(); cbParam.parameter = commandp->executeParameters(); + button->setCommitCallback(cbParam); button->setStartDragCallback(mStartDragItemCallback); button->setHandleDragCallback(mHandleDragItemCallback); + + const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); + if (isEnabledFunction.length() > 0) + { + LLUICtrl::EnableCallbackParam isEnabledParam; + isEnabledParam.function_name = isEnabledFunction; + isEnabledParam.parameter = commandp->isEnabledParameters(); + enable_signal_t::slot_type isEnabledCB = initEnableCallback(isEnabledParam); + + if (NULL == button->mIsEnabledSignal) + { + button->mIsEnabledSignal = new enable_signal_t(); + } + + button->mIsEnabledSignal->connect(isEnabledCB); + } + + const std::string& isRunningFunction = commandp->isRunningFunctionName(); + if (isRunningFunction.length() > 0) + { + LLUICtrl::EnableCallbackParam isRunningParam; + isRunningParam.function_name = isRunningFunction; + isRunningParam.parameter = commandp->isRunningParameters(); + enable_signal_t::slot_type isRunningCB = initEnableCallback(isRunningParam); + + if (NULL == button->mIsRunningSignal) + { + button->mIsRunningSignal = new enable_signal_t(); + } + + button->mIsRunningSignal->connect(isRunningCB); + } } button->setCommandId(id); - return button; + return button; } BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -568,9 +627,22 @@ LLToolBarButton::LLToolBarButton(const Params& p) mMouseDownY(0), mWidthRange(p.button_width), mDesiredHeight(p.desired_height), - mId("") + mId(""), + mIsEnabledSignal(NULL), + mIsRunningSignal(NULL), + mIsStartingSignal(NULL) { mUUID = LLUUID::generateNewID(p.name); + + mButtonFlashRate = 0.0; + mButtonFlashCount = 0; +} + +LLToolBarButton::~LLToolBarButton() +{ + delete mIsEnabledSignal; + delete mIsRunningSignal; + delete mIsStartingSignal; } BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) @@ -594,10 +666,10 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) handled = TRUE; } else - { + { handled = mHandleDragItemCallback(x,y,mUUID,LLAssetType::AT_WIDGET); - } } + } else { handled = LLButton::handleHover(x, y, mask); @@ -605,3 +677,10 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) return handled; } +void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) +{ + LLUICtrl::onMouseEnter(x, y, mask); + + // Always highlight toolbar buttons, even if they are disabled + mNeedsHighlight = TRUE; +} |