diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 36 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 27 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 8 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.cpp | 45 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.h | 6 |
5 files changed, 105 insertions, 17 deletions
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index bc740dde17..8a0513f246 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -455,12 +455,42 @@ 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 :) - + // + // Floaters controlled by the toolbar behave a bit differently from others. + // Namely they have 3-4 states as defined in the design wiki page here: + // https://wiki.lindenlab.com/wiki/FUI_Button_states + // + // The basic idea is this: + // * If the target floater is minimized, this button press will un-minimize it. + // * Else if the target floater is closed open it. + // * Else if the target floater does not have focus, give it focus. + // * Also, if it is not on top, bring it forward when focus is given. + // * Else the target floater is open, close it. + // + + // First parse the parameter LLSD key; std::string name = sdname.asString(); parse_name_key(name, key); - toggleInstance(name, key); + + LLFloater* instance = findInstance(name, key); + + if (LLFloater::isMinimized(instance)) + { + instance->setMinimized(FALSE); + } + else if (!LLFloater::isShown(instance)) + { + showInstance(name, key, TRUE); + } + else if (!instance->hasFocus()) + { + instance->setFocus(TRUE); + } + else + { + instance->closeFloater(); + } } //static 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; |