diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 23 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.cpp | 99 | ||||
-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/floater_toybox.xml | 16 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_toolbar_view.xml | 9 |
7 files changed, 177 insertions, 26 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 2fb9f249d4..8249df3e9d 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -123,12 +123,16 @@ void LLToolBar::createContextMenu() { if (!mPopupMenuHandle.get()) { + // Setup bindings specific to this instance for the context menu options + LLUICtrl::CommitCallbackRegistry::Registrar& commit_reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2)); LLUICtrl::EnableCallbackRegistry::Registrar& enable_reg = LLUICtrl::EnableCallbackRegistry::defaultRegistrar(); enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2)); + // Create the context menu + LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu>("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (menu) @@ -141,6 +145,10 @@ void LLToolBar::createContextMenu() { llwarns << "Unable to load toolbars context menu." << llendl; } + + // Remove this instance's bindings + commit_reg.remove("Toolbars.EnableSetting"); + enable_reg.remove("Toolbars.CheckSetting"); } } @@ -187,12 +195,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 +204,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; } @@ -251,11 +256,13 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) if (handle_it_here) { createContextMenu(); + LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get(); if (menu) { menu->show(x, y); + LLMenuGL::showPopup(this, menu, x, y); } } diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 9df6f4946f..7047cca948 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; } 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/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml index 60a39b0bff..092eddaa53 100644 --- a/indra/newview/skins/default/xui/en/floater_toybox.xml +++ b/indra/newview/skins/default/xui/en/floater_toybox.xml @@ -46,6 +46,7 @@ <toolbar bottom="395" button_display_mode="icons_with_text" + follows="all" left="20" max_button_width="140" min_button_width="70" @@ -58,15 +59,22 @@ read_only="true" right="-20" side="top" - top="85"> - </toolbar> + top="85" /> + <panel + bevel_style="none" + border="true" + bottom="396" + follows="left|bottom|right" + left="20" + right="-20" + top="396" /> <button - follows="left|bottom" + follows="left|bottom|right" height="23" label="Restore defaults" label_selected="Restore defaults" layout="topleft" - left="20" + left="260" name="btn_restore_defaults" top="415" width="130"> 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> |