Skip to content
Snippets Groups Projects
Commit 7e74481f authored by Gilbert Gonzales's avatar Gilbert Gonzales
Browse files

This does not pertain to a CHUI bug fix but Richard took a look at the...

This does not pertain to a CHUI bug fix but Richard took a look at the behavior of the layout stack test and found a mathematical bug that caused panels in a layout stack to jitter as they were resized. Submitting in this branch.
parent 4f6afb08
No related branches found
No related tags found
No related merge requests found
...@@ -672,12 +672,12 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -672,12 +672,12 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
S32 new_dim = (mOrientation == HORIZONTAL) S32 new_dim = (mOrientation == HORIZONTAL)
? new_rect.getWidth() ? new_rect.getWidth()
: new_rect.getHeight(); : new_rect.getHeight();
S32 delta_dim = new_dim - resized_panel->getVisibleDim(); S32 delta_panel_dim = new_dim - resized_panel->getVisibleDim();
if (delta_dim == 0) return; if (delta_panel_dim == 0) return;
F32 total_visible_fraction = 0.f; F32 total_visible_fraction = 0.f;
F32 delta_auto_resize_headroom = 0.f; F32 delta_auto_resize_headroom = 0.f;
F32 original_auto_resize_headroom = 0.f; F32 old_auto_resize_headroom = 0.f;
LLLayoutPanel* other_resize_panel = NULL; LLLayoutPanel* other_resize_panel = NULL;
LLLayoutPanel* following_panel = NULL; LLLayoutPanel* following_panel = NULL;
...@@ -686,7 +686,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -686,7 +686,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
{ {
if (panelp->mAutoResize) if (panelp->mAutoResize)
{ {
original_auto_resize_headroom += (F32)(panelp->mTargetDim - panelp->getRelevantMinDim()); old_auto_resize_headroom += (F32)(panelp->mTargetDim - panelp->getRelevantMinDim());
if (panelp->getVisible() && !panelp->mCollapsed) if (panelp->getVisible() && !panelp->mCollapsed)
{ {
total_visible_fraction += panelp->mFractionalSize; total_visible_fraction += panelp->mFractionalSize;
...@@ -704,25 +704,24 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -704,25 +704,24 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
} }
} }
if (resized_panel->mAutoResize) if (resized_panel->mAutoResize)
{ {
if (!other_resize_panel || !other_resize_panel->mAutoResize) if (!other_resize_panel || !other_resize_panel->mAutoResize)
{ {
delta_auto_resize_headroom += delta_dim; delta_auto_resize_headroom += delta_panel_dim;
} }
} }
else else
{ {
if (!other_resize_panel || other_resize_panel->mAutoResize) if (!other_resize_panel || other_resize_panel->mAutoResize)
{ {
delta_auto_resize_headroom -= delta_dim; delta_auto_resize_headroom -= delta_panel_dim;
} }
} }
F32 fraction_given_up = 0.f; F32 fraction_given_up = 0.f;
F32 fraction_remaining = 1.f; F32 fraction_remaining = 1.f;
F32 updated_auto_resize_headroom = original_auto_resize_headroom + delta_auto_resize_headroom; F32 new_auto_resize_headroom = old_auto_resize_headroom + delta_auto_resize_headroom;
enum enum
{ {
...@@ -734,7 +733,14 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -734,7 +733,14 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
BOOST_FOREACH(LLLayoutPanel* panelp, mPanels) BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
{ {
if (!panelp->getVisible() || panelp->mCollapsed) continue; if (!panelp->getVisible() || panelp->mCollapsed)
{
if (panelp->mAutoResize)
{
fraction_remaining -= panelp->mFractionalSize;
}
continue;
}
if (panelp == resized_panel) if (panelp == resized_panel)
{ {
...@@ -746,9 +752,9 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -746,9 +752,9 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
case BEFORE_RESIZED_PANEL: case BEFORE_RESIZED_PANEL:
if (panelp->mAutoResize) if (panelp->mAutoResize)
{ // freeze current size as fraction of overall auto_resize space { // freeze current size as fraction of overall auto_resize space
F32 fractional_adjustment_factor = updated_auto_resize_headroom == 0.f F32 fractional_adjustment_factor = new_auto_resize_headroom == 0.f
? 1.f ? 1.f
: original_auto_resize_headroom / updated_auto_resize_headroom; : old_auto_resize_headroom / new_auto_resize_headroom;
F32 new_fractional_size = llclamp(panelp->mFractionalSize * fractional_adjustment_factor, F32 new_fractional_size = llclamp(panelp->mFractionalSize * fractional_adjustment_factor,
MIN_FRACTIONAL_SIZE, MIN_FRACTIONAL_SIZE,
MAX_FRACTIONAL_SIZE); MAX_FRACTIONAL_SIZE);
...@@ -765,9 +771,9 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -765,9 +771,9 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
case RESIZED_PANEL: case RESIZED_PANEL:
if (panelp->mAutoResize) if (panelp->mAutoResize)
{ // freeze new size as fraction { // freeze new size as fraction
F32 new_fractional_size = (updated_auto_resize_headroom == 0.f) F32 new_fractional_size = (new_auto_resize_headroom == 0.f)
? MAX_FRACTIONAL_SIZE ? MAX_FRACTIONAL_SIZE
: llclamp(total_visible_fraction * (F32)(new_dim - panelp->getRelevantMinDim()) / updated_auto_resize_headroom, MIN_FRACTIONAL_SIZE, MAX_FRACTIONAL_SIZE); : llclamp(total_visible_fraction * (F32)(new_dim - panelp->getRelevantMinDim()) / new_auto_resize_headroom, MIN_FRACTIONAL_SIZE, MAX_FRACTIONAL_SIZE);
fraction_given_up -= new_fractional_size - panelp->mFractionalSize; fraction_given_up -= new_fractional_size - panelp->mFractionalSize;
fraction_remaining -= panelp->mFractionalSize; fraction_remaining -= panelp->mFractionalSize;
panelp->mFractionalSize = new_fractional_size; panelp->mFractionalSize = new_fractional_size;
...@@ -791,7 +797,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -791,7 +797,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
else else
{ {
F32 new_fractional_size = llclamp(total_visible_fraction * (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, / new_auto_resize_headroom,
MIN_FRACTIONAL_SIZE, MIN_FRACTIONAL_SIZE,
MAX_FRACTIONAL_SIZE); MAX_FRACTIONAL_SIZE);
fraction_given_up -= new_fractional_size - panelp->mFractionalSize; fraction_given_up -= new_fractional_size - panelp->mFractionalSize;
...@@ -800,7 +806,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -800,7 +806,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
} }
else else
{ {
panelp->mTargetDim -= delta_dim; panelp->mTargetDim -= delta_panel_dim;
} }
which_panel = AFTER_RESIZED_PANEL; which_panel = AFTER_RESIZED_PANEL;
break; break;
...@@ -816,7 +822,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect& ...@@ -816,7 +822,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
} }
} }
updateLayout(); updateLayout();
normalizeFractionalSizes(); //normalizeFractionalSizes();
} }
void LLLayoutStack::reshape(S32 width, S32 height, BOOL called_from_parent) void LLLayoutStack::reshape(S32 width, S32 height, BOOL called_from_parent)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment