summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2011-10-19 19:44:30 -0700
committerMerov Linden <merov@lindenlab.com>2011-10-19 19:44:30 -0700
commitaa3f5edc83a6a20f0473fff6f28fdad6f5406dc2 (patch)
tree192da0c80b9b9b76486c2b174297b9dfd8f8b7de /indra/llui
parentc8499a7b607171507df8cbb6f415dfaa66699b2a (diff)
parent832a509c38035447ece2d0ae77c8661311e72d7e (diff)
Pull from richard/viewer-experience-fui
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/lldockablefloater.cpp7
-rw-r--r--indra/llui/llfloater.cpp43
-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
6 files changed, 53 insertions, 13 deletions
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..bd537bfb19 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,15 @@ bool LLFloater::applyRectControl()
{
bool saved_rect = false;
- // If we have a saved rect, use it
- if (mRectControl.size() > 1)
+ if (LLFloaterReg::getLastFloaterInGroup(mInstanceName))
{
+ // 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 +1071,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 +1403,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 +1479,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 +1585,12 @@ void LLFloater::setDocked(bool docked, bool pop_on_undock)
{
mDocked = docked;
mButtonsEnabled[BUTTON_DOCK] = !mDocked;
+
+ if (mDocked)
+ {
+ setMinimized(FALSE);
+ }
+
updateTitleButtons();
storeDockStateControl();
@@ -2949,6 +2980,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 +3262,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..bceda9bf54 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->id().name(); // Make sure to retrieve the name from the command itself, not the passed in id
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;