diff options
author | Don Kjer <don@lindenlab.com> | 2007-05-08 22:20:26 +0000 |
---|---|---|
committer | Don Kjer <don@lindenlab.com> | 2007-05-08 22:20:26 +0000 |
commit | a154ec72f759e20add6aacfab7f04e65b49051b9 (patch) | |
tree | 6410887f2466911a7a28574e7778d6fc7d416c67 /indra/llui | |
parent | 60a09f20f450ced238afc74e806d080b3c13cc33 (diff) |
svn merge -r 61343:61423 svn+ssh://svn/svn/linden/branches/maintenance into release
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lldraghandle.cpp | 14 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 79 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 3 |
3 files changed, 49 insertions, 47 deletions
diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index 25b41e44e1..e2974cd859 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -308,7 +308,12 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask) // Resize the parent S32 delta_x = screen_x - mDragLastScreenX; S32 delta_y = screen_y - mDragLastScreenY; - getParent()->translate(delta_x, delta_y); + + LLRect original_rect = getParent()->getRect(); + LLRect translated_rect = getParent()->getRect(); + translated_rect.translate(delta_x, delta_y); + // temporarily slam dragged window to new position + getParent()->setRect(translated_rect); S32 pre_snap_x = getParent()->getRect().mLeft; S32 pre_snap_y = getParent()->getRect().mBottom; mDragLastScreenX = screen_x; @@ -328,7 +333,12 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask) getParent()->snappedTo(snap_view); delta_x = new_rect.mLeft - pre_snap_x; delta_y = new_rect.mBottom - pre_snap_y; - getParent()->translate(delta_x, delta_y); + translated_rect.translate(delta_x, delta_y); + + // restore original rect so delta are detected, then call user reshape method to handle snapped floaters, etc + getParent()->setRect(original_rect); + getParent()->userSetShape(translated_rect); + mDragLastScreenX += delta_x; mDragLastScreenY += delta_y; diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 3da53275c7..fd8947c594 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -655,25 +655,6 @@ const LLString& LLFloater::getTitle() const return mDragHandle ? mDragHandle->getTitle() : LLString::null; } -void LLFloater::translate(S32 x, S32 y) -{ - LLPanel::translate(x, y); - - if (x != 0 || y != 0) - { - for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); ++dependent_it) - { - LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); - // is a dependent snapped to us? - if (floaterp && floaterp->getSnapTarget() == mViewHandle) - { - floaterp->translate(x, y); - } - } - } -} - BOOL LLFloater::canSnapTo(LLView* other_view) { if (NULL == other_view) @@ -711,14 +692,13 @@ void LLFloater::snappedTo(LLView* snap_view) } } -void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent) +void LLFloater::userSetShape(const LLRect& new_rect) { - S32 old_width = mRect.getWidth(); - S32 old_height = mRect.getHeight(); - - LLView::reshape(width, height, called_from_parent); + LLRect old_rect = mRect; + LLView::userSetShape(new_rect); - if (width != old_width || height != old_height) + // if not minimized, adjust all snapped dependents to new shape + if (!isMinimized()) { // gather all snapped dependents for(handle_set_iter_t dependent_it = mDependents.begin(); @@ -730,22 +710,27 @@ void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent) { S32 delta_x = 0; S32 delta_y = 0; - // check to see if it snapped to right or top - LLRect floater_rect = floaterp->getRect(); - if (floater_rect.mLeft - mRect.mLeft >= old_width || - floater_rect.mRight == mRect.mLeft + old_width) + // check to see if it snapped to right or top, and move if dependee floater is resizing + LLRect dependent_rect = floaterp->getRect(); + if (dependent_rect.mLeft - mRect.mLeft >= old_rect.getWidth() || // dependent on my right? + dependent_rect.mRight == mRect.mLeft + old_rect.getWidth()) // dependent aligned with my right { // was snapped directly onto right side or aligned with it - delta_x += width - old_width; + delta_x += new_rect.getWidth() - old_rect.getWidth(); } - if (floater_rect.mBottom - mRect.mBottom >= old_height || - floater_rect.mTop == mRect.mBottom + old_height) + if (dependent_rect.mBottom - mRect.mBottom >= old_rect.getHeight() || + dependent_rect.mTop == mRect.mBottom + old_rect.getHeight()) { // was snapped directly onto top side or aligned with it - delta_y += height - old_height; + delta_y += new_rect.getHeight() - old_rect.getHeight(); } - floaterp->translate(delta_x, delta_y); + // take translation of dependee floater into account as well + delta_x += new_rect.mLeft - old_rect.mLeft; + delta_y += new_rect.mBottom - old_rect.mBottom; + + dependent_rect.translate(delta_x, delta_y); + floaterp->userSetShape(dependent_rect); } } } @@ -792,28 +777,33 @@ void LLFloater::setMinimized(BOOL minimize) setBorderVisible(TRUE); for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); ) + dependent_it != mDependents.end(); + ++dependent_it) { LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); if (floaterp) { - floaterp->setVisible(FALSE); + if (floaterp->isMinimizeable()) + { + floaterp->setMinimized(TRUE); + } + else if (!floaterp->isMinimized()) + { + floaterp->setVisible(FALSE); + } } - ++dependent_it; } - mMinimized = TRUE; - // Lose keyboard focus when minimized releaseFocus(); + + mMinimized = TRUE; } else { reshape( mPreviousRect.getWidth(), mPreviousRect.getHeight(), TRUE ); setOrigin( mPreviousRect.mLeft, mPreviousRect.mBottom ); - mMinimized = FALSE; - if (mButtonsEnabled[BUTTON_RESTORE]) { mButtonsEnabled[BUTTON_MINIMIZE] = TRUE; @@ -837,15 +827,18 @@ void LLFloater::setMinimized(BOOL minimize) // show dependent floater for(handle_set_iter_t dependent_it = mDependents.begin(); - dependent_it != mDependents.end(); ) + dependent_it != mDependents.end(); + ++dependent_it) { LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); if (floaterp) { + floaterp->setMinimized(FALSE); floaterp->setVisible(TRUE); } - ++dependent_it; } + + mMinimized = FALSE; } make_ui_sound("UISndWindowClose"); updateButtons(); diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 79483db297..90063108f5 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -88,8 +88,7 @@ public: static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open = TRUE); - /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = 1); - /*virtual*/ void translate(S32 x, S32 y); + /*virtual*/ void userSetShape(const LLRect& new_rect); /*virtual*/ BOOL canSnapTo(LLView* other_view); /*virtual*/ void snappedTo(LLView* snap_view); /*virtual*/ void setFocus( BOOL b ); |