diff options
Diffstat (limited to 'indra/llui/lllayoutstack.cpp')
-rw-r--r-- | indra/llui/lllayoutstack.cpp | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 2f1c2a47c9..31e0434753 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -36,7 +36,7 @@ #include "llcriticaldamp.h" #include "boost/foreach.hpp" -static const F32 MIN_FRACTIONAL_SIZE = 0.0001f; +static const F32 MIN_FRACTIONAL_SIZE = 0.0f; static const F32 MAX_FRACTIONAL_SIZE = 1.f; static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack"); @@ -129,6 +129,12 @@ void LLLayoutPanel::setOrientation( LLLayoutStack::ELayoutOrientation orientatio ? getRect().getWidth() : getRect().getHeight())); + if (mAutoResize == FALSE + && mUserResize == TRUE + && mMinDim == -1 ) + { + setMinDim(layout_dim); + } mTargetDim = llmax(layout_dim, getMinDim()); } @@ -246,7 +252,7 @@ void LLLayoutStack::removeChild(LLView* view) { mPanels.erase(std::find(mPanels.begin(), mPanels.end(), embedded_panelp)); delete embedded_panelp; - updateFractionalSizes(); + normalizeFractionalSizes(); mNeedsLayout = true; } @@ -271,7 +277,7 @@ bool LLLayoutStack::addChild(LLView* child, S32 tab_group) } BOOL result = LLView::addChild(child, tab_group); - updateFractionalSizes(); + normalizeFractionalSizes(); return result; } @@ -306,7 +312,6 @@ void LLLayoutStack::updateLayout() bool animation_in_progress = animatePanels(); F32 total_visible_fraction = 0.f; - F32 total_open_fraction = 0.f; S32 space_to_distribute = (mOrientation == HORIZONTAL) ? getRect().getWidth() : getRect().getHeight(); @@ -318,20 +323,17 @@ void LLLayoutStack::updateLayout() if (panelp->mAutoResize) { panelp->mTargetDim = panelp->getRelevantMinDim(); - if (!panelp->mCollapsed && panelp->getVisible()) - { - total_open_fraction += panelp->mFractionalSize; - } } space_to_distribute -= panelp->getVisibleDim() + llround((F32)mPanelSpacing * panelp->getVisibleAmount()); - total_visible_fraction += panelp->mFractionalSize; + total_visible_fraction += panelp->mFractionalSize * panelp->getAutoResizeFactor(); } - llassert(total_visible_fraction < 1.01f); + llassert(total_visible_fraction < 1.05f); // don't need spacing after last panel space_to_distribute += panelp ? llround((F32)mPanelSpacing * panelp->getVisibleAmount()) : 0; + S32 remaining_space = space_to_distribute; F32 fraction_distributed = 0.f; if (space_to_distribute > 0 && total_visible_fraction > 0.f) { // give space proportionally to visible auto resize panels @@ -343,26 +345,23 @@ void LLLayoutStack::updateLayout() S32 delta = llround((F32)space_to_distribute * fraction_to_distribute); fraction_distributed += fraction_to_distribute; panelp->mTargetDim += delta; + remaining_space -= delta; } } } - if (fraction_distributed < total_visible_fraction) - { // distribute any left over pixels to non-collapsed, visible panels - F32 fraction_left = total_visible_fraction - fraction_distributed; - S32 space_left = llround((F32)space_to_distribute * (fraction_left / total_visible_fraction)); + // distribute any left over pixels to non-collapsed, visible panels + BOOST_FOREACH(LLLayoutPanel* panelp, mPanels) + { + if (remaining_space == 0) break; - BOOST_FOREACH(LLLayoutPanel* panelp, mPanels) + if (panelp->mAutoResize + && !panelp->mCollapsed + && panelp->getVisible()) { - if (panelp->mAutoResize - && !panelp->mCollapsed - && panelp->getVisible()) - { - S32 space_for_panel = llmax(0, llround((F32)space_left * (panelp->mFractionalSize / total_open_fraction))); - panelp->mTargetDim += space_for_panel; - space_left -= space_for_panel; - total_open_fraction -= panelp->mFractionalSize; - } + S32 space_for_panel = remaining_space > 0 ? 1 : -1; + panelp->mTargetDim += space_for_panel; + remaining_space -= space_for_panel; } } @@ -492,7 +491,7 @@ void LLLayoutStack::updateClass() } } -void LLLayoutStack::updateFractionalSizes() +void LLLayoutStack::normalizeFractionalSizes() { F32 total_resizable_dim = 0; S32 num_auto_resize_panels = 0; @@ -691,7 +690,9 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& case BEFORE_RESIZED_PANEL: if (panelp->mAutoResize) { // freeze current size as fraction of overall auto_resize space - F32 fractional_adjustment_factor = total_auto_resize_headroom / updated_auto_resize_headroom; + F32 fractional_adjustment_factor = updated_auto_resize_headroom == 0.f + ? 1.f + : total_auto_resize_headroom / updated_auto_resize_headroom; F32 new_fractional_size = llclamp(panelp->mFractionalSize * fractional_adjustment_factor, MIN_FRACTIONAL_SIZE, MAX_FRACTIONAL_SIZE); @@ -711,7 +712,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& { // freeze new size as fraction F32 new_fractional_size = (updated_auto_resize_headroom == 0.f) ? MAX_FRACTIONAL_SIZE - : llclamp((F32)(new_dim - panelp->getRelevantMinDim()) / updated_auto_resize_headroom, MIN_FRACTIONAL_SIZE, MAX_FRACTIONAL_SIZE); + : llclamp(total_visible_fraction * (F32)(new_dim - panelp->getRelevantMinDim()) / updated_auto_resize_headroom, MIN_FRACTIONAL_SIZE, MAX_FRACTIONAL_SIZE); fraction_given_up -= new_fractional_size - panelp->mFractionalSize; fraction_remaining -= panelp->mFractionalSize; panelp->mFractionalSize = new_fractional_size; @@ -720,7 +721,6 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& else { // freeze new size as original size panelp->mTargetDim = new_dim; - fraction_remaining -= fraction_given_up; } which_panel = NEXT_PANEL; break; @@ -728,14 +728,14 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& if (panelp->mAutoResize) { fraction_remaining -= panelp->mFractionalSize; - if (fraction_given_up != 0.f) + if (resized_panel->mAutoResize) { panelp->mFractionalSize = llclamp(panelp->mFractionalSize + fraction_given_up, MIN_FRACTIONAL_SIZE, MAX_FRACTIONAL_SIZE); fraction_given_up = 0.f; } else { - F32 new_fractional_size = llclamp((F32)(panelp->mTargetDim - panelp->getRelevantMinDim() + delta_auto_resize_headroom) + F32 new_fractional_size = llclamp(total_visible_fraction * (F32)(panelp->mTargetDim - panelp->getRelevantMinDim() + delta_auto_resize_headroom) / updated_auto_resize_headroom, MIN_FRACTIONAL_SIZE, MAX_FRACTIONAL_SIZE); @@ -750,7 +750,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& which_panel = AFTER_RESIZED_PANEL; break; case AFTER_RESIZED_PANEL: - if (panelp->mAutoResize) + if (panelp->mAutoResize && fraction_given_up != 0.f) { panelp->mFractionalSize = llclamp(panelp->mFractionalSize + (panelp->mFractionalSize / fraction_remaining) * fraction_given_up, MIN_FRACTIONAL_SIZE, @@ -760,6 +760,8 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& break; } } + updateLayout(); + normalizeFractionalSizes(); } void LLLayoutStack::reshape(S32 width, S32 height, BOOL called_from_parent) |