Commits

richard_linden committed f9e42fb

fix for not being able to drag disabled buttons

Comments (0)

Files changed (5)

indra/llui/llbutton.cpp

 	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")),
 	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),
 		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;
 

indra/llui/llbutton.h

 								image_color,
 								image_color_disabled,
 								image_overlay_color,
+								image_overlay_selected_color,
 								image_overlay_disabled_color,
 								flash_color;
 
 	LLPointer<LLUIImage>		mImageOverlay;
 	LLFontGL::HAlign			mImageOverlayAlignment;
 	LLUIColor					mImageOverlayColor;
+	LLUIColor					mImageOverlaySelectedColor;
 	LLUIColor					mImageOverlayDisabledColor;
 
 	LLPointer<LLUIImage>		mImageUnselected;

indra/llui/lltoolbar.cpp

 
 			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)
 	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);
 
 	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();
 			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)
 	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;
 		mUnselectedLabelColor = mOriginalLabelColor;
 		mSelectedLabelColor = mOriginalLabelColorSelected;
 		mImageOverlayColor = mOriginalImageOverlayColor;
+		mOriginalImageOverlaySelectedColor = mOriginalImageOverlaySelectedColor;
 	}
 
 	else
 		mUnselectedLabelColor = mDisabledLabelColor;
 		mSelectedLabelColor = mDisabledSelectedLabelColor;
 		mImageOverlayColor = mImageOverlayDisabledColor;
+		mImageOverlaySelectedColor = mImageOverlayDisabledColor;
 	}
 }
 

indra/llui/lltoolbar.h

 	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;
 							mOriginalImagePressedSelected;
 	LLUIColor				mOriginalLabelColor,
 							mOriginalLabelColorSelected,
-							mOriginalImageOverlayColor;
+							mOriginalImageOverlayColor,
+							mOriginalImageOverlaySelectedColor;
 };
 
 

indra/newview/skins/default/xui/en/floater_tools.xml

      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"