summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llbutton.cpp22
-rw-r--r--indra/llui/llbutton.h5
-rw-r--r--indra/llui/llcommandmanager.cpp4
-rw-r--r--indra/llui/llcommandmanager.h9
-rw-r--r--indra/llui/llfloater.cpp76
-rw-r--r--indra/llui/llfloater.h42
-rw-r--r--indra/llui/llfloaterreg.cpp35
-rw-r--r--indra/llui/llsdparam.cpp6
-rw-r--r--indra/llui/llsdparam.h3
-rw-r--r--indra/llui/lltoolbar.cpp109
-rw-r--r--indra/llui/lltoolbar.h13
11 files changed, 249 insertions, 75 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index ba3748a573..0a7584a576 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -296,6 +296,24 @@ void LLButton::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 )
{
if (!mCommitSignal) mCommitSignal = new commit_signal_t();
@@ -810,6 +828,10 @@ void LLButton::draw()
{
overlay_color.mV[VALPHA] = 0.5f;
}
+ else if (!getToggleState())
+ {
+ overlay_color.mV[VALPHA] = 0.75f;
+ }
overlay_color.mV[VALPHA] *= alpha;
switch(mImageOverlayAlignment)
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index a0a7b4e372..ba0345f610 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -170,6 +170,11 @@ public:
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 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
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index d8e035a320..128ba609cb 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -55,6 +55,8 @@ LLCommand::Params::Params()
, tooltip_ref("tooltip_ref")
, execute_function("execute_function")
, execute_parameters("execute_parameters")
+ , execute_stop_function("execute_stop_function")
+ , execute_stop_parameters("execute_stop_parameters")
, is_enabled_function("is_enabled_function")
, is_enabled_parameters("is_enabled_parameters")
, is_running_function("is_running_function")
@@ -72,6 +74,8 @@ LLCommand::LLCommand(const LLCommand::Params& p)
, mTooltipRef(p.tooltip_ref)
, mExecuteFunction(p.execute_function)
, mExecuteParameters(p.execute_parameters)
+ , mExecuteStopFunction(p.execute_stop_function)
+ , mExecuteStopParameters(p.execute_stop_parameters)
, mIsEnabledFunction(p.is_enabled_function)
, mIsEnabledParameters(p.is_enabled_parameters)
, mIsRunningFunction(p.is_running_function)
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index 46e0fe6e69..9b93ab735a 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -116,6 +116,9 @@ public:
Mandatory<std::string> execute_function;
Optional<LLSD> execute_parameters;
+ Optional<std::string> execute_stop_function;
+ Optional<LLSD> execute_stop_parameters;
+
Optional<std::string> is_enabled_function;
Optional<LLSD> is_enabled_parameters;
@@ -139,6 +142,9 @@ public:
const std::string& executeFunctionName() const { return mExecuteFunction; }
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 LLSD& isEnabledParameters() const { return mIsEnabledParameters; }
@@ -159,6 +165,9 @@ private:
std::string mExecuteFunction;
LLSD mExecuteParameters;
+ std::string mExecuteStopFunction;
+ LLSD mExecuteStopParameters;
+
std::string mIsEnabledFunction;
LLSD mIsEnabledParameters;
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 90c41e99dc..0398c0d7eb 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -62,6 +62,17 @@
// use this to control "jumping" behavior when Ctrl-Tabbing
const S32 TABBED_FLOATER_OFFSET = 0;
+namespace LLInitParam
+{
+ void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
+ {
+ declare("none", LLFloaterEnums::OPEN_POSITIONING_NONE);
+ declare("cascading", LLFloaterEnums::OPEN_POSITIONING_CASCADING);
+ declare("centered", LLFloaterEnums::OPEN_POSITIONING_CENTERED);
+ declare("specified", LLFloaterEnums::OPEN_POSITIONING_SPECIFIED);
+ }
+}
+
std::string LLFloater::sButtonNames[BUTTON_COUNT] =
{
"llfloater_close_btn", //BUTTON_CLOSE
@@ -154,7 +165,6 @@ LLFloater::Params::Params()
: title("title"),
short_title("short_title"),
single_instance("single_instance", false),
- auto_tile("auto_tile", false),
can_resize("can_resize", false),
can_minimize("can_minimize", true),
can_close("can_close", true),
@@ -164,7 +174,7 @@ LLFloater::Params::Params()
save_rect("save_rect", false),
save_visibility("save_visibility", false),
can_dock("can_dock", false),
- open_centered("open_centered", false),
+ open_positioning("open_positioning", LLFloaterEnums::OPEN_POSITIONING_NONE),
header_height("header_height", 0),
legacy_header_height("legacy_header_height", 0),
close_image("close_image"),
@@ -227,7 +237,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
mShortTitle(p.short_title),
mSingleInstance(p.single_instance),
mKey(key),
- mAutoTile(p.auto_tile),
mCanTearOff(p.can_tear_off),
mCanMinimize(p.can_minimize),
mCanClose(p.can_close),
@@ -831,7 +840,7 @@ LLMultiFloater* LLFloater::getHost()
return (LLMultiFloater*)mHostHandle.get();
}
-void LLFloater::applySavedVariables()
+void LLFloater::applySavedVariables()
{
applyRectControl();
applyDockState();
@@ -839,13 +848,7 @@ void LLFloater::applySavedVariables()
void LLFloater::applyRectControl()
{
- // first, center on screen if requested
- if (mOpenCentered)
- {
- center();
- }
-
- // override center if we have saved rect control
+ // If we have a saved rect, use it
if (mRectControl.size() > 1)
{
const LLRect& rect = getControlGroup()->getRect(mRectControl);
@@ -867,7 +870,50 @@ void LLFloater::applyDockState()
bool dockState = getControlGroup()->getBOOL(mDocStateControl);
setDocked(dockState);
}
+}
+
+void LLFloater::applyPositioning()
+{
+ // Otherwise position according to the positioning code
+ switch (mOpenPositioning)
+ {
+ case LLFloaterEnums::OPEN_POSITIONING_CENTERED:
+ center();
+ break;
+
+ case LLFloaterEnums::OPEN_POSITIONING_SPECIFIED:
+ {
+ // Translate relative to snap rect
+ LLRect r = getRect();
+ r.mBottom = getSnapRect().getHeight() - r.getHeight() - r.mBottom;
+ setOrigin(r.mLeft, r.mBottom);
+ translateIntoRect(getSnapRect(), FALSE);
+ }
+ break;
+ case LLFloaterEnums::OPEN_POSITIONING_CASCADING:
+ {
+ static const U32 CASCADING_FLOATER_HOFFSET = 25;
+ static const U32 CASCADING_FLOATER_VOFFSET = 25;
+ static const S32 CASCADING_FLOATER_LIMIT = 15;
+ static S32 cascading_floater_count = 1;
+ const S32 top = CASCADING_FLOATER_VOFFSET * cascading_floater_count;
+ const S32 left = CASCADING_FLOATER_HOFFSET * cascading_floater_count;
+ setOrigin(left, top);
+ translateIntoRect(getSnapRect(), FALSE);
+
+ if (++cascading_floater_count > CASCADING_FLOATER_LIMIT)
+ {
+ cascading_floater_count = 1;
+ }
+ }
+ break;
+
+ case LLFloaterEnums::OPEN_POSITIONING_NONE:
+ default:
+ // Do nothing
+ break;
+ }
}
void LLFloater::applyTitle()
@@ -2784,7 +2830,6 @@ void LLFloater::setInstanceName(const std::string& name)
{
mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);
}
-
}
}
@@ -2846,9 +2891,9 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
mHeaderHeight = p.header_height;
mLegacyHeaderHeight = p.legacy_header_height;
mSingleInstance = p.single_instance;
- mAutoTile = p.auto_tile;
- mOpenCentered = p.open_centered;
+ mOpenPositioning = p.open_positioning;
+ /*
if (p.save_rect && mRectControl.empty())
{
mRectControl = "t"; // flag to build mRectControl name once mInstanceName is set
@@ -2856,7 +2901,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
if (p.save_visibility)
{
mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
- }
+ }*/
if(p.save_dock_state)
{
@@ -3008,6 +3053,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str
llerrs << "Failed to construct floater " << getName() << llendl;
}
+ applyPositioning();
applyRectControl(); // If we have a saved rect control, apply it
gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index af9665e599..b404306e94 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -59,11 +59,35 @@ const BOOL CLOSE_NO = FALSE;
const BOOL ADJUST_VERTICAL_YES = TRUE;
const BOOL ADJUST_VERTICAL_NO = FALSE;
+namespace LLFloaterEnums
+{
+ enum EOpenPositioning
+ {
+ OPEN_POSITIONING_NONE,
+ OPEN_POSITIONING_CASCADING,
+ OPEN_POSITIONING_CENTERED,
+ OPEN_POSITIONING_SPECIFIED,
+
+ OPEN_POSITIONING_COUNT
+ };
+}
+
+namespace LLInitParam
+{
+ template<>
+ struct TypeValues<LLFloaterEnums::EOpenPositioning> : public TypeValuesHelper<LLFloaterEnums::EOpenPositioning>
+ {
+ static void declareValues();
+ };
+}
+
+
class LLFloater : public LLPanel
{
-friend class LLFloaterView;
-friend class LLFloaterReg;
-friend class LLMultiFloater;
+ friend class LLFloaterView;
+ friend class LLFloaterReg;
+ friend class LLMultiFloater;
+
public:
struct KeyCompare
{
@@ -95,7 +119,6 @@ public:
short_title;
Optional<bool> single_instance,
- auto_tile,
can_resize,
can_minimize,
can_close,
@@ -104,8 +127,10 @@ public:
save_rect,
save_visibility,
save_dock_state,
- can_dock,
- open_centered;
+ can_dock;
+
+ Optional<LLFloaterEnums::EOpenPositioning> open_positioning;
+
Optional<S32> header_height,
legacy_header_height; // HACK see initFromXML()
@@ -297,6 +322,7 @@ protected:
virtual void applyRectControl();
void applyDockState();
+ void applyPositioning();
void storeRectControl();
void storeVisibilityControl();
void storeDockStateControl();
@@ -378,14 +404,14 @@ private:
BOOL mSingleInstance; // TRUE if there is only ever one instance of the floater
std::string mInstanceName; // Store the instance name so we can remove ourselves from the list
- BOOL mAutoTile; // TRUE if placement of new instances tiles
BOOL mCanTearOff;
BOOL mCanMinimize;
BOOL mCanClose;
BOOL mDragOnLeft;
BOOL mResizable;
- bool mOpenCentered;
+
+ LLFloaterEnums::EOpenPositioning mOpenPositioning;
S32 mMinWidth;
S32 mMinHeight;
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index ae06eb74ac..058223abbd 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -107,7 +107,6 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
if (!groupname.empty())
{
instance_list_t& list = sInstanceMap[groupname];
- int index = list.size();
res = build_func(key);
if (!res)
@@ -121,27 +120,18 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
llwarns << "Failed to build floater type: '" << name << "'." << llendl;
return NULL;
}
-
+
// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
if (res->mKey.isUndefined())
{
- res->mKey = key;
+ res->mKey = key;
}
res->setInstanceName(name);
res->applySavedVariables(); // Can't apply rect and dock state until setting instance name
- if (res->mAutoTile && !res->getHost() && index > 0)
- {
- LLFloater* last_floater = getLastFloaterInGroup(groupname);
- if (last_floater)
- {
- res->stackWith(*last_floater);
- gFloaterView->adjustToFitScreen(res, true);
- }
- }
- else
- {
- gFloaterView->adjustToFitScreen(res, false);
- }
+
+ // apply list.size() and possibly stackWith(getLastFloaterInGroup(groupname))
+ gFloaterView->adjustToFitScreen(res, false);
+
list.push_back(res);
}
}
@@ -477,16 +467,21 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname)
std::string name = sdname.asString();
parse_name_key(name, key);
- LLFloater* instance = findInstance(name, key);
+ LLFloater* instance = getInstance(name, key);
- if (LLFloater::isMinimized(instance))
+ if (!instance)
+ {
+ lldebugs << "Unable to get instance of floater '" << name << "'" << llendl;
+ }
+ else if (instance->isMinimized())
{
instance->setMinimized(FALSE);
instance->setFocus(TRUE);
}
- else if (!LLFloater::isShown(instance))
+ else if (!instance->isShown())
{
- showInstance(name, key, TRUE);
+ instance->openFloater(key);
+ instance->setFocus(TRUE);
}
else if (!instance->hasFocus() && !instance->getIsChrome())
{
diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp
index da50c0ff39..242b1fca7f 100644
--- a/indra/llui/llsdparam.cpp
+++ b/indra/llui/llsdparam.cpp
@@ -299,6 +299,12 @@ void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLI
}
}
+//static
+void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd)
+{
+ LLInitParam::Parser::name_stack_t stack = LLInitParam::Parser::name_stack_t();
+ readSDValues(cb, sd, stack);
+}
namespace LLInitParam
{
// LLSD specialization
diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h
index 784358d038..c1cfa98399 100644
--- a/indra/llui/llsdparam.h
+++ b/indra/llui/llsdparam.h
@@ -36,7 +36,8 @@ struct LLParamSDParserUtilities
static LLSD& getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range);
typedef boost::function<void (const LLSD&, LLInitParam::Parser::name_stack_t&)> read_sd_cb_t;
- static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack = LLInitParam::Parser::name_stack_t());
+ static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack);
+ static void readSDValues(read_sd_cb_t cb, const LLSD& sd);
};
class LLParamSDParser
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 89184f781f..a1ea4ba18b 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -34,6 +34,7 @@
#include "llmenugl.h"
#include "lltrans.h"
#include "llinventory.h"
+#include "lliconctrl.h"
// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit
// thanks, MSVC!
@@ -204,7 +205,6 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
{
LLCommand * command = LLCommandManager::instance().getCommand(commandId);
if (!command) return false;
- llinfos << "Merov debug : addCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
// Create the button and do the things that don't need ordering
LLToolBarButton* button = createButton(commandId);
@@ -248,7 +248,6 @@ int LLToolBar::removeCommand(const LLCommandId& commandId)
{
if (!hasCommand(commandId)) return RANK_NONE;
- llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
// First erase the map record
command_id_map::iterator it = mButtonMap.find(commandId.uuid());
mButtonMap.erase(it);
@@ -398,7 +397,7 @@ void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row
// The rank is the position a tool dropped in (x,y) would assume in the button list.
// The value returned is between 0 and mButtons.size(), 0 being the first element to the left
// (or top) and mButtons.size() the last one to the right (or bottom).
-int LLToolBar::getRankFromPosition(S32 x, S32 y)
+int LLToolBar::getRankFromPosition(S32& x, S32& y)
{
int rank = 0;
@@ -406,16 +405,16 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
S32 button_panel_x = 0;
S32 button_panel_y = 0;
localPointToOtherView(x, y, &button_panel_x, &button_panel_y, mButtonPanel);
+ S32 dx = x - button_panel_x;
+ S32 dy = y - button_panel_y;
- //llinfos << "Merov debug : rank compute: orientation = " << orientation << ", x = " << button_panel_x << ", y = " << button_panel_y << llendl;
-
// Simply compare the passed coord with the buttons outbound box
std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
std::list<LLToolBarButton*>::iterator end_button = mButtons.end();
+ LLRect button_rect;
while (it_button != end_button)
{
- LLRect button_rect = (*it_button)->getRect();
- //llinfos << "Merov debug : rank compute: rect = " << button_rect.mLeft << ", " << button_rect.mTop << ", " << button_rect.mRight << ", " << button_rect.mBottom << llendl;
+ button_rect = (*it_button)->getRect();
if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > button_panel_x)) ||
((orientation == LLLayoutStack::VERTICAL) && (button_rect.mBottom < button_panel_y)) )
{
@@ -424,7 +423,16 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
rank++;
++it_button;
}
- //llinfos << "Merov debug : rank = " << rank << llendl;
+ if (it_button != end_button)
+ {
+ x = button_rect.mLeft + dx;
+ y = button_rect.mTop + dy;
+ }
+ else
+ {
+ x = button_rect.mRight + dx;
+ y = button_rect.mBottom + dy;
+ }
return rank;
}
@@ -613,7 +621,41 @@ void LLToolBar::draw()
LLUI::pushMatrix();
LLUI::translate((F32)getRect().mLeft, (F32)getRect().mBottom, 0.f);
+ // Position the caret
+ LLIconCtrl* caret = getChild<LLIconCtrl>("caret");
+ caret->setVisible(FALSE);
+ if (mDragAndDropTarget && !mButtonCommands.empty())
+ {
+ LLRect caret_rect = caret->getRect();
+ LLRect toolbar_rect = getRect();
+ if (mSideType == SIDE_BOTTOM)
+ {
+ caret->setRect(LLRect(mDragx-caret_rect.getWidth()/2+1,
+ toolbar_rect.getHeight()+3,
+ mDragx+caret_rect.getWidth()/2+1,
+ toolbar_rect.getHeight()-caret_rect.getHeight()+3));
+ }
+ else if (mSideType == SIDE_LEFT)
+ {
+
+ caret->setRect(LLRect(toolbar_rect.getWidth()-caret_rect.getWidth()+3,
+ mDragy+caret_rect.getHeight()/2,
+ toolbar_rect.getWidth()+3,
+ mDragy-caret_rect.getHeight()/2));
+ }
+ else
+ {
+ caret->setRect(LLRect(-3,
+ mDragy+caret_rect.getHeight()/2,
+ caret_rect.getWidth()-3,
+ mDragy-caret_rect.getHeight()/2));
+ }
+ caret->setVisible(TRUE);
+ }
+
LLUICtrl::draw();
+ caret->setVisible(FALSE);
+ mDragAndDropTarget = false;
}
void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent)
@@ -659,11 +701,25 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id)
if (!mReadOnly)
{
- LLUICtrl::CommitCallbackParam cbParam;
- cbParam.function_name = commandp->executeFunctionName();
- cbParam.parameter = commandp->executeParameters();
+ LLUICtrl::CommitCallbackParam executeParam;
+ executeParam.function_name = commandp->executeFunctionName();
+ 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();
if (isEnabledFunction.length() > 0)
@@ -713,7 +769,6 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EAcceptance* accept,
std::string& tooltip_msg)
{
- llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl;
// If we have a drop callback, that means that we can handle the drop
BOOL handled = (mHandleDropCallback ? TRUE : FALSE);
@@ -729,21 +784,22 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
// We'll use that flag to change the visual aspect of the toolbar target on draw()
mDragAndDropTarget = false;
- // HACK!!!
- if (!isReadOnly() && handled)
+ // Convert drag position into insert position and rank
+ if (!isReadOnly() && handled && !drop)
{
- if (!drop)
+ LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
+ LLAssetType::EType type = inv_item->getType();
+ if (type == LLAssetType::AT_WIDGET)
{
- LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
- LLAssetType::EType type = inv_item->getType();
- if (type == LLAssetType::AT_WIDGET)
- {
- LLCommandId dragged_command(inv_item->getUUID());
- int rank = getRankFromPosition(x, y);
- removeCommand(dragged_command);
- addCommand(dragged_command,rank);
- mDragAndDropTarget = true;
- }
+ mDragx = x;
+ mDragy = y;
+ mDragRank = getRankFromPosition(mDragx, mDragy);
+ mDragAndDropTarget = true;
+ /* Do the following if you want to animate the button itself
+ LLCommandId dragged_command(inv_item->getUUID());
+ removeCommand(dragged_command);
+ addCommand(dragged_command,rank);
+ */
}
}
@@ -784,7 +840,6 @@ BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask)
BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask)
{
-// llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl;
BOOL handled = FALSE;
S32 mouse_distance_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY);
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 321064a0fd..709399c59f 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -48,7 +48,7 @@ public:
struct Params : public LLInitParam::Block<Params, LLButton::Params>
{
Optional<LLUI::RangeS32::Params> button_width;
- Optional<S32> desired_height;
+ Optional<S32> desired_height;
Params()
: button_width("button_width"),
@@ -156,14 +156,14 @@ public:
// virtuals
void draw();
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
- int getRankFromPosition(S32 x, S32 y);
+ int getRankFromPosition(S32& x, S32& y);
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
void* cargo_data,
EAcceptance* accept,
std::string& tooltip_msg);
-
+
static const int RANK_NONE = -1;
bool addCommand(const LLCommandId& commandId, int rank = RANK_NONE);
@@ -178,6 +178,8 @@ public:
LLToolBarButton* createButton(const LLCommandId& id);
+ bool hasButtons() { return !mButtons.empty(); }
+
protected:
friend class LLUICtrlFactory;
LLToolBar(const Params&);
@@ -188,6 +190,9 @@ protected:
tool_handledrag_callback_t mHandleDragItemCallback;
tool_handledrop_callback_t mHandleDropCallback;
bool mDragAndDropTarget;
+ int mDragRank;
+ S32 mDragx,
+ mDragy;
public:
// Methods used in loading and saving toolbar settings
@@ -217,7 +222,7 @@ private:
LLLayoutStack* mWrapStack;
LLPanel* mButtonPanel;
LLToolBarEnums::SideType mSideType;
-
+
bool mWrap;
bool mNeedsLayout;
S32 mPadLeft,