From db2e763ff0537785336a330d03bb9307478cb79a Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 4 Oct 2011 14:09:03 -0700 Subject: * Modified commands to add functions for is_enabled, is_running and is_starting, currently not hooked to any functionality. --- indra/llui/llcommandmanager.cpp | 24 ++++++--- indra/llui/llcommandmanager.h | 43 ++++++++++++--- indra/llui/lltoolbar.cpp | 4 +- indra/newview/app_settings/commands.xml | 92 ++++++++++++++++----------------- indra/newview/llfloatertoybox.cpp | 34 +++--------- indra/newview/llfloatertoybox.h | 4 -- 6 files changed, 109 insertions(+), 92 deletions(-) diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index b1147134c2..922f243806 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -48,24 +48,36 @@ const LLCommandId LLCommandId::null("null command"); // LLCommand::Params::Params() - : function("function") - , available_in_toybox("available_in_toybox", false) + : available_in_toybox("available_in_toybox", false) , icon("icon") , label_ref("label_ref") , name("name") - , parameter("parameter") , tooltip_ref("tooltip_ref") + , execute_function("execute_function") + , execute_parameters("execute_parameters") + , is_enabled_function("is_enabled_function") + , is_enabled_parameters("is_enabled_parameters") + , is_running_function("is_running_function") + , is_running_parameters("is_running_parameters") + , is_starting_function("is_starting_function") + , is_starting_parameters("is_starting_parameters") { } LLCommand::LLCommand(const LLCommand::Params& p) - : mFunction(p.function) - , mAvailableInToybox(p.available_in_toybox) + : mAvailableInToybox(p.available_in_toybox) , mIcon(p.icon) , mIdentifier(p.name) , mLabelRef(p.label_ref) - , mParameter(p.parameter) , mTooltipRef(p.tooltip_ref) + , mExecuteFunction(p.execute_function) + , mExecuteParameters(p.execute_parameters) + , mIsEnabledFunction(p.is_enabled_function) + , mIsEnabledParameters(p.is_enabled_parameters) + , mIsRunningFunction(p.is_running_function) + , mIsRunningParameters(p.is_running_parameters) + , mIsStartingFunction(p.is_starting_function) + , mIsStartingParameters(p.is_starting_parameters) { } diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h index 6481a05689..3ac5548a0d 100644 --- a/indra/llui/llcommandmanager.h +++ b/indra/llui/llcommandmanager.h @@ -83,41 +83,72 @@ private: typedef std::list command_id_list_t; + class LLCommand { public: struct Params : public LLInitParam::Block { Mandatory available_in_toybox; - Mandatory function; Mandatory icon; Mandatory label_ref; Mandatory name; - Optional parameter; Mandatory tooltip_ref; + Mandatory execute_function; + Optional execute_parameters; + + Optional is_enabled_function; + Optional is_enabled_parameters; + + Optional is_running_function; + Optional is_running_parameters; + + Optional is_starting_function; + Optional is_starting_parameters; + Params(); }; 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 LLSD& parameter() const { return mParameter; } const std::string& tooltipRef() const { return mTooltipRef; } + const std::string& executeFunctionName() const { return mExecuteFunction; } + const LLSD& executeParameters() const { return mExecuteParameters; } + + const std::string& isEnabledFunctionName() const { return mIsEnabledFunction; } + const LLSD& isEnabledParameters() const { return mIsEnabledParameters; } + + const std::string& isRunningFunctionName() const { return mIsRunningFunction; } + const LLSD& isRunningParameters() const { return mIsRunningParameters; } + + const std::string& isStartingFunctionName() const { return mIsStartingFunction; } + const LLSD& isStartingParameters() const { return mIsStartingParameters; } + private: LLCommandId mIdentifier; bool mAvailableInToybox; - std::string mFunction; std::string mIcon; std::string mLabelRef; - LLSD mParameter; std::string mTooltipRef; + + std::string mExecuteFunction; + LLSD mExecuteParameters; + + std::string mIsEnabledFunction; + LLSD mIsEnabledParameters; + + std::string mIsRunningFunction; + LLSD mIsRunningParameters; + + std::string mIsStartingFunction; + LLSD mIsStartingParameters; }; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index efa077ffa1..a544aa9ec7 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -525,8 +525,8 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) if (!mReadOnly) { LLUICtrl::CommitCallbackParam cbParam; - cbParam.function_name = commandp->functionName(); - cbParam.parameter = commandp->parameter(); + cbParam.function_name = commandp->executeFunctionName(); + cbParam.parameter = commandp->executeParameters(); button->setCommitCallback(cbParam); button->setStartDragCallback(mStartDragItemCallback); button->setHandleDragCallback(mHandleDragItemCallback); diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index 77bf7cace3..3a91ef490d 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -5,183 +5,183 @@ icon="Command_AboutLand_Icon" label_ref="Command_AboutLand_Label" tooltip_ref="Command_AboutLand_Tooltip" - function="Floater.ToolbarToggle" - parameter="about_land" + execute_function="Floater.ToolbarToggle" + execute_parameters="about_land" /> diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp index 7a6afb4e33..cf22e071aa 100644 --- a/indra/newview/llfloatertoybox.cpp +++ b/indra/newview/llfloatertoybox.cpp @@ -61,8 +61,6 @@ BOOL LLFloaterToybox::postBuild() center(); mBtnRestoreDefaults = getChild("btn_restore_defaults"); - mBtnRestoreDefaults->setCommitCallback(boost::bind(&LLToolBarView::loadDefaultToolbars)); - mToolBar = getChild("toybox_toolbar"); LLCommandManager& cmdMgr = LLCommandManager::instance(); @@ -97,46 +95,26 @@ BOOL LLFloaterToybox::postBuild() return TRUE; } -void LLFloaterToybox::onOpen(const LLSD& key) -{ - -} - -BOOL LLFloaterToybox::canClose() -{ - return TRUE; -} - -void LLFloaterToybox::onClose(bool app_quitting) -{ - -} - void LLFloaterToybox::draw() { llassert(gToolBarView != NULL); - LLCommandManager& cmdMgr = LLCommandManager::instance(); + const command_id_list_t& command_list = mToolBar->getCommandsList(); - for (U32 i = 0; i < cmdMgr.commandCount(); i++) + for (command_id_list_t::const_iterator it = command_list.begin(); it != command_list.end(); ++it) { - LLCommand * command = cmdMgr.getCommand(i); + const LLCommandId& id = *it; - if (command->availableInToybox()) - { - mToolBar->enableCommand(command->id(), !gToolBarView->hasCommand(command->id())); - } + const bool commandOnToolbar = gToolBarView->hasCommand(id); + mToolBar->enableCommand(id, !commandOnToolbar); } LLFloater::draw(); } -void LLFloaterToybox::onFocusReceived() -{ -} - void LLFloaterToybox::onBtnRestoreDefaults() { + LLToolBarView::loadDefaultToolbars(); } diff --git a/indra/newview/llfloatertoybox.h b/indra/newview/llfloatertoybox.h index 3574e060bf..f7245506c5 100644 --- a/indra/newview/llfloatertoybox.h +++ b/indra/newview/llfloatertoybox.h @@ -42,11 +42,7 @@ public: // virtuals BOOL postBuild(); - void onOpen(const LLSD& key); - BOOL canClose(); - void onClose(bool app_quitting); void draw(); - void onFocusReceived(); protected: void onBtnRestoreDefaults(); -- cgit v1.2.3