- Fix : tab visibility now updated without using revertLayout() which could alter the state of the active layout and was possibly causing repaint artifacts.

This commit is contained in:
spr
2013-09-07 04:26:58 +00:00
parent e18b3b3537
commit 35edfd936b
3 changed files with 429 additions and 428 deletions

View File

@@ -60,18 +60,6 @@ public final class DragCell extends JPanel implements ILocalRepaint {
public DragCell() {
super(new MigLayout("insets 0, gap 0, wrap 2"));
int borderT = SLayoutConstants.BORDER_T;
int headH = (showGameTabs() ? SLayoutConstants.HEAD_H : 0);
this.add(pnlHead,
"w 100% - " + borderT + "px!" + ", " + "h " + headH + "px!");
this.add(pnlBorderRight,
"w " + borderT + "px!" + ", " + "h 100% - " + borderT + "px!, span 1 2");
this.add(pnlBody,
"w 100% - " + borderT + "px!" + ", " + "h 100% - " + (headH + borderT) + "px!");
this.add(pnlBorderBottom,
"w 100% - " + borderT + "px!" + ", " + "h " + borderT + "px!");
this.setOpaque(false);
pnlHead.setOpaque(false);
@@ -99,6 +87,30 @@ public final class DragCell extends JPanel implements ILocalRepaint {
pnlHead.add(lblOverflow, "w 20px!, h 100%!, gap " + tabPaddingPx + "px " + tabPaddingPx + "px 0 0", -1);
pnlBody.setCornerDiameter(0);
doCellLayout(showGameTabs());
}
/**
* Refreshes the cell layout without affecting contents.
* <p>
* Primarily used to toggle visibility of tabs.
*/
public void doCellLayout(boolean showTabs) {
this.removeAll();
int borderT = SLayoutConstants.BORDER_T;
int headH = (showTabs ? SLayoutConstants.HEAD_H : 0);
this.add(pnlHead,
"w 100% - " + borderT + "px!" + ", " + "h " + headH + "px!");
this.add(pnlBorderRight,
"w " + borderT + "px!" + ", " + "h 100% - " + borderT + "px!, span 1 2");
this.add(pnlBody,
"w 100% - " + borderT + "px!" + ", " + "h 100% - " + (headH + borderT) + "px!");
this.add(pnlBorderBottom,
"w 100% - " + borderT + "px!" + ", " + "h " + borderT + "px!");
if (this.isShowing()) {
this.validate();
}
}
/**
@@ -333,24 +345,6 @@ public final class DragCell extends JPanel implements ILocalRepaint {
return docSelected;
}
/**
* Removes all components in this cell and
* rebuilds it without a header bar.
*/
public void hideHead() {
this.removeAll();
// These cause the cell to be "bumped" over...hopefully can
// just slice out? Doublestrike 18-09-12
// Looks good so far... Doublestrike 09-10-12
// this.add(pnlBorderRight, "w " + SLayoutConstants.BORDER_T + "px!, "
// + "h 100% - " + SLayoutConstants.BORDER_T + "px!, span 1 2");
this.add(pnlBody, "w 100% - " + SLayoutConstants.BORDER_T + "px!, "
+ "h 100% - " + SLayoutConstants.BORDER_T + "px!");
// this.add(pnlBorderBottom, "w 100% - " + SLayoutConstants.BORDER_T + "px!, "
// + "h " + SLayoutConstants.BORDER_T + "px!");
}
/**
* Enable/disable resize on the X axis for this cell.
*

View File

@@ -13,8 +13,8 @@ import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import forge.Singletons;
import forge.control.RestartUtil;
import forge.control.FControl.Screens;
import forge.control.RestartUtil;
import forge.gui.GuiChoose;
import forge.gui.match.controllers.CDock;
import forge.gui.menubar.MenuUtil;
@@ -148,8 +148,9 @@ public final class LayoutMenu {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
prefs.setPref(FPref.UI_HIDE_GAME_TABS, !menuItem.getState());
controller.revertLayout();
boolean showTabs = menuItem.getState();
FView.SINGLETON_INSTANCE.refreshAllCellLayouts(showTabs);
prefs.setPref(FPref.UI_HIDE_GAME_TABS, !showTabs);
}
};
}

View File

@@ -384,4 +384,10 @@ public enum FView {
VHomeUI.SINGLETON_INSTANCE.instantiate();
VDeckEditorUI.SINGLETON_INSTANCE.instantiate();
}
public void refreshAllCellLayouts(boolean showTabs) {
for (DragCell cell : allCells) {
cell.doCellLayout(showTabs);
}
}
}