BCardLayout: Do not recompute size limits on visible item switch.

The size limits are already the minimum/maximum for all views,
not just the current one, so we do not need to recompute them
when the layout is invalidated due to an item switch.

Fixes #14675, and other performance issues on switching tabs
in layouted BTabViews, among other things.

Change-Id: I55bfe4ddb8c8a79c634634cfc27113205a790c42
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2677
Reviewed-by: Andrew Lindesay <[email protected]>
This commit is contained in:
Augustin Cavalier
2020-05-11 00:41:52 +00:00
committed by waddlesplash
parent 81f3f1485d
commit 9cfe144326
+9 -3
View File
@@ -78,16 +78,20 @@ BCardLayout::SetVisibleItem(BLayoutItem* item)
return;
}
// Changing an item's visibility will invalidate its parent's layout (us),
// which would normally cause the min-max to be re-computed. But in this
// case, that is unnecessary, and so we can skip it.
const bool minMaxValid = fMinMaxValid;
if (fVisibleItem != NULL)
fVisibleItem->SetVisible(false);
fVisibleItem = item;
if (fVisibleItem != NULL) {
if (fVisibleItem != NULL)
fVisibleItem->SetVisible(true);
Relayout();
}
fMinMaxValid = minMaxValid;
}
@@ -274,6 +278,8 @@ BCardLayout::ItemAdded(BLayoutItem* item, int32 atIndex)
void
BCardLayout::ItemRemoved(BLayoutItem* item, int32 fromIndex)
{
fMinMaxValid = false;
if (fVisibleItem == item) {
BLayoutItem* newVisibleItem = NULL;
SetVisibleItem(newVisibleItem);