ChangeScreen2: Fix bouncing Files header

When related changes is configured ChangeScreen2 supplies the max
height before the tab headers are visible.  This causes the header
to be computed with 0px height, offering all space to the tab body.
Later when the tabs are populated they use too much vertical space,
as the header was not subtracted.

Store the maximum height and apply it to the tabs only after the
header is visible and its own height can be computed.

Change-Id: Idbabd14df8b84d6d9c67b3cb6a0e1ecf1c38ae7b
This commit is contained in:
Shawn Pearce
2013-12-07 10:51:27 -08:00
committed by Colby Ranger
parent d7f80ca621
commit 0f8085cf73

View File

@@ -106,8 +106,9 @@ public class RelatedChanges extends TabPanel {
}
private final List<RelatedChangesTab> tabs;
private int maxHeight;
private int maxHeightWithHeader;
private int selectedTab;
private int outstandingCallbacks;
RelatedChanges() {
tabs = new ArrayList<RelatedChangesTab>(Tab.values().length);
@@ -133,7 +134,6 @@ public class RelatedChanges extends TabPanel {
for (Tab tabInfo : Tab.values()) {
RelatedChangesTab panel = new RelatedChangesTab();
panel.setMaxHeight(maxHeight);
add(panel, tabInfo.defaultTitle);
tabs.add(panel);
@@ -205,13 +205,18 @@ public class RelatedChanges extends TabPanel {
}
void setMaxHeight(int height) {
maxHeight = height - (getTabBar().getOffsetHeight() + 2 /* padding */);
for (int i = 0; i < getTabBar().getTabCount(); i++) {
tabs.get(i).setMaxHeight(maxHeight);
maxHeightWithHeader = height;
if (isVisible()) {
applyMaxHeight();
}
}
private int outstandingCallbacks;
private void applyMaxHeight() {
int header = getTabBar().getOffsetHeight() + 2 /* padding */;
for (int i = 0; i < getTabBar().getTabCount(); i++) {
tabs.get(i).setMaxHeight(maxHeightWithHeader - header);
}
}
private abstract class TabCallback<T> implements AsyncCallback<T> {
private final Tab tabInfo;
@@ -253,6 +258,7 @@ public class RelatedChanges extends TabPanel {
if (getTabBar().isTabEnabled(i)) {
selectTab(i);
setVisible(true);
applyMaxHeight();
break;
}
}