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 <apl@lindesay.co.nz>
(cherry picked from commit 9cfe1443266e511b0a9fe9c8514655f280cf1b63)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2678
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Augustin Cavalier 2020-05-10 17:48:50 -04:00 committed by waddlesplash
parent 0742e87e45
commit 76e8ce1d8b

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);