add font/color customization support for the run sub title setting

This commit is contained in:
Gered 2016-01-03 15:32:06 -05:00
parent 1105a52a0a
commit 05983ec78f
5 changed files with 60 additions and 11 deletions

View file

@ -38,6 +38,7 @@ public enum Language {
setting_color_timeLost, setting_color_timeLost,
setting_color_newRecord, setting_color_newRecord,
setting_color_title, setting_color_title,
setting_color_subTitle,
setting_color_highlight, setting_color_highlight,
setting_color_separators, setting_color_separators,
@ -57,6 +58,7 @@ public enum Language {
setting_header_title, setting_header_title,
setting_header_showAttempts, setting_header_showAttempts,
setting_header_titleFont, setting_header_titleFont,
setting_header_subTitleFont,
// Settings > History // Settings > History
setting_history_rowCount, setting_history_rowCount,

View file

@ -48,6 +48,7 @@ public class Settings {
public static final Property<Color> colorTimeLost = new Property<>( "color.timeLost" ); public static final Property<Color> colorTimeLost = new Property<>( "color.timeLost" );
public static final Property<Color> colorNewRecord = new Property<>( "color.newRecord" ); public static final Property<Color> colorNewRecord = new Property<>( "color.newRecord" );
public static final Property<Color> colorTitle = new Property<>( "color.title" ); public static final Property<Color> colorTitle = new Property<>( "color.title" );
public static final Property<Color> colorSubTitle = new Property<>( "color.subTitle" );
public static final Property<Color> colorHighlight = new Property<>( "color.highlight" ); public static final Property<Color> colorHighlight = new Property<>( "color.highlight" );
public static final Property<Color> colorSeparators = new Property<>( "color.separators" ); public static final Property<Color> colorSeparators = new Property<>( "color.separators" );
@ -68,6 +69,7 @@ public class Settings {
public static final Property<Boolean> headerShowTitle = new Property<>( "header.title" ); public static final Property<Boolean> headerShowTitle = new Property<>( "header.title" );
public static final Property<Boolean> headerShowAttempts = new Property<>( "header.showAttempts" ); public static final Property<Boolean> headerShowAttempts = new Property<>( "header.showAttempts" );
public static final Property<Font> headerTitleFont = new Property<>( "header.titleFont" ); public static final Property<Font> headerTitleFont = new Property<>( "header.titleFont" );
public static final Property<Font> headerSubTitleFont = new Property<>( "header.subTitleFont" );
/* HISTORY properties */ /* HISTORY properties */
@ -215,6 +217,7 @@ public class Settings {
global.put( colorTimeLost.key, Color.decode( "0xe82323" ) ); global.put( colorTimeLost.key, Color.decode( "0xe82323" ) );
global.put( colorNewRecord.key, Color.decode( "0xf0b012" ) ); global.put( colorNewRecord.key, Color.decode( "0xf0b012" ) );
global.put( colorTitle.key, Color.decode( "0xf0b012" ) ); global.put( colorTitle.key, Color.decode( "0xf0b012" ) );
global.put( colorSubTitle.key, Color.decode( "0xffffff" ) );
global.put( colorHighlight.key, Color.decode( "0xffffff" ) ); global.put( colorHighlight.key, Color.decode( "0xffffff" ) );
global.put( colorSeparators.key, Color.decode( "0x666666" ) ); global.put( colorSeparators.key, Color.decode( "0x666666" ) );
@ -231,6 +234,7 @@ public class Settings {
global.put( headerShowTitle.key, true ); global.put( headerShowTitle.key, true );
global.put( headerShowAttempts.key, true ); global.put( headerShowAttempts.key, true );
global.put( headerTitleFont.key, Font.decode( "Arial-14" ) ); global.put( headerTitleFont.key, Font.decode( "Arial-14" ) );
global.put( headerSubTitleFont.key, Font.decode( "Arial-12" ) );
global.put( historyRowCount.key, 8 ); global.put( historyRowCount.key, 8 );
global.put( historyTabular.key, true ); global.put( historyTabular.key, true );

View file

@ -58,6 +58,10 @@ public class TabComponents extends SettingsTab
private JSpinner headerTitleSize; private JSpinner headerTitleSize;
private JComboBox headerSubTitleFont;
private JSpinner headerSubTitleSize;
private JComboBox coreFont; private JComboBox coreFont;
private JSpinner coreFontSize; private JSpinner coreFontSize;
@ -127,6 +131,18 @@ public class TabComponents extends SettingsTab
); );
headerTitleSize.addChangeListener(this); headerTitleSize.addChangeListener(this);
// header sub-title font family and size selector
String headerSubTitleFontName = Settings.headerSubTitleFont.get().getName();
headerSubTitleFont = new JComboBox(gEnv.getAvailableFontFamilyNames());
headerSubTitleFont.setSelectedItem(headerSubTitleFontName);
headerSubTitleFont.setPreferredSize(new Dimension(130, 22));
headerSubTitleFont.addActionListener(this);
headerSubTitleSize = new JSpinner(new SpinnerNumberModel(
Settings.headerSubTitleFont.get().getSize(), 8, 240, 1)
);
headerSubTitleSize.addChangeListener(this);
// other/general font family and size selector // other/general font family and size selector
String coreFontName = Settings.coreFont.get().getName(); String coreFontName = Settings.coreFont.get().getName();
coreFont = new JComboBox(gEnv.getAvailableFontFamilyNames()); coreFont = new JComboBox(gEnv.getAvailableFontFamilyNames());
@ -167,6 +183,7 @@ public class TabComponents extends SettingsTab
Object source = event.getSource(); Object source = event.getSource();
if (source.equals(iconSizes)) { if (source.equals(iconSizes)) {
Settings.coreIconSize.set((Integer) iconSizes.getSelectedItem()); Settings.coreIconSize.set((Integer) iconSizes.getSelectedItem());
} else if (source.equals(timerFont)) { } else if (source.equals(timerFont)) {
String fontName = timerFont.getSelectedItem().toString(); String fontName = timerFont.getSelectedItem().toString();
Font font = Font.decode(fontName).deriveFont( Font font = Font.decode(fontName).deriveFont(
@ -176,12 +193,14 @@ public class TabComponents extends SettingsTab
if (timerSameFont.isSelected()) { if (timerSameFont.isSelected()) {
timerSegFont.setSelectedItem(fontName); timerSegFont.setSelectedItem(fontName);
} }
} else if (source.equals(timerSegFont)) { } else if (source.equals(timerSegFont)) {
String fontName = timerSegFont.getSelectedItem().toString(); String fontName = timerSegFont.getSelectedItem().toString();
Font font = Font.decode(fontName).deriveFont( Font font = Font.decode(fontName).deriveFont(
(float) Settings.coreSegmentTimerFont.get().getSize() (float) Settings.coreSegmentTimerFont.get().getSize()
); );
Settings.coreSegmentTimerFont.set(font); Settings.coreSegmentTimerFont.set(font);
} else if (source.equals(headerTitleFont)) { } else if (source.equals(headerTitleFont)) {
String fontName = headerTitleFont.getSelectedItem().toString(); String fontName = headerTitleFont.getSelectedItem().toString();
Font font = Font.decode(fontName).deriveFont( Font font = Font.decode(fontName).deriveFont(
@ -189,6 +208,13 @@ public class TabComponents extends SettingsTab
); );
Settings.headerTitleFont.set(font); Settings.headerTitleFont.set(font);
} else if (source.equals(headerSubTitleFont)) {
String fontName = headerSubTitleFont.getSelectedItem().toString();
Font font = Font.decode(fontName).deriveFont(
(float) Settings.headerSubTitleFont.get().getSize()
);
Settings.headerSubTitleFont.set(font);
} else if (source.equals(coreFont)) { } else if (source.equals(coreFont)) {
String fontName = coreFont.getSelectedItem().toString(); String fontName = coreFont.getSelectedItem().toString();
Font font = Font.decode(fontName).deriveFont( Font font = Font.decode(fontName).deriveFont(
@ -232,6 +258,12 @@ public class TabComponents extends SettingsTab
Settings.headerTitleFont.get().deriveFont((float) size) Settings.headerTitleFont.get().deriveFont((float) size)
); );
} else if (source.equals(headerSubTitleSize)) {
int size = (Integer) headerSubTitleSize.getValue();
Settings.headerSubTitleFont.set(
Settings.headerSubTitleFont.get().deriveFont((float) size)
);
} else if (source.equals(coreFontSize)) { } else if (source.equals(coreFontSize)) {
int size = (Integer) coreFontSize.getValue(); int size = (Integer) coreFontSize.getValue();
Settings.coreFont.set( Settings.coreFont.set(
@ -291,18 +323,25 @@ public class TabComponents extends SettingsTab
fontPanel.add(headerTitleSize, GBC.grid(2, 3).insets(0, 5)); fontPanel.add(headerTitleSize, GBC.grid(2, 3).insets(0, 5));
fontPanel.add( fontPanel.add(
new JLabel("" + Language.setting_core_font), new JLabel("" + Language.setting_header_subTitleFont),
GBC.grid(0, 4).anchor(GBC.LS).insets(0, 5) GBC.grid(0, 4).anchor(GBC.LS).insets(0, 5)
); );
fontPanel.add(coreFont, GBC.grid(1, 4)); fontPanel.add(headerSubTitleFont, GBC.grid(1, 4));
fontPanel.add(coreFontSize, GBC.grid(2, 4).insets(0, 5)); fontPanel.add(headerSubTitleSize, GBC.grid(2, 4).insets(0, 5));
fontPanel.add(
new JLabel("" + Language.setting_core_font),
GBC.grid(0, 5).anchor(GBC.LS).insets(0, 5)
);
fontPanel.add(coreFont, GBC.grid(1, 5));
fontPanel.add(coreFontSize, GBC.grid(2, 5).insets(0, 5));
fontPanel.add( fontPanel.add(
new JLabel("" + Language.setting_core_otherTimeFont), new JLabel("" + Language.setting_core_otherTimeFont),
GBC.grid(0, 5).anchor(GBC.LS).insets(0, 5) GBC.grid(0, 6).anchor(GBC.LS).insets(0, 5)
); );
fontPanel.add(otherTimeFont, GBC.grid(1, 5)); fontPanel.add(otherTimeFont, GBC.grid(1, 6));
fontPanel.add(otherTimeSize, GBC.grid(2, 5).insets(0, 5)); fontPanel.add(otherTimeSize, GBC.grid(2, 6).insets(0, 5));
} }
JPanel timerPanel = new JPanel(new GridBagLayout()); { JPanel timerPanel = new JPanel(new GridBagLayout()); {
timerPanel.add( timerPanel.add(

View file

@ -226,7 +226,8 @@ public class RunPane extends JPanel {
updateColors(SEPARATOR); updateColors(SEPARATOR);
} else if (Settings.historyRowCount.equals(property)) { } else if (Settings.historyRowCount.equals(property)) {
updateValues(SEPARATOR); updateValues(SEPARATOR);
} else if (Settings.colorTitle.equals(property)) { } else if (Settings.colorTitle.equals(property)
|| Settings.colorSubTitle.equals(property)) {
updateColors(TITLE); updateColors(TITLE);
} else if (Settings.graphDisplay.equals(property)) { } else if (Settings.graphDisplay.equals(property)) {
updateVisibility(GRAPH); updateVisibility(GRAPH);
@ -247,7 +248,8 @@ public class RunPane extends JPanel {
} else if (Run.ATTEMPT_COUNTER_PROPERTY.equals(property) || } else if (Run.ATTEMPT_COUNTER_PROPERTY.equals(property) ||
Run.COMPLETED_ATTEMPT_COUNTER_PROPERTY.equals(property)) { Run.COMPLETED_ATTEMPT_COUNTER_PROPERTY.equals(property)) {
updateValues(ATTEMPTS); updateValues(ATTEMPTS);
} else if (Settings.headerTitleFont.equals(property)) { } else if (Settings.headerTitleFont.equals(property)
|| Settings.headerSubTitleFont.equals(property)) {
updateFonts(TITLE); updateFonts(TITLE);
} else if (Settings.coreFont.equals(property)) { } else if (Settings.coreFont.equals(property)) {
updateFonts(ALL & ~TITLE); updateFonts(ALL & ~TITLE);
@ -341,7 +343,7 @@ public class RunPane extends JPanel {
private void updateColors(int identifier) { private void updateColors(int identifier) {
if ((identifier & TITLE) == TITLE) { if ((identifier & TITLE) == TITLE) {
title.setForeground(Settings.colorTitle.get()); title.setForeground(Settings.colorTitle.get());
subTitle.setForeground(Settings.colorForeground.get()); subTitle.setForeground(Settings.colorSubTitle.get());
} }
if ((identifier & BACKGROUND) == BACKGROUND) { if ((identifier & BACKGROUND) == BACKGROUND) {
setBackground(Settings.colorBackground.get()); setBackground(Settings.colorBackground.get());
@ -366,7 +368,7 @@ public class RunPane extends JPanel {
private void updateFonts(int identifier) { private void updateFonts(int identifier) {
if ((identifier & TITLE) == TITLE) { if ((identifier & TITLE) == TITLE) {
title.setFont(Settings.headerTitleFont.get()); title.setFont(Settings.headerTitleFont.get());
subTitle.setFont(Settings.headerTitleFont.get()); subTitle.setFont(Settings.headerSubTitleFont.get());
} }
if ((identifier & ATTEMPTS) == ATTEMPTS) { if ((identifier & ATTEMPTS) == ATTEMPTS) {
attemptCounter.setFont(Settings.coreFont.get()); attemptCounter.setFont(Settings.coreFont.get());

View file

@ -19,6 +19,7 @@ setting_color_timeGained = Time Gained
setting_color_timeLost = Time Lost setting_color_timeLost = Time Lost
setting_color_newRecord = New Record setting_color_newRecord = New Record
setting_color_title = Title setting_color_title = Title
setting_color_subTitle = Sub Title
setting_color_highlight = Highlight setting_color_highlight = Highlight
setting_color_separators = Separators setting_color_separators = Separators
@ -38,6 +39,7 @@ setting_header_subTitle = Display Sub Title
setting_header_title = Display Run Title setting_header_title = Display Run Title
setting_header_showAttempts = Display Attempt Counter setting_header_showAttempts = Display Attempt Counter
setting_header_titleFont = Main Title setting_header_titleFont = Main Title
setting_header_subTitleFont = Sub Title
# Settings > History # Settings > History
setting_history_rowCount = Number of Rows setting_history_rowCount = Number of Rows