diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 12 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 2 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 59 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 5 |
4 files changed, 52 insertions, 26 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 64fd14ecc9..74b8885e1f 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -85,7 +85,9 @@ LLButton::Params::Params() label_color_disabled_selected("label_color_disabled_selected"), image_color("image_color"), image_color_disabled("image_color_disabled"), - image_overlay_color("image_overlay_color", LLColor4::white), + image_overlay_color("image_overlay_color", LLColor4::white % 0.75f), + image_overlay_disabled_color("image_overlay_disabled_color", LLColor4::white % 0.3f), + image_overlay_selected_color("image_overlay_selected_color", LLColor4::white), flash_color("flash_color"), pad_right("pad_right", LLUI::sSettingGroups["config"]->getS32("ButtonHPad")), pad_left("pad_left", LLUI::sSettingGroups["config"]->getS32("ButtonHPad")), @@ -143,6 +145,8 @@ LLButton::LLButton(const LLButton::Params& p) mDisabledImageColor(p.image_color_disabled()), mImageOverlay(p.image_overlay()), mImageOverlayColor(p.image_overlay_color()), + mImageOverlayDisabledColor(p.image_overlay_disabled_color()), + mImageOverlaySelectedColor(p.image_overlay_selected_color()), mImageOverlayAlignment(LLFontGL::hAlignFromName(p.image_overlay_alignment)), mImageOverlayTopPad(p.image_top_pad), mImageOverlayBottomPad(p.image_bottom_pad), @@ -817,11 +821,11 @@ void LLButton::draw() LLColor4 overlay_color = mImageOverlayColor.get(); if (!enabled) { - overlay_color.mV[VALPHA] = 0.3f; + overlay_color = mImageOverlayDisabledColor.get(); } - else if (!getToggleState()) + else if (getToggleState()) { - overlay_color.mV[VALPHA] = 0.75f; + overlay_color = mImageOverlaySelectedColor.get(); } overlay_color.mV[VALPHA] *= alpha; diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 1aa58ed9aa..deaa0823c6 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -94,6 +94,7 @@ public: image_color, image_color_disabled, image_overlay_color, + image_overlay_selected_color, image_overlay_disabled_color, flash_color; @@ -305,6 +306,7 @@ protected: LLPointer<LLUIImage> mImageOverlay; LLFontGL::HAlign mImageOverlayAlignment; LLUIColor mImageOverlayColor; + LLUIColor mImageOverlaySelectedColor; LLUIColor mImageOverlayDisabledColor; LLPointer<LLUIImage> mImageUnselected; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 278e7826b7..629c7d9bc7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -690,9 +690,8 @@ void LLToolBar::draw() if (command && btn->mIsEnabledSignal) { - //const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); - // TODO: make button appear disabled but have it still respond to drag and drop - btn->setEnabled(false);//button_command_enabled); + const bool button_command_enabled = (*btn->mIsEnabledSignal)(btn, command->isEnabledParameters()); + btn->setEnabled(button_command_enabled); } if (command && btn->mIsRunningSignal) @@ -763,6 +762,16 @@ void LLToolBar::createButtons() mNeedsLayout = true; } +void LLToolBarButton::callIfEnabled(LLUICtrl::commit_callback_t commit, LLUICtrl* ctrl, const LLSD& param ) +{ + LLCommand* command = LLCommandManager::instance().getCommand(mId); + + if (!mIsEnabledSignal || (*mIsEnabledSignal)(this, command->isEnabledParameters())) + { + commit(ctrl, param); + } +} + LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) { LLCommand* commandp = LLCommandManager::instance().getCommand(id); @@ -778,6 +787,24 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) if (!mReadOnly) { + enable_callback_t isEnabledCB; + + const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); + if (isEnabledFunction.length() > 0) + { + LLUICtrl::EnableCallbackParam isEnabledParam; + isEnabledParam.function_name = isEnabledFunction; + isEnabledParam.parameter = commandp->isEnabledParameters(); + isEnabledCB = initEnableCallback(isEnabledParam); + + if (NULL == button->mIsEnabledSignal) + { + button->mIsEnabledSignal = new enable_signal_t(); + } + + button->mIsEnabledSignal->connect(isEnabledCB); + } + LLUICtrl::CommitCallbackParam executeParam; executeParam.function_name = commandp->executeFunctionName(); executeParam.parameter = commandp->executeParameters(); @@ -789,30 +816,18 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) LLUICtrl::CommitCallbackParam executeStopParam; executeStopParam.function_name = executeStopFunction; executeStopParam.parameter = commandp->executeStopParameters(); + LLUICtrl::commit_callback_t execute_func = initCommitCallback(executeParam); + LLUICtrl::commit_callback_t stop_func = initCommitCallback(executeStopParam); - button->setMouseDownCallback(executeParam); - button->setMouseUpCallback(executeStopParam); + button->setMouseDownCallback(boost::bind(&LLToolBarButton::callIfEnabled, button, execute_func, _1, _2)); + button->setMouseUpCallback(boost::bind(&LLToolBarButton::callIfEnabled, button, stop_func, _1, _2)); } else { button->setCommitCallback(executeParam); } - 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) @@ -908,7 +923,8 @@ LLToolBarButton::LLToolBarButton(const Params& p) mOriginalImagePressedSelected(p.image_pressed_selected), mOriginalLabelColor(p.label_color), mOriginalLabelColorSelected(p.label_color_selected), - mOriginalImageOverlayColor(p.image_overlay_color) + mOriginalImageOverlayColor(p.image_overlay_color), + mOriginalImageOverlaySelectedColor(p.image_overlay_selected_color) { mButtonFlashRate = 0.0; mButtonFlashCount = 0; @@ -998,8 +1014,8 @@ void LLToolBarButton::setEnabled(BOOL enabled) mUnselectedLabelColor = mOriginalLabelColor; mSelectedLabelColor = mOriginalLabelColorSelected; mImageOverlayColor = mOriginalImageOverlayColor; + mImageOverlaySelectedColor = mOriginalImageOverlaySelectedColor; } - else { mImageSelected = mImageDisabledSelected; @@ -1009,6 +1025,7 @@ void LLToolBarButton::setEnabled(BOOL enabled) mUnselectedLabelColor = mDisabledLabelColor; mSelectedLabelColor = mDisabledSelectedLabelColor; mImageOverlayColor = mImageOverlayDisabledColor; + mImageOverlaySelectedColor = mImageOverlayDisabledColor; } } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 47af039d52..616710ea70 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -77,6 +77,8 @@ public: virtual const std::string getToolTip() const; private: + void callIfEnabled(LLUICtrl::commit_callback_t commit, LLUICtrl* ctrl, const LLSD& param ); + LLCommandId mId; S32 mMouseDownX; S32 mMouseDownY; @@ -95,7 +97,8 @@ private: mOriginalImagePressedSelected; LLUIColor mOriginalLabelColor, mOriginalLabelColorSelected, - mOriginalImageOverlayColor; + mOriginalImageOverlayColor, + mOriginalImageOverlaySelectedColor; }; |