mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Fix so menu bar not blanked out when changing skins and status message is retained
This commit is contained in:
@@ -114,7 +114,6 @@ public enum CHomeUI implements ICDoc, IMenuProvider {
|
||||
|
||||
private void setupMyMenuBar() {
|
||||
Singletons.getControl().getMenuBar().setupMenuBar(this);
|
||||
Singletons.getControl().getMenuBar().setStatusText("F1 : hide menu");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -14,21 +14,24 @@ import forge.gui.menus.ForgeMenu;
|
||||
import forge.gui.menus.HelpMenu;
|
||||
import forge.gui.menus.LayoutMenu;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.gui.toolbox.FSkin.JLabelSkin;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FMenuBar extends JMenuBar {
|
||||
|
||||
private JLabel statusCaption;
|
||||
private String statusText;
|
||||
private JLabel lblStatus;
|
||||
private IMenuProvider provider;
|
||||
|
||||
public FMenuBar(JFrame f) {
|
||||
f.setJMenuBar(this);
|
||||
setPreferredSize(new Dimension(f.getWidth(), 26));
|
||||
refresh();
|
||||
setStatusText(""); //set default status text
|
||||
}
|
||||
|
||||
public void setupMenuBar(IMenuProvider provider0) {
|
||||
this.provider = provider0;
|
||||
provider = provider0;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -38,25 +41,31 @@ public class FMenuBar extends JMenuBar {
|
||||
addProviderMenus();
|
||||
add(LayoutMenu.getMenu());
|
||||
add(HelpMenu.getMenu());
|
||||
setStatusCaption();
|
||||
repaint();
|
||||
addStatusLabel();
|
||||
revalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a label to the right-hand side of the MenuBar which can
|
||||
* be used to show hints or status information.
|
||||
*/
|
||||
private void setStatusCaption() {
|
||||
private void addStatusLabel() {
|
||||
add(Box.createHorizontalGlue()); // align right hack/patch.
|
||||
statusCaption = new JLabel();
|
||||
statusCaption.setForeground(getForeground());
|
||||
statusCaption.setFont(FSkin.getItalicFont(11));
|
||||
statusCaption.setOpaque(false);
|
||||
add(statusCaption);
|
||||
lblStatus = new JLabel(statusText);
|
||||
JLabelSkin<JLabel> labelSkin = FSkin.get(lblStatus);
|
||||
labelSkin.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
lblStatus.setFont(FSkin.getItalicFont(11));
|
||||
lblStatus.setOpaque(false);
|
||||
add(lblStatus);
|
||||
}
|
||||
|
||||
public void setStatusText(String text) {
|
||||
statusCaption.setText(text.trim() + " ");
|
||||
statusText = text.trim();
|
||||
if (statusText.isEmpty()) {
|
||||
statusText = "F1 : hide menu"; //show shortcut to hide menu if no other status to show
|
||||
}
|
||||
statusText += " "; //add padding from right edge of menu bar
|
||||
lblStatus.setText(statusText);
|
||||
}
|
||||
|
||||
private void addProviderMenus() {
|
||||
|
||||
Reference in New Issue
Block a user