summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llcommandmanager.cpp9
-rw-r--r--indra/llui/llcommandmanager.h23
-rw-r--r--indra/llui/lldockablefloater.cpp7
-rw-r--r--indra/llui/llfloater.cpp45
-rw-r--r--indra/llui/llfloater.h2
-rw-r--r--indra/llui/llfloaterreg.cpp1
-rw-r--r--indra/llui/lltoolbar.cpp10
-rw-r--r--indra/llui/lltoolbar.h3
8 files changed, 64 insertions, 36 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 128ba609cb..0e2f3f1961 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -41,7 +41,7 @@
// LLCommandId class
//
-const LLCommandId LLCommandId::null = LLCommandId();
+const LLCommandId LLCommandId::null = LLCommandId("null command");
//
// LLCommand class
@@ -67,10 +67,11 @@ LLCommand::Params::Params()
}
LLCommand::LLCommand(const LLCommand::Params& p)
- : mAvailableInToybox(p.available_in_toybox)
+ : mIdentifier(p.name)
+ , mAvailableInToybox(p.available_in_toybox)
, mIcon(p.icon)
- , mIdentifier(p.name)
, mLabelRef(p.label_ref)
+ , mName(p.name)
, mTooltipRef(p.tooltip_ref)
, mExecuteFunction(p.execute_function)
, mExecuteParameters(p.execute_parameters)
@@ -134,7 +135,7 @@ void LLCommandManager::addCommand(LLCommand * command)
mCommandIndices[command_id.uuid()] = mCommands.size();
mCommands.push_back(command);
- lldebugs << "Successfully added command: " << command->id().name() << llendl;
+ lldebugs << "Successfully added command: " << command->name() << llendl;
}
//static
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index 9b93ab735a..a7276a48aa 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -50,31 +50,20 @@ public:
{}
};
- LLCommandId()
- : mName("null command")
- {
- mUUID = LLUUID::generateNewID(mName);
- }
-
LLCommandId(const std::string& name)
- : mName(name)
{
mUUID = LLUUID::generateNewID(name);
}
LLCommandId(const Params& p)
- : mName(p.name)
{
mUUID = LLUUID::generateNewID(p.name);
}
LLCommandId(const LLUUID& uuid)
- : mName(""),
- mUUID(uuid)
- {
- }
+ : mUUID(uuid)
+ {}
- const std::string& name() const { return mName; }
const LLUUID& uuid() const { return mUUID; }
bool operator!=(const LLCommandId& command) const
@@ -87,15 +76,9 @@ public:
return (mUUID == command.mUUID);
}
- bool operator<(const LLCommandId& command) const
- {
- return (mName < command.mName);
- }
-
static const LLCommandId null;
private:
- std::string mName;
LLUUID mUUID;
};
@@ -137,6 +120,7 @@ public:
const std::string& icon() const { return mIcon; }
const LLCommandId& id() const { return mIdentifier; }
const std::string& labelRef() const { return mLabelRef; }
+ const std::string& name() const { return mName; }
const std::string& tooltipRef() const { return mTooltipRef; }
const std::string& executeFunctionName() const { return mExecuteFunction; }
@@ -160,6 +144,7 @@ private:
bool mAvailableInToybox;
std::string mIcon;
std::string mLabelRef;
+ std::string mName;
std::string mTooltipRef;
std::string mExecuteFunction;
diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp
index ca2dc644a4..aea58be12a 100644
--- a/indra/llui/lldockablefloater.cpp
+++ b/indra/llui/lldockablefloater.cpp
@@ -162,10 +162,15 @@ void LLDockableFloater::setVisible(BOOL visible)
void LLDockableFloater::setMinimized(BOOL minimize)
{
- if(minimize)
+ if(minimize && isDocked())
{
+ // minimizing a docked floater just hides it
setVisible(FALSE);
}
+ else
+ {
+ LLFloater::setMinimized(minimize);
+ }
}
LLView * LLDockableFloater::getDockWidget()
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 3085921e04..ddc90b0378 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -165,6 +165,7 @@ LLFloater::Params::Params()
: title("title"),
short_title("short_title"),
single_instance("single_instance", false),
+ reuse_instance("reuse_instance", false),
can_resize("can_resize", false),
can_minimize("can_minimize", true),
can_close("can_close", true),
@@ -239,6 +240,7 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
mTitle(p.title),
mShortTitle(p.short_title),
mSingleInstance(p.single_instance),
+ mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default
mKey(key),
mCanTearOff(p.can_tear_off),
mCanMinimize(p.can_minimize),
@@ -683,7 +685,12 @@ void LLFloater::openFloater(const LLSD& key)
}
else
{
- applyControlsAndPosition(LLFloaterReg::getLastFloaterCascading());
+ LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+ if (!floater_to_stack)
+ {
+ floater_to_stack = LLFloaterReg::getLastFloaterCascading();
+ }
+ applyControlsAndPosition(floater_to_stack);
setMinimized(FALSE);
setVisibleAndFrontmost(mAutoFocus);
}
@@ -776,12 +783,19 @@ void LLFloater::closeFloater(bool app_quitting)
else
{
setVisible(FALSE);
+ if (!mReuseInstance)
+ {
+ destroy();
+ }
}
}
else
{
setVisible(FALSE); // hide before destroying (so handleVisibilityChange() gets called)
- destroy();
+ if (!mReuseInstance)
+ {
+ destroy();
+ }
}
}
}
@@ -861,9 +875,16 @@ bool LLFloater::applyRectControl()
{
bool saved_rect = false;
- // If we have a saved rect, use it
- if (mRectControl.size() > 1)
+ LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+ if (last_in_group && last_in_group != this)
{
+ // other floaters in our group, position ourselves relative to them and don't save the rect
+ mRectControl.clear();
+ mOpenPositioning = LLFloaterEnums::OPEN_POSITIONING_CASCADING;
+ }
+ else if (mRectControl.size() > 1)
+ {
+ // If we have a saved rect, use it
const LLRect& rect = getControlGroup()->getRect(mRectControl);
saved_rect = rect.notEmpty();
if (saved_rect)
@@ -1051,6 +1072,7 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user)
if (by_user)
{
storeRectControl();
+ mOpenPositioning = LLFloaterEnums::OPEN_POSITIONING_NONE;
}
// if not minimized, adjust all snapped dependents to new shape
@@ -1382,7 +1404,10 @@ void LLFloater::moveResizeHandlesToFront()
BOOL LLFloater::isFrontmost()
{
- return gFloaterView && gFloaterView->getFrontmost() == this && getVisible();
+ LLFloaterView* floater_view = getParentByType<LLFloaterView>();
+ return getVisible()
+ && (floater_view
+ && floater_view->getFrontmost() == this);
}
void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition)
@@ -1455,6 +1480,7 @@ BOOL LLFloater::handleMouseDown(S32 x, S32 y, MASK mask)
if(offerClickToButton(x, y, mask, BUTTON_CLOSE)) return TRUE;
if(offerClickToButton(x, y, mask, BUTTON_RESTORE)) return TRUE;
if(offerClickToButton(x, y, mask, BUTTON_TEAR_OFF)) return TRUE;
+ if(offerClickToButton(x, y, mask, BUTTON_DOCK)) return TRUE;
// Otherwise pass to drag handle for movement
return mDragHandle->handleMouseDown(x, y, mask);
@@ -1560,6 +1586,13 @@ void LLFloater::setDocked(bool docked, bool pop_on_undock)
{
mDocked = docked;
mButtonsEnabled[BUTTON_DOCK] = !mDocked;
+
+ if (mDocked)
+ {
+ setMinimized(FALSE);
+ mOpenPositioning = LLFloaterEnums::OPEN_POSITIONING_NONE;
+ }
+
updateTitleButtons();
storeDockStateControl();
@@ -2949,6 +2982,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
mHeaderHeight = p.header_height;
mLegacyHeaderHeight = p.legacy_header_height;
mSingleInstance = p.single_instance;
+ mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance;
mOpenPositioning = p.open_positioning;
mSpecifiedLeft = p.specified_left;
@@ -3230,7 +3264,6 @@ void LLFloater::stackWith(LLFloater& other)
next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight());
- mRectControl.clear(); // don't save rect of stacked floaters
setShape(next_rect);
}
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index f610b04e35..f384e64e53 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -120,6 +120,7 @@ public:
short_title;
Optional<bool> single_instance,
+ reuse_instance,
can_resize,
can_minimize,
can_close,
@@ -409,6 +410,7 @@ private:
LLUIString mShortTitle;
BOOL mSingleInstance; // TRUE if there is only ever one instance of the floater
+ bool mReuseInstance; // true if we want to hide the floater when we close it instead of destroying it
std::string mInstanceName; // Store the instance name so we can remove ourselves from the list
BOOL mCanTearOff;
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index df3cff9968..e144b68f5e 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -167,6 +167,7 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
res->setInstanceName(name);
LLFloater *last_floater = (list.empty() ? NULL : list.back());
+
res->applyControlsAndPosition(last_floater);
gFloaterView->adjustToFitScreen(res, false);
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index c559a2bf1d..515605200e 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -217,7 +217,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
if ((rank >= mButtonCommands.size()) || (rank == RANK_NONE))
{
// In that case, back load
- mButtonCommands.push_back(commandId);
+ mButtonCommands.push_back(command->id());
mButtons.push_back(button);
}
else
@@ -232,7 +232,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
rank--;
}
// ...then insert
- mButtonCommands.insert(it_command,commandId);
+ mButtonCommands.insert(it_command, command->id());
mButtons.insert(it_button,button);
}
@@ -821,7 +821,7 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id)
if (!commandp) return NULL;
LLToolBarButton::Params button_p;
- button_p.name = id.name();
+ button_p.name = commandp->name();
button_p.label = LLTrans::getString(commandp->labelRef());
button_p.tool_tip = LLTrans::getString(commandp->tooltipRef());
button_p.image_overlay = LLUI::getUIImage(commandp->icon());
@@ -999,13 +999,13 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask)
{
if (!mIsDragged)
{
- mStartDragItemCallback(x,y,mId.uuid());
+ mStartDragItemCallback(x, y, this);
mIsDragged = true;
handled = TRUE;
}
else
{
- handled = mHandleDragItemCallback(x,y,mId.uuid(),LLAssetType::AT_WIDGET);
+ handled = mHandleDragItemCallback(x, y, mId.uuid(), LLAssetType::AT_WIDGET);
}
}
else
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index ad42d1fa35..e634e57f93 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -36,8 +36,9 @@
#include "llassettype.h"
class LLToolBar;
+class LLToolBarButton;
-typedef boost::function<void (S32 x, S32 y, const LLUUID& uuid)> tool_startdrag_callback_t;
+typedef boost::function<void (S32 x, S32 y, LLToolBarButton* button)> tool_startdrag_callback_t;
typedef boost::function<BOOL (S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type)> tool_handledrag_callback_t;
typedef boost::function<BOOL (void* data, S32 x, S32 y, LLToolBar* toolbar)> tool_handledrop_callback_t;