add font/color customization support for the run sub title setting
This commit is contained in:
parent
1105a52a0a
commit
05983ec78f
|
@ -38,6 +38,7 @@ public enum Language {
|
|||
setting_color_timeLost,
|
||||
setting_color_newRecord,
|
||||
setting_color_title,
|
||||
setting_color_subTitle,
|
||||
setting_color_highlight,
|
||||
setting_color_separators,
|
||||
|
||||
|
@ -57,6 +58,7 @@ public enum Language {
|
|||
setting_header_title,
|
||||
setting_header_showAttempts,
|
||||
setting_header_titleFont,
|
||||
setting_header_subTitleFont,
|
||||
|
||||
// Settings > History
|
||||
setting_history_rowCount,
|
||||
|
|
|
@ -48,6 +48,7 @@ public class Settings {
|
|||
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> 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> colorSeparators = new Property<>( "color.separators" );
|
||||
|
||||
|
@ -67,7 +68,8 @@ public class Settings {
|
|||
public static final Property<Boolean> headerShowSubtitle = new Property<>( "header.subTitle" );
|
||||
public static final Property<Boolean> headerShowTitle = new Property<>( "header.title" );
|
||||
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 */
|
||||
|
||||
|
@ -215,6 +217,7 @@ public class Settings {
|
|||
global.put( colorTimeLost.key, Color.decode( "0xe82323" ) );
|
||||
global.put( colorNewRecord.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( colorSeparators.key, Color.decode( "0x666666" ) );
|
||||
|
||||
|
@ -231,6 +234,7 @@ public class Settings {
|
|||
global.put( headerShowTitle.key, true );
|
||||
global.put( headerShowAttempts.key, true );
|
||||
global.put( headerTitleFont.key, Font.decode( "Arial-14" ) );
|
||||
global.put( headerSubTitleFont.key, Font.decode( "Arial-12" ) );
|
||||
|
||||
global.put( historyRowCount.key, 8 );
|
||||
global.put( historyTabular.key, true );
|
||||
|
|
|
@ -58,6 +58,10 @@ public class TabComponents extends SettingsTab
|
|||
|
||||
private JSpinner headerTitleSize;
|
||||
|
||||
private JComboBox headerSubTitleFont;
|
||||
|
||||
private JSpinner headerSubTitleSize;
|
||||
|
||||
private JComboBox coreFont;
|
||||
|
||||
private JSpinner coreFontSize;
|
||||
|
@ -127,6 +131,18 @@ public class TabComponents extends SettingsTab
|
|||
);
|
||||
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
|
||||
String coreFontName = Settings.coreFont.get().getName();
|
||||
coreFont = new JComboBox(gEnv.getAvailableFontFamilyNames());
|
||||
|
@ -167,6 +183,7 @@ public class TabComponents extends SettingsTab
|
|||
Object source = event.getSource();
|
||||
if (source.equals(iconSizes)) {
|
||||
Settings.coreIconSize.set((Integer) iconSizes.getSelectedItem());
|
||||
|
||||
} else if (source.equals(timerFont)) {
|
||||
String fontName = timerFont.getSelectedItem().toString();
|
||||
Font font = Font.decode(fontName).deriveFont(
|
||||
|
@ -176,12 +193,14 @@ public class TabComponents extends SettingsTab
|
|||
if (timerSameFont.isSelected()) {
|
||||
timerSegFont.setSelectedItem(fontName);
|
||||
}
|
||||
|
||||
} else if (source.equals(timerSegFont)) {
|
||||
String fontName = timerSegFont.getSelectedItem().toString();
|
||||
Font font = Font.decode(fontName).deriveFont(
|
||||
(float) Settings.coreSegmentTimerFont.get().getSize()
|
||||
);
|
||||
Settings.coreSegmentTimerFont.set(font);
|
||||
|
||||
} else if (source.equals(headerTitleFont)) {
|
||||
String fontName = headerTitleFont.getSelectedItem().toString();
|
||||
Font font = Font.decode(fontName).deriveFont(
|
||||
|
@ -189,6 +208,13 @@ public class TabComponents extends SettingsTab
|
|||
);
|
||||
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)) {
|
||||
String fontName = coreFont.getSelectedItem().toString();
|
||||
Font font = Font.decode(fontName).deriveFont(
|
||||
|
@ -232,6 +258,12 @@ public class TabComponents extends SettingsTab
|
|||
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)) {
|
||||
int size = (Integer) coreFontSize.getValue();
|
||||
Settings.coreFont.set(
|
||||
|
@ -291,18 +323,25 @@ public class TabComponents extends SettingsTab
|
|||
fontPanel.add(headerTitleSize, GBC.grid(2, 3).insets(0, 5));
|
||||
|
||||
fontPanel.add(
|
||||
new JLabel("" + Language.setting_core_font),
|
||||
new JLabel("" + Language.setting_header_subTitleFont),
|
||||
GBC.grid(0, 4).anchor(GBC.LS).insets(0, 5)
|
||||
);
|
||||
fontPanel.add(coreFont, GBC.grid(1, 4));
|
||||
fontPanel.add(coreFontSize, GBC.grid(2, 4).insets(0, 5));
|
||||
fontPanel.add(headerSubTitleFont, GBC.grid(1, 4));
|
||||
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(
|
||||
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(otherTimeSize, GBC.grid(2, 5).insets(0, 5));
|
||||
fontPanel.add(otherTimeFont, GBC.grid(1, 6));
|
||||
fontPanel.add(otherTimeSize, GBC.grid(2, 6).insets(0, 5));
|
||||
}
|
||||
JPanel timerPanel = new JPanel(new GridBagLayout()); {
|
||||
timerPanel.add(
|
||||
|
|
|
@ -226,7 +226,8 @@ public class RunPane extends JPanel {
|
|||
updateColors(SEPARATOR);
|
||||
} else if (Settings.historyRowCount.equals(property)) {
|
||||
updateValues(SEPARATOR);
|
||||
} else if (Settings.colorTitle.equals(property)) {
|
||||
} else if (Settings.colorTitle.equals(property)
|
||||
|| Settings.colorSubTitle.equals(property)) {
|
||||
updateColors(TITLE);
|
||||
} else if (Settings.graphDisplay.equals(property)) {
|
||||
updateVisibility(GRAPH);
|
||||
|
@ -247,7 +248,8 @@ public class RunPane extends JPanel {
|
|||
} else if (Run.ATTEMPT_COUNTER_PROPERTY.equals(property) ||
|
||||
Run.COMPLETED_ATTEMPT_COUNTER_PROPERTY.equals(property)) {
|
||||
updateValues(ATTEMPTS);
|
||||
} else if (Settings.headerTitleFont.equals(property)) {
|
||||
} else if (Settings.headerTitleFont.equals(property)
|
||||
|| Settings.headerSubTitleFont.equals(property)) {
|
||||
updateFonts(TITLE);
|
||||
} else if (Settings.coreFont.equals(property)) {
|
||||
updateFonts(ALL & ~TITLE);
|
||||
|
@ -341,7 +343,7 @@ public class RunPane extends JPanel {
|
|||
private void updateColors(int identifier) {
|
||||
if ((identifier & TITLE) == TITLE) {
|
||||
title.setForeground(Settings.colorTitle.get());
|
||||
subTitle.setForeground(Settings.colorForeground.get());
|
||||
subTitle.setForeground(Settings.colorSubTitle.get());
|
||||
}
|
||||
if ((identifier & BACKGROUND) == BACKGROUND) {
|
||||
setBackground(Settings.colorBackground.get());
|
||||
|
@ -366,7 +368,7 @@ public class RunPane extends JPanel {
|
|||
private void updateFonts(int identifier) {
|
||||
if ((identifier & TITLE) == TITLE) {
|
||||
title.setFont(Settings.headerTitleFont.get());
|
||||
subTitle.setFont(Settings.headerTitleFont.get());
|
||||
subTitle.setFont(Settings.headerSubTitleFont.get());
|
||||
}
|
||||
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
||||
attemptCounter.setFont(Settings.coreFont.get());
|
||||
|
|
|
@ -19,6 +19,7 @@ setting_color_timeGained = Time Gained
|
|||
setting_color_timeLost = Time Lost
|
||||
setting_color_newRecord = New Record
|
||||
setting_color_title = Title
|
||||
setting_color_subTitle = Sub Title
|
||||
setting_color_highlight = Highlight
|
||||
setting_color_separators = Separators
|
||||
|
||||
|
@ -38,6 +39,7 @@ setting_header_subTitle = Display Sub Title
|
|||
setting_header_title = Display Run Title
|
||||
setting_header_showAttempts = Display Attempt Counter
|
||||
setting_header_titleFont = Main Title
|
||||
setting_header_subTitleFont = Sub Title
|
||||
|
||||
# Settings > History
|
||||
setting_history_rowCount = Number of Rows
|
||||
|
|
Reference in a new issue