diff options
-rw-r--r-- | indra/llui/lltoolbar.cpp | 13 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.cpp | 101 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.h | 32 | ||||
-rw-r--r-- | indra/newview/CMakeLists.txt | 1 | ||||
-rw-r--r-- | indra/newview/app_settings/toolbars.xml | 23 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_toolbar_view.xml | 9 |
6 files changed, 156 insertions, 23 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 2fb9f249d4..f8effb5bb6 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -187,12 +187,6 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) mCenteringStack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p)); - BOOST_FOREACH (const LLCommandId::Params& command_id, p.commands) - { - mButtonCommands.push_back(command_id); - } - createButtons(); - mNeedsLayout = true; } @@ -202,8 +196,11 @@ bool LLToolBar::addCommand(const LLCommandId& commandId) bool add_command = (command != NULL); - mButtonCommands.push_back(commandId); - createButtons(); + if (add_command) + { + mButtonCommands.push_back(commandId); + createButtons(); + } return add_command; } diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 6ae10fbf1d..139a26a251 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -29,13 +29,108 @@ #include "lltoolbarview.h" +#include "lldir.h" +#include "llxmlnode.h" #include "lltoolbar.h" #include "llbutton.h" +#include <boost/foreach.hpp> + LLToolBarView* gToolBarView = NULL; static LLDefaultChildRegistry::Register<LLToolBarView> r("toolbar_view"); +LLToolBarView::Toolbar::Toolbar() +: commands("command") +{} + +LLToolBarView::ToolbarSet::ToolbarSet() +: left_toolbar("left_toolbar"), + right_toolbar("right_toolbar"), + bottom_toolbar("bottom_toolbar") +{} + +bool LLToolBarView::load() +{ + LLToolBarView::ToolbarSet toolbar_set; + + // Load the default toolbars.xml file + // *TODO : pick up the user's toolbar setting if existing + std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); + + LLXMLNodePtr root; + if(!LLXMLNode::parseFile(toolbar_file, root, NULL)) + { + llerrs << "Unable to load toolbars from file: " << toolbar_file << llendl; + return false; + } + if(!root->hasName("toolbars")) + { + llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl; + return false; + } + + // Parse the toolbar settings + LLXUIParser parser; + parser.readXUI(root, toolbar_set, toolbar_file); + if (!toolbar_set.validateBlock()) + { + llerrs << "Unable to validate toolbars from file: " << toolbar_file << llendl; + return false; + } + + // Add commands to each toolbar + // *TODO: factorize that code : tricky with Blocks though, simple lexical approach fails + LLCommandManager& mgr = LLCommandManager::instance(); + + if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) + { + LLCommandId* commandId = new LLCommandId(command); + if (mgr.getCommand(*commandId)) + { + mToolbarLeft->addCommand(*commandId); + } + else + { + llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; + } + } + } + if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) + { + LLCommandId* commandId = new LLCommandId(command); + if (mgr.getCommand(*commandId)) + { + mToolbarRight->addCommand(*commandId); + } + else + { + llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; + } + } + } + if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) + { + BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) + { + LLCommandId* commandId = new LLCommandId(command); + if (mgr.getCommand(*commandId)) + { + mToolbarBottom->addCommand(*commandId); + } + else + { + llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; + } + } + } + return true; +} + LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) : LLUICtrl(p), mToolbarLeft(NULL), @@ -59,6 +154,10 @@ BOOL LLToolBarView::postBuild() mToolbarLeft = getChild<LLToolBar>("toolbar_left"); mToolbarRight = getChild<LLToolBar>("toolbar_right"); mToolbarBottom = getChild<LLToolBar>("toolbar_bottom"); + + // Load the toolbars from the settings + load(); + return TRUE; } @@ -86,7 +185,7 @@ void LLToolBarView::draw() static S32 old_width = 0; static S32 old_height = 0; - LLPanel* sizer_left = getChild<LLPanel>("sizer_left"); +// LLPanel* sizer_left = getChild<LLPanel>("sizer_left"); LLRect bottom_rect, left_rect, right_rect; diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 2e7885f391..0f16b89ecc 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -39,18 +39,36 @@ class LLUICtrlFactory; class LLToolBarView : public LLUICtrl { public: + // Xui structure of the toolbar panel struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> {}; + + // Note: valid children for LLToolBarView are stored in this registry + typedef LLDefaultChildRegistry child_registry_t; - virtual ~LLToolBarView(); - /*virtual*/ BOOL postBuild(); + // Xml structure of the toolbars.xml setting + // Those live in a toolbars.xml found in app_settings (for the default) and in + // the user folder for the user specific (saved) settings + struct Toolbar : public LLInitParam::Block<Toolbar> + { + Multiple<LLCommandId::Params> commands; + Toolbar(); + }; + struct ToolbarSet : public LLInitParam::Block<ToolbarSet> + { + Optional<Toolbar> left_toolbar, + right_toolbar, + bottom_toolbar; + ToolbarSet(); + }; + // Derived methods + virtual ~LLToolBarView(); + virtual BOOL postBuild(); virtual void draw(); + // Toolbar view interface with the rest of the world bool hasCommand(const LLCommandId& commandId) const; - // valid children for LLToolBarView are stored in this registry - typedef LLDefaultChildRegistry child_registry_t; - protected: friend class LLUICtrlFactory; LLToolBarView(const Params&); @@ -58,6 +76,10 @@ protected: void initFromParams(const Params&); private: + // Loads the toolbars from the existing user or default settings + bool load(); // return false if load fails + + // Pointers to the toolbars handled by the toolbar view LLToolBar* mToolbarLeft; LLToolBar* mToolbarRight; LLToolBar* mToolbarBottom; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 597a1dd603..38d6ff0f58 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1423,6 +1423,7 @@ set(viewer_APPSETTINGS_FILES app_settings/settings_files.xml app_settings/settings_per_account.xml app_settings/std_bump.ini + app_settings/toolbars.xml app_settings/trees.xml app_settings/ultra_graphics.xml app_settings/viewerart.xml diff --git a/indra/newview/app_settings/toolbars.xml b/indra/newview/app_settings/toolbars.xml new file mode 100644 index 0000000000..55327ea919 --- /dev/null +++ b/indra/newview/app_settings/toolbars.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<toolbars> + <bottom_toolbar> + <command name="chat"/> + <command name="speak"/> + <command name="places"/> + <command name="people"/> + <command name="profile"/> + <command name="view"/> + <command name="move"/> + <command name="howto"/> + </bottom_toolbar> + <left_toolbar> + <command name="avatar"/> + <command name="inventory"/> + <command name="snapshot"/> + <command name="search"/> + <command name="shop"/> + <command name="move_objects"/> + <command name="minimap"/> + <command name="preferences"/> + </left_toolbar> +</toolbars>
\ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml index 23ea516b86..fa7632920b 100644 --- a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml @@ -47,9 +47,6 @@ top="0" side="left" button_display_mode="icons_only"> - <command name="avatar"/> - <command name="build"/> - <command name="chat"/> </toolbar> </layout_panel> <layout_panel name="non_toolbar_panel" @@ -72,9 +69,6 @@ top="0" side="right" button_display_mode="icons_only"> - <command name="avatar"/> - <command name="build"/> - <command name="chat"/> </toolbar> </layout_panel> </layout_stack> @@ -96,9 +90,6 @@ follows="left|right|bottom" button_display_mode="icons_with_text" visible="true"> - <command name="avatar"/> - <command name="build"/> - <command name="chat"/> </toolbar> </layout_panel> </layout_stack> |