Skip to content
Snippets Groups Projects
Commit aec61c57 authored by Leslie Linden's avatar Leslie Linden
Browse files

Added 'execute_stop_function' command parameter to handle mouse down/up actions on toolbar buttons

parent 05b31ff3
No related branches found
No related tags found
No related merge requests found
...@@ -296,6 +296,24 @@ void LLButton::onCommit() ...@@ -296,6 +296,24 @@ void LLButton::onCommit()
LLUICtrl::onCommit(); LLUICtrl::onCommit();
} }
boost::signals2::connection LLButton::setClickedCallback(const CommitCallbackParam& cb)
{
return setClickedCallback(initCommitCallback(cb));
}
boost::signals2::connection LLButton::setMouseDownCallback(const CommitCallbackParam& cb)
{
return setMouseDownCallback(initCommitCallback(cb));
}
boost::signals2::connection LLButton::setMouseUpCallback(const CommitCallbackParam& cb)
{
return setMouseUpCallback(initCommitCallback(cb));
}
boost::signals2::connection LLButton::setHeldDownCallback(const CommitCallbackParam& cb)
{
return setHeldDownCallback(initCommitCallback(cb));
}
boost::signals2::connection LLButton::setClickedCallback( const commit_signal_t::slot_type& cb ) boost::signals2::connection LLButton::setClickedCallback( const commit_signal_t::slot_type& cb )
{ {
if (!mCommitSignal) mCommitSignal = new commit_signal_t(); if (!mCommitSignal) mCommitSignal = new commit_signal_t();
......
...@@ -170,6 +170,11 @@ class LLButton ...@@ -170,6 +170,11 @@ class LLButton
void setUseEllipses( BOOL use_ellipses ) { mUseEllipses = use_ellipses; } void setUseEllipses( BOOL use_ellipses ) { mUseEllipses = use_ellipses; }
boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb);
boost::signals2::connection setMouseDownCallback(const CommitCallbackParam& cb);
boost::signals2::connection setMouseUpCallback(const CommitCallbackParam& cb);
boost::signals2::connection setHeldDownCallback(const CommitCallbackParam& cb);
boost::signals2::connection setClickedCallback( const commit_signal_t::slot_type& cb ); // mouse down and up within button boost::signals2::connection setClickedCallback( const commit_signal_t::slot_type& cb ); // mouse down and up within button
boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); // mouse up, EVEN IF NOT IN BUTTON boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); // mouse up, EVEN IF NOT IN BUTTON
......
...@@ -55,6 +55,8 @@ LLCommand::Params::Params() ...@@ -55,6 +55,8 @@ LLCommand::Params::Params()
, tooltip_ref("tooltip_ref") , tooltip_ref("tooltip_ref")
, execute_function("execute_function") , execute_function("execute_function")
, execute_parameters("execute_parameters") , execute_parameters("execute_parameters")
, execute_stop_function("execute_stop_function")
, execute_stop_parameters("execute_stop_parameters")
, is_enabled_function("is_enabled_function") , is_enabled_function("is_enabled_function")
, is_enabled_parameters("is_enabled_parameters") , is_enabled_parameters("is_enabled_parameters")
, is_running_function("is_running_function") , is_running_function("is_running_function")
...@@ -72,6 +74,8 @@ LLCommand::LLCommand(const LLCommand::Params& p) ...@@ -72,6 +74,8 @@ LLCommand::LLCommand(const LLCommand::Params& p)
, mTooltipRef(p.tooltip_ref) , mTooltipRef(p.tooltip_ref)
, mExecuteFunction(p.execute_function) , mExecuteFunction(p.execute_function)
, mExecuteParameters(p.execute_parameters) , mExecuteParameters(p.execute_parameters)
, mExecuteStopFunction(p.execute_stop_function)
, mExecuteStopParameters(p.execute_stop_parameters)
, mIsEnabledFunction(p.is_enabled_function) , mIsEnabledFunction(p.is_enabled_function)
, mIsEnabledParameters(p.is_enabled_parameters) , mIsEnabledParameters(p.is_enabled_parameters)
, mIsRunningFunction(p.is_running_function) , mIsRunningFunction(p.is_running_function)
......
...@@ -116,6 +116,9 @@ class LLCommand ...@@ -116,6 +116,9 @@ class LLCommand
Mandatory<std::string> execute_function; Mandatory<std::string> execute_function;
Optional<LLSD> execute_parameters; Optional<LLSD> execute_parameters;
Optional<std::string> execute_stop_function;
Optional<LLSD> execute_stop_parameters;
Optional<std::string> is_enabled_function; Optional<std::string> is_enabled_function;
Optional<LLSD> is_enabled_parameters; Optional<LLSD> is_enabled_parameters;
...@@ -139,6 +142,9 @@ class LLCommand ...@@ -139,6 +142,9 @@ class LLCommand
const std::string& executeFunctionName() const { return mExecuteFunction; } const std::string& executeFunctionName() const { return mExecuteFunction; }
const LLSD& executeParameters() const { return mExecuteParameters; } const LLSD& executeParameters() const { return mExecuteParameters; }
const std::string& executeStopFunctionName() const { return mExecuteStopFunction; }
const LLSD& executeStopParameters() const { return mExecuteStopParameters; }
const std::string& isEnabledFunctionName() const { return mIsEnabledFunction; } const std::string& isEnabledFunctionName() const { return mIsEnabledFunction; }
const LLSD& isEnabledParameters() const { return mIsEnabledParameters; } const LLSD& isEnabledParameters() const { return mIsEnabledParameters; }
...@@ -159,6 +165,9 @@ class LLCommand ...@@ -159,6 +165,9 @@ class LLCommand
std::string mExecuteFunction; std::string mExecuteFunction;
LLSD mExecuteParameters; LLSD mExecuteParameters;
std::string mExecuteStopFunction;
LLSD mExecuteStopParameters;
std::string mIsEnabledFunction; std::string mIsEnabledFunction;
LLSD mIsEnabledParameters; LLSD mIsEnabledParameters;
......
...@@ -659,11 +659,25 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) ...@@ -659,11 +659,25 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id)
if (!mReadOnly) if (!mReadOnly)
{ {
LLUICtrl::CommitCallbackParam cbParam; LLUICtrl::CommitCallbackParam executeParam;
cbParam.function_name = commandp->executeFunctionName(); executeParam.function_name = commandp->executeFunctionName();
cbParam.parameter = commandp->executeParameters(); executeParam.parameter = commandp->executeParameters();
button->setCommitCallback(cbParam); // If we have a "stop" function then we map the command to mouse down / mouse up otherwise commit
const std::string& executeStopFunction = commandp->executeStopFunctionName();
if (executeStopFunction.length() > 0)
{
LLUICtrl::CommitCallbackParam executeStopParam;
executeStopParam.function_name = executeStopFunction;
executeStopParam.parameter = commandp->executeStopParameters();
button->setMouseDownCallback(executeParam);
button->setMouseUpCallback(executeStopParam);
}
else
{
button->setCommitCallback(executeParam);
}
const std::string& isEnabledFunction = commandp->isEnabledFunctionName(); const std::string& isEnabledFunction = commandp->isEnabledFunctionName();
if (isEnabledFunction.length() > 0) if (isEnabledFunction.length() > 0)
......
...@@ -217,6 +217,8 @@ ...@@ -217,6 +217,8 @@
tooltip_ref="Command_Speak_Tooltip" tooltip_ref="Command_Speak_Tooltip"
execute_function="Agent.ToggleMicrophone" execute_function="Agent.ToggleMicrophone"
execute_parameters="speak" execute_parameters="speak"
execute_stop_function=""
execute_stop_parameters="speak"
is_enabled_function="Agent.IsActionAllowed" is_enabled_function="Agent.IsActionAllowed"
is_enabled_parameters="speak" is_enabled_parameters="speak"
is_running_function="Agent.IsMicrophoneOn" is_running_function="Agent.IsMicrophoneOn"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment