summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llfloater.h2
-rw-r--r--indra/llui/llfloaterreg.cpp36
-rw-r--r--indra/llui/lltoolbar.cpp29
-rw-r--r--indra/llui/lltoolbar.h8
-rw-r--r--indra/llui/lltoolbarview.cpp91
-rw-r--r--indra/llui/lltoolbarview.h5
6 files changed, 125 insertions, 46 deletions
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 58c2d34253..fba59e82e1 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -293,7 +293,7 @@ public:
protected:
virtual void applySavedVariables();
- void applyRectControl();
+ virtual void applyRectControl();
void applyDockState();
void storeRectControl();
void storeVisibilityControl();
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index bc740dde17..27e96856b3 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->getIsChrome())
+ {
+ instance->setFocus(TRUE);
+ }
+ else
+ {
+ instance->closeFloater();
+ }
}
//static
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index d940bed905..2592fd1229 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -185,7 +185,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
LLPanel::Params button_panel_p(p.button_panel);
button_panel_p.rect = center_panel->getLocalRect();
- button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT;
+ button_panel_p.follows.flags = FOLLOWS_BOTTOM|FOLLOWS_LEFT;
mButtonPanel = LLUICtrlFactory::create<LLPanel>(button_panel_p);
center_panel->addChild(mButtonPanel);
@@ -214,6 +214,14 @@ bool LLToolBar::addCommand(const LLCommandId& commandId)
return true;
}
+void LLToolBar::clearCommandsList()
+{
+ // Clears the commands list
+ mButtonCommands.clear();
+ // This will clear the buttons
+ createButtons();
+}
+
bool LLToolBar::hasCommand(const LLCommandId& commandId) const
{
if (commandId != LLCommandId::null)
@@ -270,7 +278,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);
}
@@ -288,18 +296,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);
}
+}
+
+void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type)
+{
+ bool regenerate_buttons = (mButtonType != button_type);
+
+ mButtonType = button_type;
- if(current_button_type != mButtonType)
+ if (regenerate_buttons)
{
createButtons();
}
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 77bac87dbc..0bb95f4e9c 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -131,7 +131,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; }
LLToolBarButton* createButton(const LLCommandId& id);
@@ -142,6 +141,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 bb4ea815c9..0996577114 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,21 @@ 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
- // *TODO : pick up the user's toolbar setting if existing
- std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
+ // Load the toolbars.xml file
+ std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
+ 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");
+ }
LLXMLNodePtr root;
if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
@@ -141,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);
@@ -151,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);
@@ -158,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);
@@ -166,6 +204,19 @@ bool LLToolBarView::loadToolbars()
return true;
}
+//static
+bool LLToolBarView::loadDefaultToolbars()
+{
+ bool retval = false;
+
+ if (gToolBarView)
+ {
+ retval = gToolBarView->loadToolbars(true);
+ }
+
+ return retval;
+}
+
void LLToolBarView::saveToolbars() const
{
// Build the parameter tree from the toolbar data
@@ -174,39 +225,15 @@ void LLToolBarView::saveToolbars() const
// *TODO : factorize that code a bit...
if (mToolbarLeft)
{
- command_id_list_t& command_list = mToolbarLeft->getCommandsList();
- for (command_id_list_t::const_iterator it = command_list.begin();
- it != command_list.end();
- ++it)
- {
- LLCommandId::Params command;
- command.name = it->name();
- toolbar_set.left_toolbar.commands.add(command);
- }
+ addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar);
}
if (mToolbarRight)
{
- command_id_list_t& command_list = mToolbarRight->getCommandsList();
- for (command_id_list_t::const_iterator it = command_list.begin();
- it != command_list.end();
- ++it)
- {
- LLCommandId::Params command;
- command.name = it->name();
- toolbar_set.right_toolbar.commands.add(command);
- }
+ addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar);
}
if (mToolbarBottom)
{
- command_id_list_t& command_list = mToolbarBottom->getCommandsList();
- for (command_id_list_t::const_iterator it = command_list.begin();
- it != command_list.end();
- ++it)
- {
- LLCommandId::Params command;
- command.name = it->name();
- toolbar_set.bottom_toolbar.commands.add(command);
- }
+ addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar);
}
// Serialize the parameter tree
diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h
index dd2bbf0e49..20525a22ac 100644
--- a/indra/llui/lltoolbarview.h
+++ b/indra/llui/lltoolbarview.h
@@ -50,6 +50,7 @@ public:
// the user folder for the user specific (saved) settings
struct Toolbar : public LLInitParam::Block<Toolbar>
{
+ Mandatory<U32> button_display_mode;
Multiple<LLCommandId::Params> commands;
Toolbar();
};
@@ -69,7 +70,9 @@ 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
+
+ static bool loadDefaultToolbars();
protected:
friend class LLUICtrlFactory;