make font sizes relative to default (12)

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
Jamin W. Collins
2018-09-24 17:29:42 -06:00
parent e6af6abfcf
commit 7781660c11
30 changed files with 80 additions and 51 deletions

View File

@@ -20,7 +20,7 @@ public class DecksComboBox extends FComboBoxWrapper<DeckType> {
private DeckType selectedDeckType = null;
public DecksComboBox() {
setSkinFont(FSkin.getBoldFont(14));
setSkinFont(FSkin.getRelativeBoldFont(14));
setTextAlignment(TextAlignment.CENTER);
addActionListener(getDeckTypeComboListener());
}

View File

@@ -90,7 +90,7 @@ public class GuiDownloader extends DefaultBoundedRangeModel {
radProxyNone.setSelected(true);
btnClose.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_TEXT)));
btnStart.setFont(FSkin.getFont(18));
btnStart.setFont(FSkin.getRelativeFont(18));
btnStart.setEnabled(false);
progressBar.reset();

View File

@@ -27,7 +27,7 @@ public abstract class ItemFilter<T extends InventoryItem> {
public static void layoutCheckbox(SkinnedCheckBox cb) {
cb.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
cb.setFont(FSkin.getFont(12));
cb.setFont(FSkin.getFont());
cb.setOpaque(false);
cb.setFocusable(false);
}

View File

@@ -63,7 +63,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
private static final float PILE_SPACING_Y = 0.1f;
private static final SkinColor GROUP_HEADER_FORE_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT);
private static final SkinColor GROUP_HEADER_LINE_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(120);
private static final SkinFont GROUP_HEADER_FONT = FSkin.getFont(12);
private static final SkinFont GROUP_HEADER_FONT = FSkin.getFont();
private static final int GROUP_HEADER_HEIGHT = 19;
private static final int GROUP_HEADER_GLYPH_WIDTH = 6;
private static final int MIN_COLUMN_COUNT = 1;

View File

@@ -103,7 +103,7 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
static final SkinColor ALT_ROW_COLOR = BACK_COLOR.getContrastColor(-20);
private static final SkinColor GRID_COLOR = BACK_COLOR.getContrastColor(20);
private static final SkinBorder HEADER_BORDER = new FSkin.CompoundSkinBorder(new FSkin.MatteSkinBorder(0, 0, 1, 1, GRID_COLOR), new EmptyBorder(0, 1, 0, 0));
private static final SkinFont ROW_FONT = FSkin.getFont(12);
private static final SkinFont ROW_FONT = FSkin.getFont();
private static final int ROW_HEIGHT = 19;
private final ItemTable table = new ItemTable();

View File

@@ -103,7 +103,7 @@ public class AddBasicLandsDialog {
panel.add(pnlForest);
panel.add(lblDeckInfo);
lblDeckInfo.setFont(FSkin.getFont(14));
lblDeckInfo.setFont(FSkin.getRelativeFont(14));
lblDeckInfo.addMouseListener(new FMouseAdapter() {
@Override
public void onLeftDoubleClick(MouseEvent e) {

View File

@@ -38,7 +38,7 @@ public class LblGroup extends SkinnedLabel implements ILocalRepaint {
public LblGroup(final EMenuGroup e0) {
super(" " + e0.getTitle());
this.setFont(FSkin.getBoldFont(14));
this.setFont(FSkin.getRelativeBoldFont(14));
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
this.addMouseListener(new MouseAdapter() {

View File

@@ -25,7 +25,7 @@ public class LblHeader extends SkinnedLabel {
public LblHeader(final String txt0) {
super(txt0);
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
this.setFont(FSkin.getFont(18));
this.setFont(FSkin.getRelativeFont(18));
this.setBorder(new EmptyBorder(5, 30, 0, 0));
}

View File

@@ -36,7 +36,7 @@ public class LblMenuItem extends SkinnedLabel implements ILocalRepaint {
public LblMenuItem(final IVSubmenu<? extends ICDoc> doc0) {
super(" " + doc0.getMenuTitle());
this.setFont(FSkin.getFont(14));
this.setFont(FSkin.getRelativeFont(14));
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
this.addMouseListener(new MouseAdapter() {

View File

@@ -663,7 +663,7 @@ public class PlayerPanel extends FPanel {
txtPlayerName.setText(name);
txtPlayerName.setFocusable(true);
txtPlayerName.setFont(FSkin.getFont(14));
txtPlayerName.setFont(FSkin.getRelativeFont(14));
txtPlayerName.addActionListener(lobby.nameListener);
txtPlayerName.addFocusListener(nameFocusListener);
}

View File

@@ -107,7 +107,7 @@ public enum VSubmenuGauntletQuick implements IVSubmenu<CSubmenuGauntletQuick> {
sliOpponents.setSnapToTicks(true);
sliOpponents.setOpaque(false);
sliOpponents.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
sliOpponents.setFont(FSkin.getFont(12));
sliOpponents.setFont(FSkin.getFont());
pnlOptions.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
pnlOptions.add(lblOptions, "h 30px!, w 96%!, gap 2% 0 0 5px");

View File

@@ -64,7 +64,7 @@ public enum VSubmenuOnlineLobby implements IVSubmenu<CSubmenuOnlineLobby>, IOnli
if (lobby == null) {
final FButton btnConnect = new FButton("Connect to Server");
btnConnect.setFont(FSkin.getFont(20));
btnConnect.setFont(FSkin.getRelativeFont(20));
btnConnect.addActionListener(new ActionListener() {
@Override
public final void actionPerformed(final ActionEvent e) {

View File

@@ -27,17 +27,17 @@ public class PnlDraftEvent extends JPanel {
super();
radButton = new FRadioButton(event.getTitle());
radButton.setFont(FSkin.getBoldFont(20));
radButton.setFont(FSkin.getRelativeBoldFont(20));
radButton.setIconTextGap(10);
final FTextArea eventBoosters = new FTextArea();
final FTextArea eventFee = new FTextArea();
eventBoosters.setText(event.getBoosterList());
eventBoosters.setFont(FSkin.getFont(12));
eventBoosters.setFont(FSkin.getFont());
eventFee.setText(QuestUtil.formatCredits(event.getEntryFee()) + " Credit Entry Fee");
eventFee.setFont(FSkin.getFont(12));
eventFee.setFont(FSkin.getFont());
radButton.addChangeListener(new ChangeListener() {
@Override

View File

@@ -56,11 +56,11 @@ class PnlEvent extends JPanel {
// Title and description
this.rad = new FRadioButton(event.getFullTitle());
this.rad.setFont(FSkin.getBoldFont(16));
this.rad.setFont(FSkin.getRelativeBoldFont(16));
final FTextArea tarDesc = new FTextArea();
tarDesc.setText(event.getDescription());
tarDesc.setFont(FSkin.getItalicFont(12));
tarDesc.setFont(FSkin.getItalicFont());
tarDesc.addMouseListener(new MouseAdapter() {
@Override

View File

@@ -509,7 +509,7 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
this.setOpaque(false);
this.setBorder((Border)null);
this.setFont(FSkin.getFont(13));
this.setFont(FSkin.getRelativeFont(13));
this.setForeground(clrText);
this.setCaretColor(clrText);
this.setBackground(clrHover);

View File

@@ -80,7 +80,7 @@ public class ViewStall extends JPanel {
this.tpnFluff.setOpaque(false);
this.tpnFluff.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
this.tpnFluff.setFont(FSkin.getItalicFont(15));
this.tpnFluff.setFont(FSkin.getRelativeItalicFont(15));
this.tpnFluff.setFocusable(false);
this.tpnFluff.setEditable(false);
this.tpnFluff.setBorder((Border)null);

View File

@@ -193,7 +193,7 @@ public enum VSubmenuSealed implements IVSubmenu<CSubmenuSealed> {
final SkinnedTextPane tpnDirections = new SkinnedTextPane();
tpnDirections.setOpaque(false);
tpnDirections.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
tpnDirections.setFont(FSkin.getFont(15));
tpnDirections.setFont(FSkin.getRelativeFont(15));
tpnDirections.setAlignmentX(SwingConstants.CENTER);
tpnDirections.setFocusable(false);
tpnDirections.setEditable(false);

View File

@@ -48,8 +48,8 @@ public enum VSubmenuAchievements implements IVSubmenu<CSubmenuAchievements> {
private static final int TROPHIES_PER_SHELVE = 4;
private static final int PADDING = 5;
private static final int TROPHY_PADDING = 45;
private static final SkinFont NAME_FONT = FSkin.getBoldFont(14);
private static final SkinFont DESC_FONT = FSkin.getFont(12);
private static final SkinFont NAME_FONT = FSkin.getRelativeBoldFont(14);
private static final SkinFont DESC_FONT = FSkin.getFont();
private static final SkinColor TEXT_COLOR = FSkin.getColor(Colors.CLR_TEXT);
private static final SkinColor NOT_EARNED_COLOR = TEXT_COLOR.alphaColor(128);
private static final SkinColor TEXTURE_OVERLAY_COLOR = FSkin.getColor(Colors.CLR_THEME);
@@ -121,7 +121,7 @@ public enum VSubmenuAchievements implements IVSubmenu<CSubmenuAchievements> {
AchievementCollection.buildComboBox(cbCollections);
cbCollections.setSkinFont(FSkin.getBoldFont(14));
cbCollections.setSkinFont(FSkin.getRelativeBoldFont(14));
cbCollections.setTextAlignment(TextAlignment.CENTER);
cbCollections.addActionListener(new ActionListener() {
@Override
@@ -264,8 +264,8 @@ public enum VSubmenuAchievements implements IVSubmenu<CSubmenuAchievements> {
private static final SkinImage imgTop = FSkin.getImage(FSkinProp.IMG_TROPHY_CASE_TOP);
private static final SkinImage imgShelf = FSkin.getImage(FSkinProp.IMG_TROPHY_SHELF);
private static final SkinImage imgTrophyPlate = FSkin.getImage(FSkinProp.IMG_TROPHY_PLATE);
private static final Font font = FSkin.getFixedFont(14).deriveFont(Font.BOLD);
private static final Font subFont = FSkin.getFixedFont(12);
private static final Font font = FSkin.getRelativeFixedFont(14).deriveFont(Font.BOLD);
private static final Font subFont = FSkin.getFixedFont();
private static final Color foreColor = new Color(239, 220, 144);
private AchievementCollection achievements;

View File

@@ -391,7 +391,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final class OptionsCheckBox extends FCheckBox {
private OptionsCheckBox(final String txt0) {
super(txt0);
this.setFont(FSkin.getBoldFont(12));
this.setFont(FSkin.getBoldFont());
}
}
@@ -402,7 +402,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
super(txt0);
this.setBorder(new FSkin.MatteSkinBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
setHorizontalAlignment(SwingConstants.CENTER);
this.setFont(FSkin.getBoldFont(16));
this.setFont(FSkin.getRelativeBoldFont(16));
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
}
}
@@ -412,7 +412,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final class NoteLabel extends SkinnedLabel {
private NoteLabel(final String txt0) {
super(txt0);
this.setFont(FSkin.getItalicFont(12));
this.setFont(FSkin.getItalicFont());
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
}
}
@@ -436,7 +436,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
public KeyboardShortcutField(final Shortcut shortcut0) {
super();
this.setEditable(false);
this.setFont(FSkin.getFont(14));
this.setFont(FSkin.getRelativeFont(14));
final FPref prefKey = shortcut0.getPrefKey();
reload(prefKey);

View File

@@ -60,7 +60,7 @@ public enum VSubmenuReleaseNotes implements IVSubmenu<CSubmenuReleaseNotes> {
tar.setEditable(false);
tar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
tar.setFont(FSkin.getFixedFont(16));
tar.setFont(FSkin.getRelativeFixedFont(16));
tar.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
tar.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));

View File

@@ -59,7 +59,7 @@ public class LimitedWinLose extends ControlWinLose {
TitleLabel lblTemp1 = new TitleLabel(title);
SkinnedLabel lblTemp2 = new SkinnedLabel(message);
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
lblTemp2.setFont(FSkin.getFont(17));
lblTemp2.setFont(FSkin.getRelativeFont(17));
lblTemp2.setForeground(FORE_COLOR);
lblTemp2.setIconTextGap(50);
getView().getPnlCustom().add(lblTemp1, LimitedWinLose.CONSTRAINTS_TITLE);
@@ -136,7 +136,7 @@ public class LimitedWinLose extends ControlWinLose {
private class TitleLabel extends SkinnedLabel {
TitleLabel(final String msg) {
super(msg);
setFont(FSkin.getFont(18));
setFont(FSkin.getRelativeFont(18));
setPreferredSize(new Dimension(200, 40));
setHorizontalAlignment(SwingConstants.CENTER);
setForeground(FORE_COLOR);

View File

@@ -110,24 +110,24 @@ public class ViewWinLose implements IWinLoseView<FButton> {
lblTitle.setForeground(Color.white);
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setFont(FSkin.getBoldFont(30));
lblTitle.setFont(FSkin.getRelativeBoldFont(30));
lblStats.setForeground(Color.white);
lblStats.setHorizontalAlignment(SwingConstants.CENTER);
lblStats.setFont(FSkin.getFont(26));
lblStats.setFont(FSkin.getRelativeFont(26));
btnContinue.setText("Next Game");
btnContinue.setFont(FSkin.getFont(22));
btnContinue.setFont(FSkin.getRelativeFont(22));
btnRestart.setText("Start New Match");
btnRestart.setFont(FSkin.getFont(22));
btnRestart.setFont(FSkin.getRelativeFont(22));
btnQuit.setText("Quit Match");
btnQuit.setFont(FSkin.getFont(22));
btnQuit.setFont(FSkin.getRelativeFont(22));
btnContinue.setEnabled(!game0.isMatchOver());
// Assemble game log scroller.
final FTextArea txtLog = new FTextArea();
txtLog.setText(StringUtils.join(game.getGameLog().getLogEntries(null), "\r\n").replace("[COMPUTER]", "[AI]"));
txtLog.setFont(FSkin.getFont(14));
txtLog.setFont(FSkin.getRelativeFont(14));
txtLog.setFocusable(true); // allow highlighting and copying of log
final FLabel btnCopyLog = new FLabel.ButtonBuilder().text("Copy to clipboard").build();
@@ -292,7 +292,7 @@ public class ViewWinLose implements IWinLoseView<FButton> {
message = "<html>" + message.replace("\n", "<br>") + "</html>";
}
final SkinnedLabel lblMessage = new SkinnedLabel(message);
lblMessage.setFont(FSkin.getFont(14));
lblMessage.setFont(FSkin.getRelativeFont(14));
lblMessage.setForeground(FORE_COLOR);
lblMessage.setHorizontalAlignment(SwingConstants.CENTER);
lblMessage.setIconTextGap(50);
@@ -309,7 +309,7 @@ public class ViewWinLose implements IWinLoseView<FButton> {
private class TitleLabel extends SkinnedLabel {
TitleLabel(final String msg) {
super(msg);
setFont(FSkin.getFont(16));
setFont(FSkin.getRelativeFont(16));
setPreferredSize(new Dimension(200, 40));
setHorizontalAlignment(SwingConstants.CENTER);
setForeground(FORE_COLOR);

View File

@@ -116,11 +116,11 @@ public class VPrompt implements IVDoc<CPrompt> {
// wrap : 2 columns required for btnOk and btnCancel.
container.setLayout(new MigLayout("wrap 2, gap 0px!, insets 1px 1px 3px 1px"));
if (prefs.getPrefBoolean(FPref.UI_COMPACT_PROMPT)) { //hide header and use smaller font if compact prompt
tarMessage.setFont(FSkin.getFont(12));
tarMessage.setFont(FSkin.getFont());
}
else {
container.add(lblGames, "span 2, w 10:100%, h 22px!");
tarMessage.setFont(FSkin.getFont(14));
tarMessage.setFont(FSkin.getRelativeFont(14));
}
lblGames.setText("Game Setup");

View File

@@ -191,7 +191,7 @@ public class VStack implements IVDoc<CStack> {
setFocusable(false);
setEditable(false);
setLineWrap(true);
setFont(FSkin.getFont(12));
setFont(FSkin.getFont());
setWrapStyleWord(true);
setMinimumSize(new Dimension(CARD_WIDTH + 2 * PADDING, CARD_HEIGHT + 2 * PADDING));

View File

@@ -82,7 +82,7 @@ public class FComboBoxPanel<E> extends JPanel {
if (comboBoxCaption != null && !comboBoxCaption.isEmpty()) {
final SkinnedLabel comboLabel = new SkinnedLabel(comboBoxCaption);
comboLabel.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
comboLabel.setFont(FSkin.getBoldFont(12));
comboLabel.setFont(FSkin.getBoldFont());
add(comboLabel);
}
}
@@ -91,7 +91,7 @@ public class FComboBoxPanel<E> extends JPanel {
if (comboBox != null) {
comboBox.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
comboBox.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
comboBox.setFont(FSkin.getFont(12));
comboBox.setFont(FSkin.getFont());
comboBox.setEditable(false);
comboBox.setFocusable(true);
comboBox.setOpaque(true);

View File

@@ -859,8 +859,12 @@ public class FSkin {
private static Map<Integer, SkinImage> avatars;
private static Map<Integer, Font> fixedFonts = new HashMap<>();
public static Font getFixedFont() {
return getFixedFont(defaultFontSize);
}
/** @return {@link java.awt.font} */
public static Font getFixedFont(final int size) {
private static Font getFixedFont(final int size) {
Font fixedFont = fixedFonts.get(size);
if (fixedFont == null) {
fixedFont = new Font("Monospaced", Font.PLAIN, size);
@@ -869,6 +873,16 @@ public class FSkin {
return fixedFont;
}
public static Font getRelativeFixedFont(final int relative) {
double multiplier = getMultiplier(relative);
return getFixedFont((int)(defaultFontSize * multiplier));
}
private static double getMultiplier(final int relative) {
// don't know of a good way to get the preference default value
return relative / 12.0;
}
/**
* @return {@link forge.toolbox.FSkin.SkinFont}
*/
@@ -884,6 +898,11 @@ public class FSkin {
return SkinFont.get(Font.PLAIN, size);
}
public static SkinFont getRelativeFont(final int relative) {
double multiplier = getMultiplier(relative);
return SkinFont.get(Font.PLAIN, (int)(defaultFontSize * multiplier));
}
/**
* @return {@link forge.toolbox.FSkin.SkinFont}
*/
@@ -899,6 +918,11 @@ public class FSkin {
return SkinFont.get(Font.BOLD, size);
}
public static SkinFont getRelativeBoldFont(final int relative) {
double multiplier = getMultiplier(relative);
return SkinFont.get(Font.BOLD, (int)(defaultFontSize * multiplier));
}
/**
* @return {@link forge.toolbox.FSkin.SkinFont}
*/
@@ -914,6 +938,11 @@ public class FSkin {
return SkinFont.get(Font.ITALIC, size);
}
public static SkinFont getRelativeItalicFont(final int relative) {
double multiplier = getMultiplier(relative);
return SkinFont.get(Font.ITALIC, (int)(defaultFontSize * multiplier));
}
public static void setGraphicsFont(final Graphics g, final SkinFont skinFont) {
g.setFont(skinFont.font);
}

View File

@@ -19,7 +19,7 @@ public class FTextEditor extends SkinnedScrollPane {
public FTextEditor() {
tarEditor = new SkinnedTextArea();
tarEditor.setFont(FSkin.getFixedFont(16));
tarEditor.setFont(FSkin.getRelativeFixedFont(16));
tarEditor.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
tarEditor.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
tarEditor.setCaretColor(FSkin.getColor(FSkin.Colors.CLR_TEXT));

View File

@@ -382,7 +382,7 @@ public class FNavigationBar extends FTitleBarBase {
setOpaque(false);
this.setIcon(screen0.getTabIcon());
this.setForeground(foreColor.alphaColor(unhoveredAlpha));
this.setFont(FSkin.getFont(fontSize));
this.setFont(FSkin.getRelativeFont(fontSize));
int closeButtonOffset;
if (screen.allowTabClose()) {
@@ -434,7 +434,7 @@ public class FNavigationBar extends FTitleBarBase {
private void setSelected(final boolean selected0) {
if (this.selected == selected0) { return; }
this.selected = selected0;
this.setFont(selected0 ? FSkin.getBoldFont(fontSize) : FSkin.getFont(fontSize));
this.setFont(selected0 ? FSkin.getRelativeBoldFont(fontSize) : FSkin.getRelativeFont(fontSize));
repaintSelf();
}

View File

@@ -9,7 +9,7 @@ import java.awt.*;
@SuppressWarnings("serial")
public class FTitleBar extends FTitleBarBase {
private static final FSkin.SkinFont skinFont = FSkin.getFont(12);
private static final FSkin.SkinFont skinFont = FSkin.getFont();
private final SkinnedLabel lblTitle = new SkinnedLabel();

View File

@@ -265,7 +265,7 @@ public enum FView {
textPane.setOpaque(false);
textPane.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT).getColor());
textPane.setBorder(null);
textPane.setFont(FSkin.getFont(14).getBaseFont());
textPane.setFont(FSkin.getRelativeFont(14).getBaseFont());
final FLabel btnRemindMeLater = new FLabel.Builder().text("Remind Me Later").hoverable().opaque().build();
final FLabel btnDoNotRemindMe = new FLabel.Builder().text("Don't Remind Me Again").hoverable().opaque().build();