From 78eb989e50e7f91298294d34a743f8ac0e3dcce1 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Sep 2011 19:22:09 -0700
Subject: [PATCH] EXP-1258 FIX toggle buttons between icons and icons+text
 modes fixed button layout for icon only buttons

---
 indra/llui/llbutton.cpp  |  1 +
 indra/llui/lltoolbar.cpp | 30 ++++++++++++++++++------------
 indra/llui/lltoolbar.h   |  1 +
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index e1bea086b2a..f259e8027ea 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -1015,6 +1015,7 @@ void LLButton::resize(LLUIString label)
 				min_width += overlay_width + mImgOverlayLabelSpace;
 				break;
 			case LLFontGL::HCENTER:
+				min_width = llmax(min_width, overlay_width + mLeftHPad + mRightHPad);
 				break;
 			default:
 				// draw nothing
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 57a91516498..c5219b11e86 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -207,7 +207,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId)
 	if (add_command)
 	{
 		mButtonCommands.push_back(commandId);
-		createButtons();
+		createButton(commandId);
 	}
 
 	return add_command;
@@ -498,19 +498,25 @@ void LLToolBar::createButtons()
 	
 	BOOST_FOREACH(LLCommandId& command_id, mButtonCommands)
 	{
-		LLCommand* commandp = LLCommandManager::instance().getCommand(command_id);
-		if (!commandp) continue;
+		createButton(command_id);
+	}
 
-		LLToolBarButton::Params button_p;
-		button_p.label = LLTrans::getString(commandp->labelRef());
-		button_p.image_overlay = LLUI::getUIImage(commandp->icon());
-		button_p.overwriteFrom(mButtonParams[mButtonType]);
-		LLToolBarButton* button = LLUICtrlFactory::create<LLToolBarButton>(button_p);
+}
 
-		mButtons.push_back(button);
-		mButtonPanel->addChild(button);
-	}
+void LLToolBar::createButton(const LLCommandId& id)
+{
+	LLCommand* commandp = LLCommandManager::instance().getCommand(id);
+	if (!commandp) return;
+
+	LLToolBarButton::Params button_p;
+	button_p.label = LLTrans::getString(commandp->labelRef());
+	button_p.tool_tip = button_p.label();
+	button_p.image_overlay = LLUI::getUIImage(commandp->icon());
+	button_p.overwriteFrom(mButtonParams[mButtonType]);
+	LLToolBarButton* button = LLUICtrlFactory::create<LLToolBarButton>(button_p);
+
+	mButtons.push_back(button);
+	mButtonPanel->addChild(button);
 
 	mNeedsLayout = true;
 }
-
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 75ae499a3db..02db58128c8 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -135,6 +135,7 @@ class LLToolBar
 	void createContextMenu();
 	void updateLayoutAsNeeded();
 	void createButtons();
+	void createButton(const LLCommandId& id);
 	void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth);
 	BOOL isSettingChecked(const LLSD& userdata);
 	void onSettingEnable(const LLSD& userdata);
-- 
GitLab