Skip to content

Commit

Permalink
Some more changes to GUI to better support high screen resolutions.
Browse files Browse the repository at this point in the history
  • Loading branch information
LevelX2 committed Feb 12, 2016
1 parent 2ce5e00 commit 706d319
Show file tree
Hide file tree
Showing 25 changed files with 370 additions and 223 deletions.
32 changes: 14 additions & 18 deletions Mage.Client/src/main/java/mage/client/MageFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import mage.client.dialog.ErrorDialog;
import mage.client.dialog.FeedbackDialog;
import mage.client.dialog.GameEndDialog;
import mage.client.dialog.MageDialog;
import mage.client.dialog.PreferencesDialog;
import mage.client.dialog.TableWaitingDialog;
import mage.client.dialog.UserRequestDialog;
Expand Down Expand Up @@ -237,7 +238,7 @@ public void windowClosing(WindowEvent e) {
try {
UIManager.put("desktop", new Color(0, 0, 0, 0));
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
FontSizeHelper.setGUISize();
FontSizeHelper.calculateGUISizes();
// Change default font and row size for JTables
Font font = FontSizeHelper.getTableFont();
UIManager.put("Table.font", font);
Expand Down Expand Up @@ -1406,29 +1407,24 @@ public void processCallback(ClientCallback callback) {

public void changeGUISize() {
setGUISize();
for (Component component : desktopPane.getComponents()) {
if (component instanceof MageDialog) {
((MageDialog) component).changeGUISize();
}
if (component instanceof MagePane) {
((MagePane) component).changeGUISize();
}
}
Font font = FontSizeHelper.getChatFont();
for (ChatPanelBasic chatPanel : getChatPanels().values()) {
chatPanel.changeGUISize(font);
}
this.revalidate();
this.repaint();
}

private void setGUISize() {
Font font = FontSizeHelper.getToolbarFont();
// Tables
if (tablesPane != null) {
tablesPane.changeGUISize();
}
// Deck editor
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
for (JInternalFrame window : windows) {
if (window instanceof DeckEditorPane) {
((DeckEditorPane) window).getPanel().changeGUISize();
}
}
// Tournament panels
for (Component component : desktopPane.getComponents()) {
if (component instanceof TournamentPane) {
((TournamentPane) component).changeGUISize();
}
}
mageToolbar.setFont(font);
int newHeight = font.getSize() + 6;
Dimension mageToolbarDimension = mageToolbar.getPreferredSize();
Expand Down
7 changes: 4 additions & 3 deletions Mage.Client/src/main/java/mage/client/MagePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@
import java.beans.PropertyVetoException;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import org.apache.log4j.Logger;

/**
*
* @author BetaSteward_at_googlemail.com
*/
public abstract class MagePane extends javax.swing.JInternalFrame {

private static final Logger LOGGER = Logger.getLogger(MagePane.class);

/**
* Creates new form MagePane
*/
Expand All @@ -62,6 +59,10 @@ private void hideTitle() {
}
}

public void changeGUISize() {

}

@Override
public void updateUI() {
super.updateUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public DeckEditorPane() {
}
}

@Override
public void changeGUISize() {
super.changeGUISize();
deckEditorPanel1.changeGUISize();
}

public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) {
if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) {
this.setTitle("Deck Editor - " + tableId.toString());
Expand Down
38 changes: 20 additions & 18 deletions Mage.Client/src/main/java/mage/client/dialog/MageDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com.
*/

/*
/*
* MageDialog.java
*
* Created on 15-Dec-2009, 10:28:27 PM
Expand Down Expand Up @@ -56,7 +56,7 @@
*/
public class MageDialog extends javax.swing.JInternalFrame {

private static final Logger logger = Logger.getLogger(MageDialog.class);
private static final Logger LOGGER = Logger.getLogger(MageDialog.class);

protected boolean modal = false;

Expand All @@ -67,6 +67,10 @@ public MageDialog() {
initComponents();
}

public void changeGUISize() {

}

@Override
public void show() {
super.show();
Expand All @@ -89,22 +93,20 @@ public void setVisible(boolean value) {
this.setClosable(false);
if (value) {
startModal();
} else if (SwingUtilities.isEventDispatchThread()) {
stopModal();
} else {
if (SwingUtilities.isEventDispatchThread()) {
stopModal();
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
stopModal();
}
});
} catch (InterruptedException ex) {
logger.fatal("MageDialog error", ex);
} catch (InvocationTargetException ex) {
logger.fatal("MageDialog error", ex);
}
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
stopModal();
}
});
} catch (InterruptedException ex) {
LOGGER.fatal("MageDialog error", ex);
} catch (InvocationTargetException ex) {
LOGGER.fatal("MageDialog error", ex);
}
}
}
Expand Down Expand Up @@ -140,7 +142,7 @@ private synchronized void startModal() {
} else if (source instanceof MenuComponent) {
((MenuComponent) source).dispatchEvent(event);
} else {
logger.warn("Unable to dispatch: " + event);
LOGGER.warn("Unable to dispatch: " + event);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
</Component>
<Component class="javax.swing.JSlider" name="sliderFontSize">
<Properties>
<Property name="majorTickSpacing" type="int" value="10"/>
<Property name="majorTickSpacing" type="int" value="5"/>
<Property name="maximum" type="int" value="50"/>
<Property name="minimum" type="int" value="10"/>
<Property name="minorTickSpacing" type="int" value="1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
fontSizeLabel.setText("Size");
fontSizeLabel.setToolTipText("<HTML>The size of the font used to display text.");
guiSize_font.add(fontSizeLabel, java.awt.BorderLayout.CENTER);
fontSizeLabel.getAccessibleContext().setAccessibleName("Size");

sliderFontSize.setMajorTickSpacing(10);
sliderFontSize.setMajorTickSpacing(5);
sliderFontSize.setMaximum(50);
sliderFontSize.setMinimum(10);
sliderFontSize.setMinorTickSpacing(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
package mage.client.dialog;

import java.awt.Dimension;
import java.awt.Font;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CancellationException;
Expand All @@ -46,6 +48,7 @@
import mage.client.components.tray.MageTray;
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
import mage.client.util.FontSizeHelper;
import mage.client.util.audio.AudioManager;
import mage.client.util.gui.TableUtil;
import mage.client.util.gui.countryBox.CountryCellRenderer;
Expand Down Expand Up @@ -90,10 +93,25 @@ public TableWaitingDialog() {
tableSeats.createDefaultColumnsFromModel();
TableUtil.setColumnWidthAndOrder(tableSeats, DEFAULT_COLUMS_WIDTH, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER);
tableSeats.setDefaultRenderer(Icon.class, new CountryCellRenderer());
setGUISize();

MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
}

public void changeGUISize() {
setGUISize();
}

private void setGUISize() {
Font font = FontSizeHelper.getTableFont();
tableSeats.getTableHeader().setFont(font);
tableSeats.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));

jSplitPane1.setDividerSize(FontSizeHelper.dividerBarSize);
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(FontSizeHelper.scrollBarSize, 0));
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, FontSizeHelper.scrollBarSize));
}

public void update(TableView table) {
try {
if (table != null) {
Expand Down
Loading

0 comments on commit 706d319

Please sign in to comment.