diff options
author | Leslie Linden <leslie@lindenlab.com> | 2011-09-26 17:38:10 -0700 |
---|---|---|
committer | Leslie Linden <leslie@lindenlab.com> | 2011-09-26 17:38:10 -0700 |
commit | 53a486649381af53d21de28aced388bc2aacac0f (patch) | |
tree | 9b7378da2c05e9dbd0c7a594b12d242e87ddf0dd /indra/llui/lltoolbar.cpp | |
parent | bb1776de6865715b2dd96185140d35e46d63c837 (diff) |
EXP-1205 PROGRESS -- As a User, I want a toybox which will contain all buttons that I can d&d into the toolbars
* Command buttons are now enabled/disabled in toybox based on whether or not the
LLToolBarView has them anywhere.
* Commands now have argument to specify whether or not they should be in the
toybox.
* LLCommandId is now used a universal reference for commands.
Reviewed by Richard.
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 71 |
1 files changed, 50 insertions, 21 deletions
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; |