diff options
author | Leslie Linden <leslie@lindenlab.com> | 2011-09-21 17:25:38 -0700 |
---|---|---|
committer | Leslie Linden <leslie@lindenlab.com> | 2011-09-21 17:25:38 -0700 |
commit | 412e29ed9d62e975a5290c6008558a739b88065d (patch) | |
tree | 4fa73ecfb7c661270a6562c7831d703511d17731 /indra/llui | |
parent | 3dfc05c2e84923bc0aef5256d227f566aaa37868 (diff) |
EXP-1205 PROGRESS -- As a User, I want a toybox which will contain all buttons that I can d&d into the toolbars
EXP-1232 FIX -- Create class to load and hold all of the command meta data associated with FUI toolbar actions
* Added basic commands.xml file to define FUI-related toolbar actions. For now
a basic "avatar" and "places" button are defined.
* Added basic command manager to parse and hold strings that define potential
toolbar command actions.
* Broke out a separate floater function as a placeholder for the 3-state toolbar
floater toggling.
* LLUI::initClass now parses the new commands.xml file
Reviewed by Richard.
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llui/llcommandmanager.cpp | 138 | ||||
-rw-r--r-- | indra/llui/llcommandmanager.h | 97 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 11 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.h | 1 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 5 |
6 files changed, 254 insertions, 0 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index cf3f9b1a7b..0687cf55d8 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -35,6 +35,7 @@ set(llui_SOURCE_FILES llcheckboxctrl.cpp llclipboard.cpp llcombobox.cpp + llcommandmanager.cpp llconsole.cpp llcontainerview.cpp llctrlselectioninterface.cpp @@ -132,6 +133,7 @@ set(llui_HEADER_FILES llcheckboxctrl.h llclipboard.h llcombobox.h + llcommandmanager.h llconsole.h llcontainerview.h llctrlselectioninterface.h diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp new file mode 100644 index 0000000000..306b357d6a --- /dev/null +++ b/indra/llui/llcommandmanager.cpp @@ -0,0 +1,138 @@ +/** + * @file llcommandmanager.cpp + * @brief LLCommandManager class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// A control that displays the name of the chosen item, which when +// clicked shows a scrolling box of options. + +#include "linden_common.h" + +#include "llcommandmanager.h" +#include "lldir.h" +#include "llerror.h" +#include "llxuiparser.h" + +#include <boost/foreach.hpp> + + +// +// LLCommand class +// + +LLCommand::Params::Params() + : function("function") + , icon("icon") + , label_ref("label_ref") + , name("name") + , param("param") + , tooltip_ref("tooltip_ref") +{ +} + +LLCommand::LLCommand(const LLCommand::Params& p) + : mFunction(p.function) + , mIcon(p.icon) + , mLabelRef(p.label_ref) + , mName(p.name) + , mParam(p.param) + , mTooltipRef(p.tooltip_ref) +{ +} + + +// +// LLCommandManager class +// + +LLCommandManager::LLCommandManager() +{ +} + +LLCommandManager::~LLCommandManager() +{ +} + +U32 LLCommandManager::count() const +{ + return mCommands.size(); +} + +LLCommand * LLCommandManager::getCommand(U32 commandIndex) +{ + return mCommands[commandIndex]; +} + +LLCommand * LLCommandManager::getCommand(const std::string& commandName) +{ + LLCommand * command_name_match = NULL; + + for (CommandVector::iterator it = mCommands.begin(); it != mCommands.end(); ++it) + { + LLCommand * command = *it; + + if (command->name() == commandName) + { + command_name_match = command; + break; + } + } + + return command_name_match; +} + +//static +bool LLCommandManager::load() +{ + LLCommandManager& mgr = LLCommandManager::instance(); + + std::string commands_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "commands.xml"); + + LLCommandManager::Params commandsParams; + + LLSimpleXUIParser parser; + + if (!parser.readXUI(commands_file, commandsParams)) + { + llerrs << "Unable to load xml file: " << commands_file << llendl; + return false; + } + + if (!commandsParams.validateBlock()) + { + llerrs << "Unable to validate commands param block from file: " << commands_file << llendl; + return false; + } + + BOOST_FOREACH(LLCommand::Params& commandParams, commandsParams.commands) + { + LLCommand * command = new LLCommand(commandParams); + + mgr.mCommands.push_back(command); + + llinfos << "Successfully loaded command: " << command->name() << llendl; + } + + return true; +} diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h new file mode 100644 index 0000000000..4f3c9b2ada --- /dev/null +++ b/indra/llui/llcommandmanager.h @@ -0,0 +1,97 @@ +/** + * @file llcommandmanager.h + * @brief LLCommandManager class to hold commands + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_COMMANDMANAGER_H +#define LL_COMMANDMANAGER_H + +#include "llinitparam.h" +#include "llsingleton.h" + + +class LLCommand +{ +public: + struct Params : public LLInitParam::Block<Params> + { + Mandatory<std::string> function; + Mandatory<std::string> icon; + Mandatory<std::string> label_ref; + Mandatory<std::string> name; + Optional<std::string> param; + Mandatory<std::string> tooltip_ref; + + Params(); + }; + + LLCommand(const LLCommand::Params& p); + + const std::string& functionName() const { return mFunction; } + const std::string& icon() const { return mIcon; } + const std::string& labelRef() const { return mLabelRef; } + const std::string& name() const { return mName; } + const std::string& param() const { return mParam; } + const std::string& tooltipRef() const { return mTooltipRef; } + +private: + std::string mFunction; + std::string mIcon; + std::string mLabelRef; + std::string mName; + std::string mParam; + std::string mTooltipRef; +}; + + +class LLCommandManager +: public LLSingleton<LLCommandManager> +{ +public: + struct Params : public LLInitParam::Block<Params> + { + Multiple< LLCommand::Params, AtLeast<1> > commands; + + Params() + : commands("command") + { + } + }; + + LLCommandManager(); + ~LLCommandManager(); + + U32 count() const; + LLCommand * getCommand(U32 commandIndex); + LLCommand * getCommand(const std::string& commandName); + + static bool load(); + +private: + typedef std::vector<LLCommand *> CommandVector; + CommandVector mCommands; +}; + + +#endif // LL_COMMANDMANAGER_H diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index fc7dcfcc4e..bc740dde17 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -453,6 +453,17 @@ void LLFloaterReg::toggleFloaterInstance(const LLSD& sdname) } //static +void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) +{ + // Do some extra logic here for 3-state toolbar floater toggling madness :) + + LLSD key; + std::string name = sdname.asString(); + parse_name_key(name, key); + toggleInstance(name, key); +} + +//static bool LLFloaterReg::floaterInstanceVisible(const LLSD& sdname) { LLSD key; diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index a2027a77a0..6239d98a7d 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -127,6 +127,7 @@ public: static void showFloaterInstance(const LLSD& sdname); static void hideFloaterInstance(const LLSD& sdname); static void toggleFloaterInstance(const LLSD& sdname); + static void toggleToolbarFloaterInstance(const LLSD& sdname); static bool floaterInstanceVisible(const LLSD& sdname); static bool floaterInstanceMinimized(const LLSD& sdname); diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 593354ee9b..1bc575438c 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -41,6 +41,7 @@ #include "llgl.h" // Project includes +#include "llcommandmanager.h" #include "llcontrol.h" #include "llui.h" #include "lluicolortable.h" @@ -1617,6 +1618,7 @@ void LLUI::initClass(const settings_map_t& settings, // Callbacks for associating controls with floater visibilty: reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleFloaterInstance, _2)); + reg.add("Floater.ToolbarToggle", boost::bind(&LLFloaterReg::toggleToolbarFloaterInstance, _2)); reg.add("Floater.Show", boost::bind(&LLFloaterReg::showFloaterInstance, _2)); reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideFloaterInstance, _2)); reg.add("Floater.InitToVisibilityControl", boost::bind(&LLFloaterReg::initUICtrlToFloaterVisibilityControl, _1, _2)); @@ -1635,6 +1637,9 @@ void LLUI::initClass(const settings_map_t& settings, // Used by menus along with Floater.Toggle to display visibility as a checkmark LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::floaterInstanceVisible, _2)); + + // Parse the master list of commands + LLCommandManager::load(); } void LLUI::cleanupClass() |