mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Use new backdrop panel behind FDialog that's more transparent than overlay panel
This commit is contained in:
@@ -24,6 +24,7 @@ Title field and buttons now available on Current Deck pane when on other section
|
||||
- More skinned dialogs -
|
||||
Most remaining dialogs are now skinned, including all message, confirmation, input, and list choice dialogs
|
||||
Reveal-style list dialogs now focus OK button by default and support Escape and Close button without showing a Cancel button
|
||||
Increased transparency of backdrop behind dialogs
|
||||
|
||||
|
||||
- Constructed mode -
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.swing.JPanel;
|
||||
import forge.gui.FNetOverlay;
|
||||
import forge.gui.toolbox.FAbsolutePositioner;
|
||||
import forge.gui.toolbox.FOverlay;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.FFrame;
|
||||
import forge.view.FNavigationBar;
|
||||
import forge.view.FView;
|
||||
@@ -135,6 +136,7 @@ public final class SResizingUtil {
|
||||
FAbsolutePositioner.SINGLETON_INSTANCE.containerResized(mainBounds);
|
||||
FOverlay.SINGLETON_INSTANCE.getPanel().setBounds(mainBounds);
|
||||
FNetOverlay.SINGLETON_INSTANCE.containerResized(mainBounds);
|
||||
FDialog.getBackdropPanel().setBounds(mainBounds);
|
||||
|
||||
pnlInsets.setBounds(mainBounds);
|
||||
pnlInsets.validate();
|
||||
|
||||
@@ -27,17 +27,19 @@ import java.awt.geom.RoundRectangle2D;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.Singletons;
|
||||
import forge.gui.toolbox.FPanel;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.gui.toolbox.FSkin.SkinColor;
|
||||
import forge.util.OperatingSystem;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FDialog extends JDialog implements ITitleBarOwner, KeyEventDispatcher {
|
||||
private static final FSkin.SkinColor borderColor = FSkin.getColor(FSkin.Colors.CLR_BORDERS);
|
||||
private static final SkinColor borderColor = FSkin.getColor(FSkin.Colors.CLR_BORDERS);
|
||||
private static final int cornerDiameter = 20;
|
||||
private static final boolean isSetShapeSupported;
|
||||
private static final boolean antiAliasBorder;
|
||||
@@ -150,13 +152,15 @@ public class FDialog extends JDialog implements ITitleBarOwner, KeyEventDispatch
|
||||
setLocationRelativeTo(JOptionPane.getRootFrame());
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this); //support handling keyboard shortcuts in dialog
|
||||
if (isModal()) {
|
||||
SOverlayUtils.showOverlay();
|
||||
backdropPanel.setVisible(true);
|
||||
Singletons.getView().getNavigationBar().setMenuShortcutsEnabled(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
|
||||
if (isModal()) {
|
||||
SOverlayUtils.hideOverlay();
|
||||
backdropPanel.setVisible(false);
|
||||
Singletons.getView().getNavigationBar().setMenuShortcutsEnabled(true);
|
||||
}
|
||||
}
|
||||
super.setVisible(visible);
|
||||
@@ -314,4 +318,29 @@ public class FDialog extends JDialog implements ITitleBarOwner, KeyEventDispatch
|
||||
public Image getIconImage() {
|
||||
return getIconImages().isEmpty() ? null : getIconImages().get(0);
|
||||
}
|
||||
|
||||
private static final BackdropPanel backdropPanel = new BackdropPanel();
|
||||
|
||||
public static JPanel getBackdropPanel() {
|
||||
return backdropPanel;
|
||||
}
|
||||
|
||||
private static class BackdropPanel extends JPanel {
|
||||
private static final SkinColor backColor = FSkin.getColor(FSkin.Colors.CLR_OVERLAY).alphaColor(120);
|
||||
|
||||
private FSkin.JComponentSkin<BackdropPanel> skin = FSkin.get(this);
|
||||
|
||||
private BackdropPanel() {
|
||||
setOpaque(false);
|
||||
setVisible(false);
|
||||
setFocusable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(final Graphics g) {
|
||||
super.paintComponent(g);
|
||||
skin.setGraphicsColor(g, backColor);
|
||||
g.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,11 +303,15 @@ public class FNavigationBar extends FTitleBarBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setMenuShortcutsEnabled(boolean enabled0) {
|
||||
forgeMenu.getPopupMenu().setEnabled(enabled0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled0) {
|
||||
btnForge.setEnabled(enabled0);
|
||||
forgeMenu.getPopupMenu().setEnabled(enabled0);
|
||||
setMenuShortcutsEnabled(enabled0);
|
||||
for (NavigationTab tab : tabs) {
|
||||
tab.setEnabled(enabled0);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public enum FView {
|
||||
lpnDocument.add(navigationBar, NAVIGATION_BAR_LAYER);
|
||||
lpnDocument.add(navigationBar.getPnlReveal(), NAVIGATION_BAR_REVEAL_LAYER);
|
||||
lpnDocument.add(FOverlay.SINGLETON_INSTANCE.getPanel(), OVERLAY_LAYER);
|
||||
lpnDocument.add(FDialog.getBackdropPanel(), OVERLAY_LAYER);
|
||||
// Note: when adding new panels here, keep in mind that the layered pane
|
||||
// has a null layout, so new components will be W0 x H0 pixels - gotcha!
|
||||
// FControl has a method called "sizeComponents" which will fix this.
|
||||
|
||||
Reference in New Issue
Block a user