summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2011-10-17 13:42:35 -0700
committerRichard Nelson <richard@lindenlab.com>2011-10-17 13:42:35 -0700
commita2e32429bbe222342c413eb06e2820f6292e251a (patch)
tree44a73367daeee0451d96e76e836077d53b5f0ace
parent67a618777286e1d0ce7cfc2a956bf15ff2173005 (diff)
fix for not being able to drag disabled buttons
-rw-r--r--indra/llui/llbutton.cpp10
-rw-r--r--indra/llui/llbutton.h2
-rw-r--r--indra/llui/lltoolbar.cpp58
-rw-r--r--indra/llui/lltoolbar.h5
-rw-r--r--indra/newview/skins/default/xui/en/floater_tools.xml3
5 files changed, 53 insertions, 25 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 64fd14ecc9..2d3007cd5f 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())
{
- 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..8faa9b3988 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,6 +1014,7 @@ void LLToolBarButton::setEnabled(BOOL enabled)
mUnselectedLabelColor = mOriginalLabelColor;
mSelectedLabelColor = mOriginalLabelColorSelected;
mImageOverlayColor = mOriginalImageOverlayColor;
+ mOriginalImageOverlaySelectedColor = mOriginalImageOverlaySelectedColor;
}
else
@@ -1009,6 +1026,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;
};
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index 465bd86281..1808cab2a5 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -516,7 +516,8 @@
image_disabled_selected="Object_Grass"
image_selected="Object_Grass_Selected"
image_unselected="Object_Grass"
- image_overlay_color="Red"
+ image_overlay_color="1 0 0 .75"
+ image_overlay_selected_color="1 0 0 1"
layout="topleft"
left_delta="29"
name="ToolGrass"