summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2011-09-29 15:01:15 -0700
committerMerov Linden <merov@lindenlab.com>2011-09-29 15:01:15 -0700
commitb07e7c7198fbc78ca852b3ba48d516ec2901da21 (patch)
treeb7b2323439e2d3e5d32ce69c43540d1b38e454d3
parent71ed326f51770b215ba5dd2ac8d159c3b764c2d2 (diff)
EXP-1211, EXP-1257 : Save and load the button type along with the toolbars, add a force default load option, enforce consistency between menus and toolbars
-rw-r--r--indra/llui/lltoolbar.cpp27
-rw-r--r--indra/llui/lltoolbar.h8
-rw-r--r--indra/llui/lltoolbarview.cpp45
-rw-r--r--indra/llui/lltoolbarview.h6
-rw-r--r--indra/newview/app_settings/toolbars.xml6
-rw-r--r--indra/newview/skins/default/xui/en/menu_toolbars.xml6
6 files changed, 79 insertions, 19 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 45567d5859..75c7d91f8a 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -213,6 +213,14 @@ bool LLToolBar::addCommand(const LLCommandId& commandId)
return add_command;
}
+void LLToolBar::clearCommandsList()
+{
+ // Clears the commands list
+ mButtonCommands.clear();
+ // This will clear the buttons
+ createButtons();
+}
+
bool LLToolBar::hasCommand(const LLCommandId& commandId) const
{
bool has_command = false;
@@ -278,7 +286,7 @@ BOOL LLToolBar::isSettingChecked(const LLSD& userdata)
const std::string setting_name = userdata.asString();
- if (setting_name == "icons_and_labels")
+ if (setting_name == "icons_with_text")
{
retval = (mButtonType == BTNTYPE_ICONS_WITH_TEXT);
}
@@ -296,18 +304,23 @@ void LLToolBar::onSettingEnable(const LLSD& userdata)
const std::string setting_name = userdata.asString();
- const ButtonType current_button_type = mButtonType;
-
- if (setting_name == "icons_and_labels")
+ if (setting_name == "icons_with_text")
{
- mButtonType = BTNTYPE_ICONS_WITH_TEXT;
+ setButtonType(BTNTYPE_ICONS_WITH_TEXT);
}
else if (setting_name == "icons_only")
{
- mButtonType = BTNTYPE_ICONS_ONLY;
+ setButtonType(BTNTYPE_ICONS_ONLY);
}
+}
- if(current_button_type != mButtonType)
+void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type)
+{
+ bool regenerate_buttons = (mButtonType != button_type);
+
+ mButtonType = button_type;
+
+ if (regenerate_buttons)
{
createButtons();
}
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 8e484c7e13..03b1756988 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -123,7 +123,6 @@ public:
bool addCommand(const LLCommandId& commandId);
bool hasCommand(const LLCommandId& commandId) const;
bool enableCommand(const LLCommandId& commandId, bool enabled);
- command_id_list_t& getCommandsList() { return mButtonCommands; }
protected:
friend class LLUICtrlFactory;
@@ -132,6 +131,13 @@ protected:
void initFromParams(const Params&);
+public:
+ // Methods used in loading and saving toolbar settings
+ void setButtonType(LLToolBarEnums::ButtonType button_type);
+ LLToolBarEnums::ButtonType getButtonType() { return mButtonType; }
+ command_id_list_t& getCommandsList() { return mButtonCommands; }
+ void clearCommandsList();
+
private:
void createContextMenu();
void updateLayoutAsNeeded();
diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp
index f60598edcb..1c6cf3230b 100644
--- a/indra/llui/lltoolbarview.cpp
+++ b/indra/llui/lltoolbarview.cpp
@@ -41,7 +41,8 @@ LLToolBarView* gToolBarView = NULL;
static LLDefaultChildRegistry::Register<LLToolBarView> r("toolbar_view");
LLToolBarView::Toolbar::Toolbar()
-: commands("command")
+: button_display_mode("button_display_mode"),
+ commands("command")
{}
LLToolBarView::ToolbarSet::ToolbarSet()
@@ -112,13 +113,17 @@ bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar)
return true;
}
-bool LLToolBarView::loadToolbars()
+bool LLToolBarView::loadToolbars(bool force_default)
{
LLToolBarView::ToolbarSet toolbar_set;
- // Load the default toolbars.xml file
+ // Load the toolbars.xml file
std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
- if (!gDirUtilp->fileExists(toolbar_file))
+ if (force_default)
+ {
+ toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
+ }
+ else if (!gDirUtilp->fileExists(toolbar_file))
{
llwarns << "User toolbars def not found -> use default" << llendl;
toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
@@ -145,9 +150,28 @@ bool LLToolBarView::loadToolbars()
return false;
}
+ // Clear the toolbars now before adding the loaded commands and settings
+ if (mToolbarLeft)
+ {
+ mToolbarLeft->clearCommandsList();
+ }
+ if (mToolbarRight)
+ {
+ mToolbarRight->clearCommandsList();
+ }
+ if (mToolbarBottom)
+ {
+ mToolbarBottom->clearCommandsList();
+ }
+
// Add commands to each toolbar
if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft)
{
+ if (toolbar_set.left_toolbar.button_display_mode.isProvided())
+ {
+ U32 button_type = toolbar_set.left_toolbar.button_display_mode;
+ mToolbarLeft->setButtonType((LLToolBarEnums::ButtonType)(button_type));
+ }
BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands)
{
addCommand(LLCommandId(command),mToolbarLeft);
@@ -155,6 +179,11 @@ bool LLToolBarView::loadToolbars()
}
if (toolbar_set.right_toolbar.isProvided() && mToolbarRight)
{
+ if (toolbar_set.right_toolbar.button_display_mode.isProvided())
+ {
+ U32 button_type = toolbar_set.right_toolbar.button_display_mode;
+ mToolbarRight->setButtonType((LLToolBarEnums::ButtonType)(button_type));
+ }
BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands)
{
addCommand(LLCommandId(command),mToolbarRight);
@@ -162,6 +191,11 @@ bool LLToolBarView::loadToolbars()
}
if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom)
{
+ if (toolbar_set.bottom_toolbar.button_display_mode.isProvided())
+ {
+ U32 button_type = toolbar_set.bottom_toolbar.button_display_mode;
+ mToolbarBottom->setButtonType((LLToolBarEnums::ButtonType)(button_type));
+ }
BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands)
{
addCommand(LLCommandId(command),mToolbarBottom);
@@ -176,14 +210,17 @@ void LLToolBarView::saveToolbars() const
LLToolBarView::ToolbarSet toolbar_set;
if (mToolbarLeft)
{
+ toolbar_set.left_toolbar.button_display_mode = (int)(mToolbarLeft->getButtonType());
addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar);
}
if (mToolbarRight)
{
+ toolbar_set.right_toolbar.button_display_mode = (int)(mToolbarRight->getButtonType());
addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar);
}
if (mToolbarBottom)
{
+ toolbar_set.bottom_toolbar.button_display_mode = (int)(mToolbarBottom->getButtonType());
addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar);
}
diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h
index b19841997b..efe6920db8 100644
--- a/indra/llui/lltoolbarview.h
+++ b/indra/llui/lltoolbarview.h
@@ -50,7 +50,8 @@ public:
// the user folder for the user specific (saved) settings
struct Toolbar : public LLInitParam::Block<Toolbar>
{
- Multiple<LLCommandId::Params> commands;
+ Mandatory<U32> button_display_mode;
+ Multiple<LLCommandId::Params> commands;
Toolbar();
};
struct ToolbarSet : public LLInitParam::Block<ToolbarSet>
@@ -70,7 +71,8 @@ public:
// Checks if the commandId is being used somewhere in one of the toolbars
bool hasCommand(const LLCommandId& commandId) const;
// Loads the toolbars from the existing user or default settings
- bool loadToolbars(); // return false if load fails
+ bool loadToolbars(bool force_default = false); // return false if load fails
+ bool loadDefaultToolbars() { return loadToolbars(true); }
protected:
friend class LLUICtrlFactory;
diff --git a/indra/newview/app_settings/toolbars.xml b/indra/newview/app_settings/toolbars.xml
index 55327ea919..19dec78c63 100644
--- a/indra/newview/app_settings/toolbars.xml
+++ b/indra/newview/app_settings/toolbars.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<toolbars>
- <bottom_toolbar>
+ <bottom_toolbar
+ button_display_mode="0">
<command name="chat"/>
<command name="speak"/>
<command name="places"/>
@@ -10,7 +11,8 @@
<command name="move"/>
<command name="howto"/>
</bottom_toolbar>
- <left_toolbar>
+ <left_toolbar
+ button_display_mode="1">
<command name="avatar"/>
<command name="inventory"/>
<command name="snapshot"/>
diff --git a/indra/newview/skins/default/xui/en/menu_toolbars.xml b/indra/newview/skins/default/xui/en/menu_toolbars.xml
index de13fec670..59912b5503 100644
--- a/indra/newview/skins/default/xui/en/menu_toolbars.xml
+++ b/indra/newview/skins/default/xui/en/menu_toolbars.xml
@@ -12,11 +12,11 @@
<menu_item_separator layout="topleft" />
<menu_item_check label="Icons and labels"
layout="topleft"
- name="icons_and_labels">
+ name="icons_with_text">
<on_click function="Toolbars.EnableSetting"
- parameter="icons_and_labels" />
+ parameter="icons_with_text" />
<on_check function="Toolbars.CheckSetting"
- parameter="icons_and_labels" />
+ parameter="icons_with_text" />
</menu_item_check>
<menu_item_check label="Icons only"
layout="topleft"