diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/llcommandmanager.cpp | 24 | ||||
-rw-r--r-- | indra/llui/llcommandmanager.h | 50 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 71 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 11 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.cpp | 8 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.h | 3 | ||||
-rw-r--r-- | indra/newview/app_settings/commands.xml | 23 | ||||
-rw-r--r-- | indra/newview/llfloatertoybox.cpp | 9 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_toybox.xml | 21 |
9 files changed, 167 insertions, 53 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 6be616b980..62e1d186f5 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -38,11 +38,18 @@ // +// LLCommandId class +// + +const LLCommandId LLCommandId::null("null command"); + +// // LLCommand class // LLCommand::Params::Params() : function("function") + , available_in_toybox("available_in_toybox", false) , icon("icon") , label_ref("label_ref") , name("name") @@ -53,9 +60,10 @@ LLCommand::Params::Params() LLCommand::LLCommand(const LLCommand::Params& p) : mFunction(p.function) + , mAvailableInToybox(p.available_in_toybox) , mIcon(p.icon) + , mIdentifier(p.name) , mLabelRef(p.label_ref) - , mName(p.name) , mParam(p.param) , mTooltipRef(p.tooltip_ref) { @@ -90,26 +98,26 @@ LLCommand * LLCommandManager::getCommand(U32 commandIndex) return mCommands[commandIndex]; } -LLCommand * LLCommandManager::getCommand(const std::string& commandName) +LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId) { - LLCommand * command_name_match = NULL; + LLCommand * command_match = NULL; - CommandIndexMap::const_iterator found = mCommandIndices.find(commandName); + CommandIndexMap::const_iterator found = mCommandIndices.find(commandId); if (found != mCommandIndices.end()) { - command_name_match = mCommands[found->second]; + command_match = mCommands[found->second]; } - return command_name_match; + return command_match; } void LLCommandManager::addCommand(LLCommand * command) { - mCommandIndices[command->name()] = mCommands.size(); + mCommandIndices[command->id()] = mCommands.size(); mCommands.push_back(command); - llinfos << "Successfully added command: " << command->name() << llendl; + llinfos << "Successfully added command: " << command->id().name() << llendl; } //static diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 24378ecd62..5b53b65500 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -31,11 +31,50 @@ #include "llsingleton.h" +class LLCommand; +class LLCommandManager; + + +class LLCommandId +{ +public: + friend LLCommand; + friend LLCommandManager; + + LLCommandId(const std::string& name) + : mName(name) + { + } + + const std::string& name() const { return mName; } + + bool operator!=(const LLCommandId& command) const + { + return (mName != command.mName); + } + + bool operator==(const LLCommandId& command) const + { + return (mName == command.mName); + } + + bool operator<(const LLCommandId& command) const + { + return (mName < command.mName); + } + + static const LLCommandId null; + +private: + std::string mName; +}; + class LLCommand { public: struct Params : public LLInitParam::Block<Params> { + Mandatory<bool> available_in_toybox; Mandatory<std::string> function; Mandatory<std::string> icon; Mandatory<std::string> label_ref; @@ -48,18 +87,21 @@ public: LLCommand(const LLCommand::Params& p); + const bool availableInToybox() const { return mAvailableInToybox; } const std::string& functionName() const { return mFunction; } const std::string& icon() const { return mIcon; } + const LLCommandId& id() const { return mIdentifier; } 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: + LLCommandId mIdentifier; + + bool mAvailableInToybox; std::string mFunction; std::string mIcon; std::string mLabelRef; - std::string mName; std::string mParam; std::string mTooltipRef; }; @@ -84,7 +126,7 @@ public: U32 commandCount() const; LLCommand * getCommand(U32 commandIndex); - LLCommand * getCommand(const std::string& commandName); + LLCommand * getCommand(const LLCommandId& commandId); static bool load(); @@ -92,7 +134,7 @@ protected: void addCommand(LLCommand * command); private: - typedef std::map<std::string, U32> CommandIndexMap; + typedef std::map<LLCommandId, U32> CommandIndexMap; typedef std::vector<LLCommand *> CommandVector; CommandVector mCommands; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 5802d2adda..1e1cb16fbb 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -30,7 +30,6 @@ #include <boost/foreach.hpp> #include "lltoolbar.h" -#include "llcommandmanager.h" #include "llmenugl.h" #include "lltrans.h" @@ -212,48 +211,79 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) LLToolBarButton* buttonp = LLUICtrlFactory::create<LLToolBarButton>(button_p); mButtons.push_back(buttonp); + mButtonCommands.push_back(LLCommandId::null); mButtonPanel->addChild(buttonp); mNeedsLayout = true; } } -bool LLToolBar::addCommand(LLCommand * command) +bool LLToolBar::addCommand(const LLCommandId& commandId) { + LLCommand * command = LLCommandManager::instance().getCommand(commandId); + + bool add_command = (command != NULL); + // // Init basic toolbar button params // - LLToolBarButton::Params button_p(mButtonParams[mButtonType]); - button_p.name = command->name(); - button_p.label = LLTrans::getString(command->labelRef()); - button_p.tool_tip = LLTrans::getString(command->tooltipRef()); + if (add_command) + { + LLToolBarButton::Params button_p(mButtonParams[mButtonType]); + button_p.name = commandId.name(); + button_p.label = LLTrans::getString(command->labelRef()); + button_p.tool_tip = LLTrans::getString(command->tooltipRef()); - // - // Add it to the list of buttons - // - LLToolBarButton * toolbar_button = LLUICtrlFactory::create<LLToolBarButton>(button_p); - mButtons.push_back(toolbar_button); - mButtonPanel->addChild(toolbar_button); + // + // Add it to the list of buttons + // + LLToolBarButton * toolbar_button = LLUICtrlFactory::create<LLToolBarButton>(button_p); + mButtons.push_back(toolbar_button); + mButtonCommands.push_back(commandId); + mButtonPanel->addChild(toolbar_button); - mNeedsLayout = true; + mNeedsLayout = true; + } - return true; + return add_command; } -bool LLToolBar::hasCommand(const std::string& command_name) +bool LLToolBar::hasCommand(const LLCommandId& commandId) const { bool has_command = false; - for (std::list<LLToolBarButton*>::iterator cmd = mButtons.begin(); cmd != mButtons.end(); cmd++) + + if (commandId != LLCommandId::null) { - if ((*cmd)->getName() == command_name) + for (std::list<LLCommandId>::const_iterator cmd = mButtonCommands.begin(); cmd != mButtonCommands.end(); ++cmd) { - has_command = true; - break; + if ((*cmd) == commandId) + { + has_command = true; + break; + } } } + return has_command; } +bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) +{ + LLButton * command_button = NULL; + + if (commandId != LLCommandId::null) + { + command_button = mButtonPanel->findChild<LLButton>(commandId.name()); + + if (command_button) + { + command_button->setEnabled(enabled); + } + } + + return (command_button != NULL); +} + BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask) { BOOL handle_it_here = !mReadOnly; @@ -351,7 +381,6 @@ void LLToolBar::updateLayoutAsNeeded() max_length = getRect().getWidth() - mPadLeft - mPadRight; max_total_girth = getRect().getHeight() - mPadTop - mPadBottom; row_pad_start = mPadLeft; - row_running_length = row_pad_start; row_pad_end = mPadRight; cur_row = mPadTop; girth_pad_end = mPadBottom; @@ -361,12 +390,12 @@ void LLToolBar::updateLayoutAsNeeded() max_length = getRect().getHeight() - mPadTop - mPadBottom; max_total_girth = getRect().getWidth() - mPadLeft - mPadRight; row_pad_start = mPadTop; - row_running_length = row_pad_start; row_pad_end = mPadBottom; cur_row = mPadLeft; girth_pad_end = mPadRight; } + row_running_length = row_pad_start; cur_start = row_pad_start; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 00e6ed131a..f7562b29d2 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -28,9 +28,10 @@ #ifndef LL_LLTOOLBAR_H #define LL_LLTOOLBAR_H -#include "lluictrl.h" -#include "lllayoutstack.h" #include "llbutton.h" +#include "llcommandmanager.h" +#include "lllayoutstack.h" +#include "lluictrl.h" class LLCommand; @@ -121,8 +122,9 @@ public: BOOL postBuild(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - bool addCommand(LLCommand * command); - bool hasCommand(const std::string& command_name); + bool addCommand(const LLCommandId& commandId); + bool hasCommand(const LLCommandId& commandId) const; + bool enableCommand(const LLCommandId& commandId, bool enabled); protected: friend class LLUICtrlFactory; @@ -142,6 +144,7 @@ private: const bool mReadOnly; std::list<LLToolBarButton*> mButtons; + std::list<LLCommandId> mButtonCommands; LLToolBarEnums::ButtonType mButtonType; LLLayoutStack* mCenteringStack; LLLayoutStack* mWrapStack; diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 3b4960fdd5..6c29e566b8 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -62,20 +62,20 @@ BOOL LLToolBarView::postBuild() return TRUE; } -bool LLToolBarView::hasCommand(const std::string& command_name) +bool LLToolBarView::hasCommand(const LLCommandId& commandId) const { bool has_command = false; if (mToolbarLeft && !has_command) { - has_command = mToolbarLeft->hasCommand(command_name); + has_command = mToolbarLeft->hasCommand(commandId); } if (mToolbarRight && !has_command) { - has_command = mToolbarRight->hasCommand(command_name); + has_command = mToolbarRight->hasCommand(commandId); } if (mToolbarBottom && !has_command) { - has_command = mToolbarBottom->hasCommand(command_name); + has_command = mToolbarBottom->hasCommand(commandId); } return has_command; } diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 65d339315b..2e7885f391 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -30,6 +30,7 @@ #include "lluictrl.h" #include "lltoolbar.h" +#include "llcommandmanager.h" class LLUICtrlFactory; @@ -45,7 +46,7 @@ public: virtual void draw(); - bool hasCommand(const std::string& command_name); + bool hasCommand(const LLCommandId& commandId) const; // valid children for LLToolBarView are stored in this registry typedef LLDefaultChildRegistry child_registry_t; diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index dbb0e8b7ca..4a33b24075 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <commands> <command name="avatar" + available_in_toybox="true" icon="Command_Avatar_Icon" label_ref="Command_Avatar_Label" tooltip_ref="Command_Avatar_Tooltip" @@ -8,6 +9,7 @@ param="avatar" /> <command name="build" + available_in_toybox="true" icon="Command_Build_Icon" label_ref="Command_Build_Label" tooltip_ref="Command_Build_Tooltip" @@ -15,22 +17,23 @@ param="build" /> <command name="chat" + available_in_toybox="true" icon="Command_Chat_Icon" label_ref="Command_Chat_Label" tooltip_ref="Command_Chat_Tooltip" function="Floater.ToolbarToggle" param="chat" /> - <!-- Compass it not supported by the viewer yet <command name="compass" + available_in_toybox="false" icon="Command_Compass_Icon" label_ref="Command_Compass_Label" tooltip_ref="Command_Compass_Tooltip" function="Floater.ToolbarToggle" param="compass" /> - --> <command name="gestures" + available_in_toybox="true" icon="Command_Gestures_Icon" label_ref="Command_Gestures_Label" tooltip_ref="Command_Gestures_Tooltip" @@ -38,6 +41,7 @@ param="gestures" /> <command name="howto" + available_in_toybox="true" icon="Command_HowTo_Icon" label_ref="Command_HowTo_Label" tooltip_ref="Command_HowTo_Tooltip" @@ -45,6 +49,7 @@ param="howto" /> <command name="landmarks" + available_in_toybox="true" icon="Command_Landmarks_Icon" label_ref="Command_Landmarks_Label" tooltip_ref="Command_Landmarks_Tooltip" @@ -52,6 +57,7 @@ param="landmarks" /> <command name="map" + available_in_toybox="true" icon="Command_Map_Icon" label_ref="Command_Map_Label" tooltip_ref="Command_Map_Tooltip" @@ -59,6 +65,7 @@ param="map" /> <command name="minimap" + available_in_toybox="true" icon="Command_MiniMap_Icon" label_ref="Command_MiniMap_Label" tooltip_ref="Command_MiniMap_Tooltip" @@ -66,6 +73,7 @@ param="minimap" /> <command name="move" + available_in_toybox="true" icon="Command_Move_Icon" label_ref="Command_Move_Label" tooltip_ref="Command_Move_Tooltip" @@ -73,6 +81,7 @@ param="move" /> <command name="myland" + available_in_toybox="true" icon="Command_MyLand_Icon" label_ref="Command_MyLand_Label" tooltip_ref="Command_MyLand_Tooltip" @@ -80,6 +89,7 @@ param="myland" /> <command name="mystuff" + available_in_toybox="true" icon="Command_MyStuff_Icon" label_ref="Command_MyStuff_Label" tooltip_ref="Command_MyStuff_Tooltip" @@ -87,6 +97,7 @@ param="mystuff" /> <command name="people" + available_in_toybox="true" icon="Command_People_Icon" label_ref="Command_People_Label" tooltip_ref="Command_People_Tooltip" @@ -94,6 +105,7 @@ param="people" /> <command name="places" + available_in_toybox="true" icon="Command_Places_Icon" label_ref="Command_Places_Label" tooltip_ref="Command_Places_Tooltip" @@ -101,6 +113,7 @@ param="places" /> <command name="search" + available_in_toybox="true" icon="Command_Search_Icon" label_ref="Command_Search_Label" tooltip_ref="Command_Search_Tooltip" @@ -108,6 +121,7 @@ param="search" /> <command name="settings" + available_in_toybox="true" icon="Command_Settings_Icon" label_ref="Command_Settings_Label" tooltip_ref="Command_Settings_Tooltip" @@ -115,6 +129,7 @@ param="settings" /> <command name="shop" + available_in_toybox="true" icon="Command_Shop_Icon" label_ref="Command_Shop_Label" tooltip_ref="Command_Shop_Tooltip" @@ -122,6 +137,7 @@ param="shop" /> <command name="snapshot" + available_in_toybox="true" icon="Command_Snapshot_Icon" label_ref="Command_Snapshot_Label" tooltip_ref="Command_Snapshot_Tooltip" @@ -129,6 +145,7 @@ param="snapshot" /> <command name="speak" + available_in_toybox="true" icon="Command_Speak_Icon" label_ref="Command_Speak_Label" tooltip_ref="Command_Speak_Tooltip" @@ -136,6 +153,7 @@ param="speak" /> <command name="upload" + available_in_toybox="true" icon="Command_Upload_Icon" label_ref="Command_Upload_Label" tooltip_ref="Command_Upload_Tooltip" @@ -143,6 +161,7 @@ param="upload" /> <command name="view" + available_in_toybox="true" icon="Command_View_Icon" label_ref="Command_View_Label" tooltip_ref="Command_View_Tooltip" diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp index eaaaeb3357..beb928ea36 100644 --- a/indra/newview/llfloatertoybox.cpp +++ b/indra/newview/llfloatertoybox.cpp @@ -32,6 +32,7 @@ #include "llcommandmanager.h" #include "llpanel.h" #include "lltoolbar.h" +#include "lltoolbarview.h" LLFloaterToybox::LLFloaterToybox(const LLSD& key) @@ -63,7 +64,13 @@ BOOL LLFloaterToybox::postBuild() { LLCommand * command = cmdMgr.getCommand(i); - mToolBar->addCommand(command); + if (command->availableInToybox()) + { + mToolBar->addCommand(command->id()); + + llassert(gToolBarView != NULL); + mToolBar->enableCommand(command->id(), !gToolBarView->hasCommand(command->id())); + } } return TRUE; diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml index 1c9f20c496..60a39b0bff 100644 --- a/indra/newview/skins/default/xui/en/floater_toybox.xml +++ b/indra/newview/skins/default/xui/en/floater_toybox.xml @@ -14,17 +14,17 @@ save_rect="true" single_instance="true" title="Customize toolbars" - width="658"> + width="650"> <text follows="left|top" font="SansSerifMedium" halign="left" height="20" layout="topleft" - left="40" + left="20" length="1" name="toybox label 1" - right="-40" + right="-20" top="35" type="string"> Add or remove buttons by dragging them to or from the toolbars. @@ -35,10 +35,10 @@ halign="left" height="20" layout="topleft" - left="40" + left="20" length="1" name="toybox label 2" - right="-40" + right="-20" top="55" type="string"> Buttons will appear as shown or as icon-only depending on each toolbar's settings. @@ -46,12 +46,17 @@ <toolbar bottom="395" button_display_mode="icons_with_text" - left="40" + left="20" max_button_width="140" min_button_width="70" name="toybox_toolbar" + pad_left="5" + pad_right="5" + pad_top="5" + pad_bottom="5" + pad_between="15" read_only="true" - right="-40" + right="-20" side="top" top="85"> </toolbar> @@ -61,7 +66,7 @@ label="Restore defaults" label_selected="Restore defaults" layout="topleft" - left="40" + left="20" name="btn_restore_defaults" top="415" width="130"> |