summaryrefslogtreecommitdiff
path: root/indra/llui/llfloater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llfloater.cpp')
-rw-r--r--indra/llui/llfloater.cpp694
1 files changed, 540 insertions, 154 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index d19e33ea55..a8a3a1f906 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -58,10 +58,23 @@
#include "llhelp.h"
#include "llmultifloater.h"
#include "llsdutil.h"
+#include <boost/foreach.hpp>
+
// use this to control "jumping" behavior when Ctrl-Tabbing
const S32 TABBED_FLOATER_OFFSET = 0;
+namespace LLInitParam
+{
+ void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
+ {
+ declare("relative", LLFloaterEnums::POSITIONING_RELATIVE);
+ declare("cascading", LLFloaterEnums::POSITIONING_CASCADING);
+ declare("centered", LLFloaterEnums::POSITIONING_CENTERED);
+ declare("specified", LLFloaterEnums::POSITIONING_SPECIFIED);
+ }
+}
+
std::string LLFloater::sButtonNames[BUTTON_COUNT] =
{
"llfloater_close_btn", //BUTTON_CLOSE
@@ -100,7 +113,6 @@ LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] =
LLMultiFloater* LLFloater::sHostp = NULL;
BOOL LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting
-LLFloater::handle_map_t LLFloater::sFloaterMap;
LLFloaterView* gFloaterView = NULL;
@@ -154,7 +166,7 @@ LLFloater::Params::Params()
: title("title"),
short_title("short_title"),
single_instance("single_instance", false),
- auto_tile("auto_tile", false),
+ reuse_instance("reuse_instance", false),
can_resize("can_resize", false),
can_minimize("can_minimize", true),
can_close("can_close", true),
@@ -164,7 +176,8 @@ LLFloater::Params::Params()
save_rect("save_rect", false),
save_visibility("save_visibility", false),
can_dock("can_dock", false),
- open_centered("open_centered", false),
+ show_title("show_title", true),
+ positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE),
header_height("header_height", 0),
legacy_header_height("legacy_header_height", 0),
close_image("close_image"),
@@ -180,9 +193,10 @@ LLFloater::Params::Params()
dock_pressed_image("dock_pressed_image"),
help_pressed_image("help_pressed_image"),
open_callback("open_callback"),
- close_callback("close_callback")
+ close_callback("close_callback"),
+ follows("follows")
{
- visible = false;
+ changeDefault(visible, false);
}
@@ -226,13 +240,14 @@ 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),
- mAutoTile(p.auto_tile),
mCanTearOff(p.can_tear_off),
mCanMinimize(p.can_minimize),
mCanClose(p.can_close),
mDragOnLeft(p.can_drag_on_left),
mResizable(p.can_resize),
+ mPositioning(p.positioning),
mMinWidth(p.min_width),
mMinHeight(p.min_height),
mHeaderHeight(p.header_height),
@@ -251,7 +266,7 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
mMinimizeSignal(NULL)
// mNotificationContext(NULL)
{
- mHandle.bind(this);
+ mPosition.setFloater(*this);
// mNotificationContext = new LLFloaterNotificationContext(getHandle());
// Clicks stop here.
@@ -306,9 +321,6 @@ void LLFloater::initFloater(const Params& p)
// Floaters are created in the invisible state
setVisible(FALSE);
- // add self to handle->floater map
- sFloaterMap[mHandle] = this;
-
if (!getParent())
{
gFloaterView->addChild(this);
@@ -459,15 +471,24 @@ void LLFloater::layoutResizeCtrls()
mResizeHandle[3]->setRect(rect);
}
-void LLFloater::enableResizeCtrls(bool enable)
+void LLFloater::enableResizeCtrls(bool enable, bool width, bool height)
{
+ mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width);
+ mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width);
+
+ mResizeBar[LLResizeBar::TOP]->setVisible(enable && height);
+ mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height);
+
+ mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width);
+ mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width);
+
+ mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height);
+ mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height);
+
for (S32 i = 0; i < 4; ++i)
{
- mResizeBar[i]->setVisible(enable);
- mResizeBar[i]->setEnabled(enable);
-
- mResizeHandle[i]->setVisible(enable);
- mResizeHandle[i]->setEnabled(enable);
+ mResizeHandle[i]->setVisible(enable && width && height);
+ mResizeHandle[i]->setEnabled(enable && width && height);
}
}
@@ -506,8 +527,6 @@ LLFloater::~LLFloater()
// correct, non-minimized positions.
setMinimized( FALSE );
- sFloaterMap.erase(mHandle);
-
delete mDragHandle;
for (S32 i = 0; i < 4; i++)
{
@@ -515,7 +534,6 @@ LLFloater::~LLFloater()
delete mResizeHandle[i];
}
- storeRectControl();
setVisible(false); // We're not visible if we're destroyed
storeVisibilityControl();
storeDockStateControl();
@@ -525,10 +543,18 @@ LLFloater::~LLFloater()
void LLFloater::storeRectControl()
{
- if( mRectControl.size() > 1 )
+ if (!mRectControl.empty())
{
getControlGroup()->setRect( mRectControl, getRect() );
}
+ if (!mPosXControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
+ {
+ getControlGroup()->setF32( mPosXControl, mPosition.mX );
+ }
+ if (!mPosYControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
+ {
+ getControlGroup()->setF32( mPosYControl, mPosition.mY );
+ }
}
void LLFloater::storeVisibilityControl()
@@ -547,23 +573,6 @@ void LLFloater::storeDockStateControl()
}
}
-LLRect LLFloater::getSavedRect() const
-{
- LLRect rect;
-
- if (mRectControl.size() > 1)
- {
- rect = getControlGroup()->getRect(mRectControl);
- }
-
- return rect;
-}
-
-bool LLFloater::hasSavedRect() const
-{
- return !getSavedRect().isEmpty();
-}
-
// static
std::string LLFloater::getControlName(const std::string& name, const LLSD& key)
{
@@ -660,6 +669,12 @@ void LLFloater::openFloater(const LLSD& key)
}
else
{
+ LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+ if (!floater_to_stack)
+ {
+ floater_to_stack = LLFloaterReg::getLastFloaterCascading();
+ }
+ applyControlsAndPosition(floater_to_stack);
setMinimized(FALSE);
setVisibleAndFrontmost(mAutoFocus);
}
@@ -752,12 +767,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();
+ }
}
}
}
@@ -766,7 +788,6 @@ void LLFloater::closeFloater(bool app_quitting)
void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent)
{
LLPanel::reshape(width, height, called_from_parent);
- storeRectControl();
}
void LLFloater::releaseFocus()
@@ -823,43 +844,153 @@ LLMultiFloater* LLFloater::getHost()
return (LLMultiFloater*)mHostHandle.get();
}
-void LLFloater::applySavedVariables()
+void LLFloater::applyControlsAndPosition(LLFloater* other)
{
- applyRectControl();
- applyDockState();
+ if (!applyDockState())
+ {
+ if (!applyRectControl())
+ {
+ applyPositioning(other, true);
+ }
+ }
}
-void LLFloater::applyRectControl()
+bool LLFloater::applyRectControl()
{
- // first, center on screen if requested
- if (mOpenCentered)
+ bool saved_rect = false;
+
+ LLRect screen_rect = calcScreenRect();
+ mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+
+ LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+ if (last_in_group && last_in_group != this)
{
- center();
+ // other floaters in our group, position ourselves relative to them and don't save the rect
+ mRectControl.clear();
+ mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
}
-
- // override center if we have saved rect control
- if (mRectControl.size() > 1)
+ else
{
- const LLRect& rect = getControlGroup()->getRect(mRectControl);
- if (rect.getWidth() > 0 && rect.getHeight() > 0)
+ bool rect_specified = false;
+ if (!mRectControl.empty())
{
- translate( rect.mLeft - getRect().mLeft, rect.mBottom - getRect().mBottom);
- if (mResizable)
+ // If we have a saved rect, use it
+ const LLRect& rect = getControlGroup()->getRect(mRectControl);
+ if (rect.notEmpty()) saved_rect = true;
+ if (saved_rect)
{
- reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight()));
+ setOrigin(rect.mLeft, rect.mBottom);
+
+ if (mResizable)
+ {
+ reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight()));
+ }
+ mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+ LLRect screen_rect = calcScreenRect();
+ mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+ rect_specified = true;
}
}
+
+ LLControlVariablePtr x_control = getControlGroup()->getControl(mPosXControl);
+ LLControlVariablePtr y_control = getControlGroup()->getControl(mPosYControl);
+ if (x_control.notNull()
+ && y_control.notNull()
+ && !x_control->isDefault()
+ && !y_control->isDefault())
+ {
+ mPosition.mX = x_control->getValue().asReal();
+ mPosition.mY = y_control->getValue().asReal();
+ mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+ applyRelativePosition();
+
+ saved_rect = true;
+ }
+
+ // remember updated position
+ if (rect_specified)
+ {
+ storeRectControl();
+ }
+ }
+
+ if (saved_rect)
+ {
+ // propagate any derived positioning data back to settings file
+ storeRectControl();
}
+
+
+ return saved_rect;
}
-void LLFloater::applyDockState()
+bool LLFloater::applyDockState()
{
+ bool docked = false;
+
if (mDocStateControl.size() > 1)
{
- bool dockState = getControlGroup()->getBOOL(mDocStateControl);
- setDocked(dockState);
+ docked = getControlGroup()->getBOOL(mDocStateControl);
+ setDocked(docked);
}
+ return docked;
+}
+
+void LLFloater::applyPositioning(LLFloater* other, bool on_open)
+{
+ // Otherwise position according to the positioning code
+ switch (mPositioning)
+ {
+ case LLFloaterEnums::POSITIONING_CENTERED:
+ center();
+ break;
+
+ case LLFloaterEnums::POSITIONING_SPECIFIED:
+ break;
+
+ case LLFloaterEnums::POSITIONING_CASCADING:
+ if (!on_open)
+ {
+ applyRelativePosition();
+ }
+ // fall through
+ case LLFloaterEnums::POSITIONING_CASCADE_GROUP:
+ if (on_open)
+ {
+ if (other != NULL && other != this)
+ {
+ stackWith(*other);
+ }
+ else
+ {
+ static const U32 CASCADING_FLOATER_HOFFSET = 0;
+ static const U32 CASCADING_FLOATER_VOFFSET = 0;
+
+ const LLRect& snap_rect = gFloaterView->getSnapRect();
+
+ const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET;
+ const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET;
+
+ S32 rect_height = getRect().getHeight();
+ setOrigin(horizontal_offset, vertical_offset - rect_height);
+
+ translate(snap_rect.mLeft, snap_rect.mBottom);
+ }
+ setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+ }
+ break;
+
+ case LLFloaterEnums::POSITIONING_RELATIVE:
+ {
+ applyRelativePosition();
+
+ break;
+ }
+ default:
+ // Do nothing
+ break;
+ }
}
void LLFloater::applyTitle()
@@ -936,7 +1067,9 @@ BOOL LLFloater::canSnapTo(const LLView* other_view)
if (other_view != getParent())
{
const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view);
- if (other_floaterp && other_floaterp->getSnapTarget() == getHandle() && mDependents.find(other_floaterp->getHandle()) != mDependents.end())
+ if (other_floaterp
+ && other_floaterp->getSnapTarget() == getHandle()
+ && mDependents.find(other_floaterp->getHandle()) != mDependents.end())
{
// this is a dependent that is already snapped to us, so don't snap back to it
return FALSE;
@@ -968,6 +1101,14 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user)
const LLRect old_rect = getRect();
LLView::handleReshape(new_rect, by_user);
+ if (by_user && !isMinimized())
+ {
+ storeRectControl();
+ mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+ LLRect screen_rect = calcScreenRect();
+ mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+ }
+
// if not minimized, adjust all snapped dependents to new shape
if (!isMinimized())
{
@@ -1025,7 +1166,7 @@ void LLFloater::setMinimized(BOOL minimize)
if (minimize == mMinimized) return;
- if(mMinimizeSignal)
+ if (mMinimizeSignal)
{
(*mMinimizeSignal)(this, LLSD(minimize));
}
@@ -1057,10 +1198,6 @@ void LLFloater::setMinimized(BOOL minimize)
mButtonsEnabled[BUTTON_RESTORE] = TRUE;
}
- if (mDragHandle)
- {
- mDragHandle->setVisible(TRUE);
- }
setBorderVisible(TRUE);
for(handle_set_iter_t dependent_it = mDependents.begin();
@@ -1147,6 +1284,7 @@ void LLFloater::setMinimized(BOOL minimize)
// Reshape *after* setting mMinimized
reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE );
+ applyPositioning(NULL, false);
}
make_ui_sound("UISndWindowClose");
@@ -1211,19 +1349,9 @@ void LLFloater::setIsChrome(BOOL is_chrome)
mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome)));
}
- // no titles displayed on "chrome" floaters
- if (mDragHandle)
- mDragHandle->setTitleVisible(!is_chrome);
-
LLPanel::setIsChrome(is_chrome);
}
-void LLFloater::setTitleVisible(bool visible)
-{
- if (mDragHandle)
- mDragHandle->setTitleVisible(visible);
-}
-
// Change the draw style to account for the foreground state.
void LLFloater::setForeground(BOOL front)
{
@@ -1311,7 +1439,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)
@@ -1384,6 +1515,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);
@@ -1489,6 +1621,13 @@ void LLFloater::setDocked(bool docked, bool pop_on_undock)
{
mDocked = docked;
mButtonsEnabled[BUTTON_DOCK] = !mDocked;
+
+ if (mDocked)
+ {
+ setMinimized(FALSE);
+ mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+ }
+
updateTitleButtons();
storeDockStateControl();
@@ -1520,7 +1659,7 @@ void LLFloater::onClickTearOff(LLFloater* self)
self->openFloater(self->getKey());
// only force position for floaters that don't have that data saved
- if (self->mRectControl.size() <= 1)
+ if (self->mRectControl.empty())
{
new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight());
self->setRect(new_rect);
@@ -1572,18 +1711,19 @@ void LLFloater::onClickHelp( LLFloater* self )
LLFloater* LLFloater::getClosableFloaterFromFocus()
{
LLFloater* focused_floater = NULL;
-
- handle_map_iter_t iter;
- for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter)
+ LLInstanceTracker<LLFloater>::instance_iter it = beginInstances();
+ LLInstanceTracker<LLFloater>::instance_iter end_it = endInstances();
+ for (; it != end_it; ++it)
{
- focused_floater = iter->second;
- if (focused_floater->hasFocus())
+ if (it->hasFocus())
{
+ LLFloater& floater = *it;
+ focused_floater = &floater;
break;
}
}
- if (iter == sFloaterMap.end())
+ if (it == endInstances())
{
// nothing found, return
return NULL;
@@ -1698,7 +1838,7 @@ void LLFloater::draw()
const LLFontGL* font = LLFontGL::getFontSansSerif();
LLRect r = getRect();
- gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - (S32)font->getLineHeight() - 1,
+ gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - font->getLineHeight() - 1,
titlebar_focus_color % alpha, 0, TRUE);
}
}
@@ -1727,7 +1867,7 @@ void LLFloater::draw()
{
drawChild(mButtons[i]);
}
- drawChild(mDragHandle);
+ drawChild(mDragHandle, 0, 0, TRUE);
}
else
{
@@ -1844,6 +1984,12 @@ void LLFloater::setCanDrag(BOOL can_drag)
}
}
+bool LLFloater::getCanDrag()
+{
+ return mDragHandle->getEnabled();
+}
+
+
void LLFloater::updateTitleButtons()
{
static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
@@ -2048,25 +2194,20 @@ static LLDefaultChildRegistry::Register<LLFloaterView> r("floater_view");
LLFloaterView::LLFloaterView (const Params& p)
: LLUICtrl (p),
-
mFocusCycleMode(FALSE),
mMinimizePositionVOffset(0),
mSnapOffsetBottom(0),
mSnapOffsetRight(0)
{
+ mSnapView = getHandle();
}
// By default, adjust vertical.
void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent)
{
- reshapeFloater(width, height, called_from_parent, ADJUST_VERTICAL_YES);
-}
+ LLView::reshape(width, height, called_from_parent);
-// When reshaping this view, make the floaters follow their closest edge.
-void LLFloaterView::reshapeFloater(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical)
-{
- S32 old_width = getRect().getWidth();
- S32 old_height = getRect().getHeight();
+ mLastSnapRect = getSnapRect();
for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
{
@@ -2074,70 +2215,52 @@ void LLFloaterView::reshapeFloater(S32 width, S32 height, BOOL called_from_paren
LLFloater* floaterp = (LLFloater*)viewp;
if (floaterp->isDependent())
{
- // dependents use same follow flags as their "dependee"
+ // dependents are moved with their "dependee"
continue;
}
- // Make if follow the edge it is closest to
- U32 follow_flags = 0x0;
-
- if (floaterp->isMinimized())
+ if (!floaterp->isMinimized() && floaterp->getCanDrag())
{
- follow_flags |= (FOLLOWS_LEFT | FOLLOWS_TOP);
- }
- else
- {
- LLRect r = floaterp->getRect();
+ LLRect old_rect = floaterp->getRect();
+ floaterp->applyPositioning(NULL, false);
+ LLRect new_rect = floaterp->getRect();
- // Compute absolute distance from each edge of screen
- S32 left_offset = llabs(r.mLeft - 0);
- S32 right_offset = llabs(old_width - r.mRight);
+ //LLRect r = floaterp->getRect();
- S32 top_offset = llabs(old_height - r.mTop);
- S32 bottom_offset = llabs(r.mBottom - 0);
+ //// Compute absolute distance from each edge of screen
+ //S32 left_offset = llabs(r.mLeft - 0);
+ //S32 right_offset = llabs(old_right - r.mRight);
+ //S32 top_offset = llabs(old_top - r.mTop);
+ //S32 bottom_offset = llabs(r.mBottom - 0);
- if (left_offset < right_offset)
- {
- follow_flags |= FOLLOWS_LEFT;
- }
- else
- {
- follow_flags |= FOLLOWS_RIGHT;
- }
+ S32 translate_x = new_rect.mLeft - old_rect.mLeft;
+ S32 translate_y = new_rect.mBottom - old_rect.mBottom;
- // "No vertical adjustment" usually means that the bottom of the view
- // has been pushed up or down. Hence we want the floaters to follow
- // the top.
- if (!adjust_vertical)
- {
- follow_flags |= FOLLOWS_TOP;
- }
- else if (top_offset < bottom_offset)
- {
- follow_flags |= FOLLOWS_TOP;
- }
- else
- {
- follow_flags |= FOLLOWS_BOTTOM;
- }
- }
+ //if (left_offset > right_offset)
+ //{
+ // translate_x = new_right - old_right;
+ //}
- floaterp->setFollows(follow_flags);
+ //if (top_offset < bottom_offset)
+ //{
+ // translate_y = new_top - old_top;
+ //}
- //RN: all dependent floaters copy follow behavior of "parent"
- for(LLFloater::handle_set_iter_t dependent_it = floaterp->mDependents.begin();
- dependent_it != floaterp->mDependents.end(); ++dependent_it)
- {
- LLFloater* dependent_floaterp = dependent_it->get();
- if (dependent_floaterp)
+ // don't reposition immovable floaters
+ //if (floaterp->getCanDrag())
+ //{
+ // floaterp->translate(translate_x, translate_y);
+ //}
+ BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents)
{
- dependent_floaterp->setFollows(follow_flags);
+ if (dependent_floater.get())
+ {
+ dependent_floater.get()->translate(translate_x, translate_y);
+ }
}
}
}
-
- LLView::reshape(width, height, called_from_parent);
}
@@ -2458,6 +2581,52 @@ void LLFloaterView::closeAllChildren(bool app_quitting)
}
}
+void LLFloaterView::hiddenFloaterClosed(LLFloater* floater)
+{
+ for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
+ it != end_it;
+ ++it)
+ {
+ if (it->first.get() == floater)
+ {
+ it->second.disconnect();
+ mHiddenFloaters.erase(it);
+ break;
+ }
+ }
+}
+
+void LLFloaterView::hideAllFloaters()
+{
+ child_list_t child_list = *(getChildList());
+
+ for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it)
+ {
+ LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+ if (floaterp && floaterp->getVisible())
+ {
+ floaterp->setVisible(false);
+ boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp));
+ mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection));
+ }
+ }
+}
+
+void LLFloaterView::showHiddenFloaters()
+{
+ for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
+ it != end_it;
+ ++it)
+ {
+ LLFloater* floaterp = it->first.get();
+ if (floaterp)
+ {
+ floaterp->setVisible(true);
+ }
+ it->second.disconnect();
+ }
+ mHiddenFloaters.clear();
+}
BOOL LLFloaterView::allChildrenClosed()
{
@@ -2491,6 +2660,12 @@ void LLFloaterView::shiftFloaters(S32 x_offset, S32 y_offset)
void LLFloaterView::refresh()
{
+ LLRect snap_rect = getSnapRect();
+ if (snap_rect != mLastSnapRect)
+ {
+ reshape(getRect().getWidth(), getRect().getHeight(), TRUE);
+ }
+
// Constrain children to be entirely on the screen
for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
{
@@ -2503,6 +2678,8 @@ void LLFloaterView::refresh()
}
}
+const S32 FLOATER_MIN_VISIBLE_PIXELS = 16;
+
void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_outside)
{
if (floater->getParent() != this)
@@ -2556,7 +2733,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
}
// move window fully onscreen
- if (floater->translateIntoRect( getLocalRect(), allow_partial_outside ))
+ if (floater->translateIntoRect( getSnapRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX ))
{
floater->clearSnapTarget();
}
@@ -2770,9 +2947,11 @@ void LLFloater::setInstanceName(const std::string& name)
std::string ctrl_name = getControlName(mInstanceName, mKey);
// save_rect and save_visibility only apply to registered floaters
- if (!mRectControl.empty())
+ if (mSaveRect)
{
mRectControl = LLFloaterReg::declareRectControl(ctrl_name);
+ mPosXControl = LLFloaterReg::declarePosXControl(ctrl_name);
+ mPosYControl = LLFloaterReg::declarePosYControl(ctrl_name);
}
if (!mVisibilityControl.empty())
{
@@ -2782,7 +2961,6 @@ void LLFloater::setInstanceName(const std::string& name)
{
mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);
}
-
}
}
@@ -2829,6 +3007,12 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
// control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
LLPanel::initFromParams(p);
+ // override any follows flags
+ if (mPositioning != LLFloaterEnums::POSITIONING_SPECIFIED)
+ {
+ setFollows(FOLLOWS_NONE);
+ }
+
mTitle = p.title;
mShortTitle = p.short_title;
applyTitle();
@@ -2844,18 +3028,15 @@ 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;
+ mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance;
- if (p.save_rect)
- {
- mRectControl = "t"; // flag to build mRectControl name once mInstanceName is set
- }
+ mPositioning = p.positioning;
+
+ mSaveRect = p.save_rect;
if (p.save_visibility)
{
mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
}
-
if(p.save_dock_state)
{
mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set
@@ -2864,13 +3045,18 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
// open callback
if (p.open_callback.isProvided())
{
- mOpenSignal.connect(initCommitCallback(p.open_callback));
+ setOpenCallback(initCommitCallback(p.open_callback));
}
// close callback
if (p.close_callback.isProvided())
{
setCloseCallback(initCommitCallback(p.close_callback));
}
+
+ if (mDragHandle)
+ {
+ mDragHandle->setTitleVisible(p.show_title);
+ }
}
boost::signals2::connection LLFloater::setMinimizeCallback( const commit_signal_t::slot_type& cb )
@@ -2879,19 +3065,67 @@ boost::signals2::connection LLFloater::setMinimizeCallback( const commit_signal_
return mMinimizeSignal->connect(cb);
}
+boost::signals2::connection LLFloater::setOpenCallback( const commit_signal_t::slot_type& cb )
+{
+ return mOpenSignal.connect(cb);
+}
+
boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t::slot_type& cb )
{
return mCloseSignal.connect(cb);
}
LLFastTimer::DeclareTimer POST_BUILD("Floater Post Build");
+static LLFastTimer::DeclareTimer FTM_EXTERNAL_FLOATER_LOAD("Load Extern Floater Reference");
bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node)
{
- Params params(LLUICtrlFactory::getDefaultParams<LLFloater>());
+ Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>());
+ Params params(default_params);
+
LLXUIParser parser;
parser.readXUI(node, params, filename); // *TODO: Error checking
+ std::string xml_filename = params.filename;
+
+ if (!xml_filename.empty())
+ {
+ LLXMLNodePtr referenced_xml;
+
+ if (output_node)
+ {
+ //if we are exporting, we want to export the current xml
+ //not the referenced xml
+ Params output_params;
+ parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName());
+ setupParamsForExport(output_params, parent);
+ output_node->setName(node->getName()->mString);
+ parser.writeXUI(output_node, output_params, &default_params);
+ return TRUE;
+ }
+
+ LLUICtrlFactory::instance().pushFileName(xml_filename);
+
+ LLFastTimer _(FTM_EXTERNAL_FLOATER_LOAD);
+ if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
+ {
+ llwarns << "Couldn't parse panel from: " << xml_filename << llendl;
+
+ return FALSE;
+ }
+
+ Params referenced_params;
+ parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName());
+ params.fillFrom(referenced_params);
+
+ // add children using dimensions from referenced xml for consistent layout
+ setShape(params.rect);
+ LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());
+
+ LLUICtrlFactory::instance().popFileName();
+ }
+
+
if (output_node)
{
Params output_params(params);
@@ -2912,9 +3146,8 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str
{
params.rect.left.set(0);
}
-
params.from_xui = true;
- applyXUILayout(params, parent);
+ applyXUILayout(params, parent, parent == gFloaterView ? gFloaterView->getSnapRect() : parent->getLocalRect());
initFromParams(params);
initFloater(params);
@@ -3054,3 +3287,156 @@ bool LLFloater::buildFromFile(const std::string& filename, LLXMLNodePtr output_n
return res;
}
+
+void LLFloater::stackWith(LLFloater& other)
+{
+ static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16);
+
+ LLRect next_rect;
+ if (other.getHost())
+ {
+ next_rect = other.getHost()->getRect();
+ }
+ else
+ {
+ next_rect = other.getRect();
+ }
+ next_rect.translate(floater_offset, -floater_offset);
+
+ next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight());
+
+ setShape(next_rect);
+
+ other.mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
+ other.setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
+}
+
+void LLFloater::applyRelativePosition()
+{
+ LLRect snap_rect = gFloaterView->getSnapRect();
+ LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+ snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+ LLRect floater_screen_rect = calcScreenRect();
+
+ LLCoordGL new_center = mPosition.convert();
+ LLCoordGL cur_center(floater_screen_rect.getCenterX(), floater_screen_rect.getCenterY());
+ translate(new_center.mX - cur_center.mX, new_center.mY - cur_center.mY);
+}
+
+
+LLCoordFloater::LLCoordFloater(F32 x, F32 y, LLFloater& floater)
+: coord_t((S32)x, (S32)y)
+{
+ mFloater = floater.getHandle();
+}
+
+
+LLCoordFloater::LLCoordFloater(const LLCoordCommon& other, LLFloater& floater)
+{
+ mFloater = floater.getHandle();
+ convertFromCommon(other);
+}
+
+LLCoordFloater& LLCoordFloater::operator=(const LLCoordFloater& other)
+{
+ mFloater = other.mFloater;
+ coord_t::operator =(other);
+ return *this;
+}
+
+void LLCoordFloater::setFloater(LLFloater& floater)
+{
+ mFloater = floater.getHandle();
+}
+
+bool LLCoordFloater::operator==(const LLCoordFloater& other) const
+{
+ return mX == other.mX && mY == other.mY && mFloater == other.mFloater;
+}
+
+LLCoordCommon LL_COORD_FLOATER::convertToCommon() const
+{
+ const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
+
+ LLRect snap_rect = gFloaterView->getSnapRect();
+ LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+ snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+
+ LLFloater* floaterp = mFloater.get();
+ S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
+ S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
+ LLCoordCommon out;
+ if (self.mX < -0.5f)
+ {
+ out.mX = llround(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft));
+ }
+ else if (self.mX > 0.5f)
+ {
+ out.mX = llround(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS));
+ }
+ else
+ {
+ out.mX = llround(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width));
+ }
+
+ if (self.mY < -0.5f)
+ {
+ out.mY = llround(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom));
+ }
+ else if (self.mY > 0.5f)
+ {
+ out.mY = llround(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS));
+ }
+ else
+ {
+ out.mY = llround(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height));
+ }
+
+ // return center point instead of lower left
+ out.mX += floater_width / 2;
+ out.mY += floater_height / 2;
+
+ return out;
+}
+
+void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from)
+{
+ LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
+ LLRect snap_rect = gFloaterView->getSnapRect();
+ LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+ snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+
+
+ LLFloater* floaterp = mFloater.get();
+ S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
+ S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
+
+ S32 from_x = from.mX - floater_width / 2;
+ S32 from_y = from.mY - floater_height / 2;
+
+ if (from_x < snap_rect.mLeft)
+ {
+ self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f);
+ }
+ else if (from_x + floater_width > snap_rect.mRight)
+ {
+ self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
+ }
+ else
+ {
+ self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f);
+ }
+
+ if (from_y < snap_rect.mBottom)
+ {
+ self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f);
+ }
+ else if (from_y + floater_height > snap_rect.mTop)
+ {
+ self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
+ }
+ else
+ {
+ self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f);
+ }
+}