From 948b56e7c288471ce87838d12cb17b3f34885274 Mon Sep 17 00:00:00 2001
From: Leslie Linden <leslie@lindenlab.com>
Date: Mon, 31 Oct 2011 12:05:56 -0700
Subject: * Added "clear all" button to the toybox floater with corresponding
 functions   added to LLToolBarView to perform the action. * Updated toybox to
 new height size per XD.

---
 indra/newview/llfloatertoybox.cpp                  | 21 +++++++++++++++
 indra/newview/llfloatertoybox.h                    |  1 +
 indra/newview/lltoolbarview.cpp                    | 30 ++++++++++++++++++++++
 indra/newview/lltoolbarview.h                      |  4 +++
 .../skins/default/xui/en/floater_toybox.xml        | 24 ++++++++++++-----
 .../newview/skins/default/xui/en/notifications.xml | 18 +++++++++++--
 6 files changed, 90 insertions(+), 8 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp
index f527937e8f..324afe661f 100644
--- a/indra/newview/llfloatertoybox.cpp
+++ b/indra/newview/llfloatertoybox.cpp
@@ -42,6 +42,7 @@ LLFloaterToybox::LLFloaterToybox(const LLSD& key)
 	, mToolBar(NULL)
 {
 	mCommitCallbackRegistrar.add("Toybox.RestoreDefaults", boost::bind(&LLFloaterToybox::onBtnRestoreDefaults, this));
+	mCommitCallbackRegistrar.add("Toybox.ClearAll", boost::bind(&LLFloaterToybox::onBtnClearAll, this));
 }
 
 LLFloaterToybox::~LLFloaterToybox()
@@ -121,15 +122,35 @@ static bool finish_restore_toybox(const LLSD& notification, const LLSD& response
 	{
 		LLToolBarView::loadDefaultToolbars();
 	}
+
 	return false;
 }
+
+static bool finish_clear_all_toybox(const LLSD& notification, const LLSD& response)
+{
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+
+	if (option == 0)
+	{
+		LLToolBarView::clearAllToolbars();
+	}
+
+	return false;
+}
+
 static LLNotificationFunctorRegistration finish_restore_toybox_reg("ConfirmRestoreToybox", finish_restore_toybox);
+static LLNotificationFunctorRegistration finish_clear_all_toybox_reg("ConfirmClearAllToybox", finish_clear_all_toybox);
 
 void LLFloaterToybox::onBtnRestoreDefaults()
 {
 	LLNotificationsUtil::add("ConfirmRestoreToybox");
 }
 
+void LLFloaterToybox::onBtnClearAll()
+{
+	LLNotificationsUtil::add("ConfirmClearAllToybox");
+}
+
 BOOL LLFloaterToybox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 	EDragAndDropType cargo_type,
 	void* cargo_data,
diff --git a/indra/newview/llfloatertoybox.h b/indra/newview/llfloatertoybox.h
index 6f0275b8fe..10aee0e6f5 100644
--- a/indra/newview/llfloatertoybox.h
+++ b/indra/newview/llfloatertoybox.h
@@ -50,6 +50,7 @@ public:
 		std::string& tooltip_msg);
 
 protected:
+	void onBtnClearAll();
 	void onBtnRestoreDefaults();
 
 	void onToolBarButtonEnter(LLView* button);
diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp
index ed1dfbb8cd..5ff0ccfeb2 100644
--- a/indra/newview/lltoolbarview.cpp
+++ b/indra/newview/lltoolbarview.cpp
@@ -315,6 +315,19 @@ bool LLToolBarView::loadToolbars(bool force_default)
 	return true;
 }
 
+bool LLToolBarView::clearToolbars()
+{
+	for (S32 i = TOOLBAR_FIRST; i <= TOOLBAR_LAST; i++)
+	{
+		if (mToolbars[i])
+		{
+			mToolbars[i]->clearCommandsList();
+		}
+	}
+
+	return true;
+}
+
 //static
 bool LLToolBarView::loadDefaultToolbars()
 {
@@ -332,6 +345,23 @@ bool LLToolBarView::loadDefaultToolbars()
 	return retval;
 }
 
+//static
+bool LLToolBarView::clearAllToolbars()
+{
+	bool retval = false;
+
+	if (gToolBarView)
+	{
+		retval = gToolBarView->clearToolbars();
+		if (retval)
+		{
+			gToolBarView->saveToolbars();
+		}
+	}
+
+	return retval;
+}
+
 void LLToolBarView::saveToolbars() const
 {
 	if (!mToolbarsLoaded)
diff --git a/indra/newview/lltoolbarview.h b/indra/newview/lltoolbarview.h
index 4307d10258..f871d522a2 100644
--- a/indra/newview/lltoolbarview.h
+++ b/indra/newview/lltoolbarview.h
@@ -93,10 +93,14 @@ public:
 
 	// Loads the toolbars from the existing user or default settings
 	bool loadToolbars(bool force_default = false);	// return false if load fails
+
+	// Clears all buttons off the toolbars
+	bool clearToolbars();
 	
 	void setToolBarsVisible(bool visible);
 
 	static bool loadDefaultToolbars();
+	static bool clearAllToolbars();
 	
 	static void startDragTool(S32 x, S32 y, LLToolBarButton* toolbarButton);
 	static BOOL handleDragTool(S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type);
diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml
index ef3951a1cd..493d44a9cf 100644
--- a/indra/newview/skins/default/xui/en/floater_toybox.xml
+++ b/indra/newview/skins/default/xui/en/floater_toybox.xml
@@ -5,7 +5,7 @@
   can_minimize="false"
   can_resize="false"
   default_tab_group="1"
-  height="460"
+  height="330"
   help_topic="toybox"
   layout="topleft"
   legacy_header_height="18"
@@ -46,7 +46,7 @@
       Buttons will appear as shown or as icon-only depending on each toolbar's settings.
   </text>
   <toolbar
-    bottom="395"
+    bottom="265"
     button_display_mode="icons_with_text"
     follows="all"
     left="20"
@@ -82,20 +82,32 @@
   <panel
     bevel_style="none"
     border="true"
-    bottom="396"
+    bottom="266"
     follows="left|bottom|right"
     left="20"
     right="-20"
-    top="396" />
+    top="266" />
+  <button
+    follows="left|bottom|right"
+    height="23"
+    label="Clear all toolbars"
+    label_selected="Clear all toolbars"
+    layout="topleft"
+    left="185"
+    name="btn_clear_all"
+    top="285"
+    width="130">
+    <button.commit_callback function="Toybox.ClearAll" />
+  </button>
   <button
     follows="left|bottom|right"
     height="23"
     label="Restore defaults"
     label_selected="Restore defaults"
     layout="topleft"
-    left="260"
+    left="335"
     name="btn_restore_defaults"
-    top="415"
+    top="285"
     width="130">
     <button.commit_callback function="Toybox.RestoreDefaults" />
   </button>
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 3ed8c30ca8..e4458f33b1 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -4636,7 +4636,21 @@ Are you sure you want to quit?
    name="ConfirmRestoreToybox"
    type="alertmodal">
     <unique/>
-Are you sure you want to restore your default buttons and toolbars? 
+This action will restore your default buttons and toolbars.
+
+You cannot undo this action.
+    <usetemplate
+     name="okcancelbuttons"
+     notext="Cancel"
+     yestext="OK"/>
+  </notification>
+
+  <notification
+   icon="alertmodal.tga"
+   name="ConfirmClearAllToybox"
+   type="alertmodal">
+    <unique/>
+This action will return all buttons to the toolbox and your toolbars will be empty.
     
 You cannot undo this action.
     <usetemplate
@@ -4644,7 +4658,7 @@ You cannot undo this action.
      notext="Cancel"
      yestext="OK"/>
   </notification>
-  
+
   <notification
    icon="alertmodal.tga"
    name="DeleteItems"
-- 
cgit v1.2.3