From f27ea1aff738f3222c782a7fac5b9172fc3cf67c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 7 Feb 2012 22:50:49 -0800 Subject: EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates fixed build moved conversion funcs to llwindow.cpp as they work on all platforms refactored translateintorect to take overlap as parameter --- indra/llui/llview.cpp | 69 +++++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 49 deletions(-) (limited to 'indra/llui/llview.cpp') diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 1a62fe75fc..d22e14745f 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -1616,59 +1616,30 @@ LLView* LLView::findNextSibling(LLView* child) } -LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, BOOL allow_partial_outside) +LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, S32 min_overlap_pixels) { LLCoordGL delta; - if (allow_partial_outside) - { - const S32 KEEP_ONSCREEN_PIXELS = 16; + const S32 KEEP_ONSCREEN_PIXELS_WIDTH = llmin(min_overlap_pixels, input.getWidth()); + const S32 KEEP_ONSCREEN_PIXELS_HEIGHT = llmin(min_overlap_pixels, input.getHeight()); - if( input.mRight - KEEP_ONSCREEN_PIXELS < constraint.mLeft ) - { - delta.mX = constraint.mLeft - (input.mRight - KEEP_ONSCREEN_PIXELS); - } - else - if( input.mLeft + KEEP_ONSCREEN_PIXELS > constraint.mRight ) - { - delta.mX = constraint.mRight - (input.mLeft + KEEP_ONSCREEN_PIXELS); - } + if( input.mRight - KEEP_ONSCREEN_PIXELS_WIDTH < constraint.mLeft ) + { + delta.mX = constraint.mLeft - (input.mRight - KEEP_ONSCREEN_PIXELS_WIDTH); + } + else if( input.mLeft + KEEP_ONSCREEN_PIXELS_WIDTH > constraint.mRight ) + { + delta.mX = constraint.mRight - (input.mLeft + KEEP_ONSCREEN_PIXELS_WIDTH); + } - if( input.mTop > constraint.mTop ) - { - delta.mY = constraint.mTop - input.mTop; - } - else - if( input.mTop - KEEP_ONSCREEN_PIXELS < constraint.mBottom ) - { - delta.mY = constraint.mBottom - (input.mTop - KEEP_ONSCREEN_PIXELS); - } + if( input.mTop > constraint.mTop ) + { + delta.mY = constraint.mTop - input.mTop; } else + if( input.mTop - KEEP_ONSCREEN_PIXELS_HEIGHT < constraint.mBottom ) { - if( input.mLeft < constraint.mLeft ) - { - delta.mX = constraint.mLeft - input.mLeft; - } - else - if( input.mRight > constraint.mRight ) - { - delta.mX = constraint.mRight - input.mRight; - // compensate for left edge possible going off screen - delta.mX += llmax( 0, input.getWidth() - constraint.getWidth() ); - } - - if( input.mTop > constraint.mTop ) - { - delta.mY = constraint.mTop - input.mTop; - } - else - if( input.mBottom < constraint.mBottom ) - { - delta.mY = constraint.mBottom - input.mBottom; - // compensate for top edge possible going off screen - delta.mY -= llmax( 0, input.getHeight() - constraint.getHeight() ); - } + delta.mY = constraint.mBottom - (input.mTop - KEEP_ONSCREEN_PIXELS_HEIGHT); } return delta; @@ -1677,9 +1648,9 @@ LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, BO // Moves the view so that it is entirely inside of constraint. // If the view will not fit because it's too big, aligns with the top and left. // (Why top and left? That's where the drag bars are for floaters.) -BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outside ) +BOOL LLView::translateIntoRect(const LLRect& constraint, S32 min_overlap_pixels) { - LLCoordGL translation = getNeededTranslation(getRect(), constraint, allow_partial_outside); + LLCoordGL translation = getNeededTranslation(getRect(), constraint, min_overlap_pixels); if (translation.mX != 0 || translation.mY != 0) { @@ -1691,9 +1662,9 @@ BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outs // move this view into "inside" but not onto "exclude" // NOTE: if this view is already contained in "inside", we ignore the "exclude" rect -BOOL LLView::translateIntoRectWithExclusion( const LLRect& inside, const LLRect& exclude, BOOL allow_partial_outside ) +BOOL LLView::translateIntoRectWithExclusion( const LLRect& inside, const LLRect& exclude, S32 min_overlap_pixels) { - LLCoordGL translation = getNeededTranslation(getRect(), inside, allow_partial_outside); + LLCoordGL translation = getNeededTranslation(getRect(), inside, min_overlap_pixels); if (translation.mX != 0 || translation.mY != 0) { -- cgit v1.2.3