1414 */
1515package net .rptools .maptool .model .library .builtin .themecss ;
1616
17- import java .awt . Color ;
17+ import java .util . Objects ;
1818import java .util .function .Function ;
1919import javax .swing .UIDefaults ;
20+ import net .rptools .maptool .client .ui .theme .ThemeSupport ;
2021
2122/**
2223 * Class that extracts and represents the information passed to handlebars for building the themed
@@ -27,6 +28,9 @@ public class ButtonCssContext {
2728 /** The button foreground color. */
2829 private final String foregroundColor ;
2930
31+ /** The button background color. */
32+ private final String backgroundColor ;
33+
3034 /** Starting background color for the button background. */
3135 private final String startBackgroundColor ;
3236
@@ -45,28 +49,80 @@ public class ButtonCssContext {
4549 /** The size of the button border when it is disabled. */
4650 private final String disabledBorderSize ;
4751
48- /** The color of the border when the button is disabled. */
52+ /** The border color when the button is disabled. */
4953 private final String disabledBorderColor ;
5054
55+ /** The foreground color of the button when the mouse pointer is hovering over it. */
56+ private final String hoverForegroundColor ;
57+
5158 /** The background color of the button when the mouse pointer is hovering over it. */
5259 private final String hoverBackgroundColor ;
5360
61+ /** The border color of the button when the mouse pointer is hovering over it. */
62+ private final String hoverBorderColor ;
63+
64+ /** The border color of the button when it has focus. */
65+ private final String focusedForegroundColor ;
66+
67+ /** The border color of the button when it has focus. */
68+ private final String focusedBackgroundColor ;
69+
70+ /** The border color of the button when it has focus. */
71+ private final String focusedBorderColor ;
72+
73+ /** The border width of the button. */
74+ private final String borderWidth ;
75+
76+ /** The shadow width of the button. */
77+ private final String shadowWidth ;
78+
79+ /** The shadow color of the button. */
80+ private final String shadowColor ;
81+
82+ /** The shadow color of the button. */
83+ private final String startBorderColor ;
84+
85+ /** The shadow color of the button. */
86+ private final String endBorderColor ;
87+
88+ /** Whether to show a button shadow color. */
89+ private final int showShadow ;
90+
5491 /**
5592 * Creates a new <code>ButtonCssContext</code>
5693 *
57- * @param uiDef the {@link UIDefaults} to extract information from.
58- * @param formatColor the function to use to format the color.
94+ * @param uiDef The {@link UIDefaults} to extract information from.
95+ * @param getColorOrBlank The function to use to convert the color key into a string color format .
5996 */
60- public ButtonCssContext (UIDefaults uiDef , Function <Color , String > formatColor ) {
61- foregroundColor = formatColor .apply (uiDef .getColor ("Button.foreground" ));
62- startBackgroundColor = formatColor .apply (uiDef .getColor ("Button.startBackground" ));
63- endBackgroundColor = formatColor .apply (uiDef .getColor ("Button.endBackground" ));
64- pressedBackgroundColor = formatColor .apply (uiDef .getColor ("Button.pressedBackground" ));
65- disabledBackgroundColor = formatColor .apply (uiDef .getColor ("Button.disabledBackground" ));
66- disabledForegroundColor = formatColor .apply (uiDef .getColor ("Button.disabledForeground" ));
97+ public ButtonCssContext (UIDefaults uiDef , Function <String , String > getColorOrBlank ) {
98+ foregroundColor = getColorOrBlank .apply ("Button.foreground" );
99+ backgroundColor = getColorOrBlank .apply ("Button.background" );
100+ startBackgroundColor =
101+ ThemeCssContext .getColorOrDefault ("Button.startBackground" , backgroundColor );
102+ endBackgroundColor = ThemeCssContext .getColorOrDefault ("Button.endBackground" , backgroundColor );
103+ pressedBackgroundColor = getColorOrBlank .apply ("Button.pressedBackground" );
104+ disabledBackgroundColor = getColorOrBlank .apply ("Button.disabledBackground" );
105+ disabledForegroundColor = getColorOrBlank .apply ("Button.disabledForeground" );
67106 disabledBorderSize = uiDef .getInt ("Button.disabledBorderSize" ) + "px" ;
68- disabledBorderColor = formatColor .apply (uiDef .getColor ("Button.disabledBorderColor" ));
69- hoverBackgroundColor = formatColor .apply (uiDef .getColor ("Button.hoverBackground" ));
107+ disabledBorderColor = getColorOrBlank .apply ("Button.disabledBorderColor" );
108+ hoverForegroundColor =
109+ ThemeCssContext .getColorOrDefault ("Button.hoverForeground" , foregroundColor );
110+ hoverBackgroundColor = getColorOrBlank .apply ("Button.hoverBackground" );
111+ hoverBorderColor = getColorOrBlank .apply ("Button.hoverBorderColor" );
112+ focusedForegroundColor =
113+ ThemeCssContext .getColorOrDefault ("Button.focusedForeground" , foregroundColor );
114+ focusedBackgroundColor =
115+ ThemeCssContext .getColorOrDefault ("Button.focusedBackground" , backgroundColor );
116+ focusedBorderColor = getColorOrBlank .apply ("Button.focusedBorderColor" );
117+ borderWidth = uiDef .getInt ("Button.borderWidth" ) + "px" ;
118+ shadowColor = getColorOrBlank .apply ("Button.shadowColor" );
119+ shadowWidth = uiDef .getInt ("Button.shadowWidth" ) + "px" ;
120+ startBorderColor = getColorOrBlank .apply ("Button.startBorderColor" );
121+ endBorderColor = getColorOrBlank .apply ("Button.endBorderColor" );
122+ showShadow =
123+ uiDef .getBoolean ("button.showShadow" ) || Objects .equals (ThemeSupport .getThemeName (), "Aah" )
124+ ? 1
125+ : 0 ;
70126 }
71127
72128 /**
@@ -149,4 +205,103 @@ public String getDisabledBorderColor() {
149205 public String getHoverBackgroundColor () {
150206 return hoverBackgroundColor ;
151207 }
208+
209+ /**
210+ * Returns the foreground color of the button when the mouse pointer is hovering over it.
211+ *
212+ * @return the foreground color of the button when the mouse pointer is hovering over it.
213+ */
214+ public String getHoverForegroundColor () {
215+ return hoverForegroundColor ;
216+ }
217+
218+ /**
219+ * Returns the border color of the button when the mouse pointer is hovering over it.
220+ *
221+ * @return the border color of the button when the mouse pointer is hovering over it.
222+ */
223+ public String getHoverBorderColor () {
224+ return hoverBorderColor ;
225+ }
226+
227+ /**
228+ * Returns the foreground color of the button when it has focus.
229+ *
230+ * @return the foreground color of the button when it has focus.
231+ */
232+ public String getFocusedForegroundColor () {
233+ return focusedForegroundColor ;
234+ }
235+
236+ /**
237+ * Returns the background color of the button when it has focus.
238+ *
239+ * @return the background color of the button when it has focus.
240+ */
241+ public String getFocusedBackgroundColor () {
242+ return focusedBackgroundColor ;
243+ }
244+
245+ /**
246+ * Returns the border color of the button when it has focus.
247+ *
248+ * @return the border color of the button when it has focus.
249+ */
250+ public String getFocusedBorderColor () {
251+ return focusedBorderColor ;
252+ }
253+
254+ /**
255+ * Returns the border width of the button.
256+ *
257+ * @return the border width of the button.
258+ */
259+ public String getBorderWidth () {
260+ return borderWidth ;
261+ }
262+
263+ /**
264+ * Returns the shadow width of the button.
265+ *
266+ * @return the shadow width of the button.
267+ */
268+ public String getShadowWidth () {
269+ return shadowWidth ;
270+ }
271+
272+ /**
273+ * Returns the shadow color of the button.
274+ *
275+ * @return the shadow color of the button.
276+ */
277+ public String getShadowColor () {
278+ return shadowColor ;
279+ }
280+
281+ /**
282+ * Returns the start border color of the button.
283+ *
284+ * @return the start border color of the button.
285+ */
286+ public String getStartBorderColor () {
287+ return startBorderColor ;
288+ }
289+
290+ /**
291+ * Returns the end border color of the button.
292+ *
293+ * @return the end border color of the button.
294+ */
295+ public String getEndBorderColor () {
296+ return endBorderColor ;
297+ }
298+
299+ /**
300+ * Returns whether to show a button shadow.
301+ *
302+ * @return whether to show a button shadow.
303+ */
304+ public int getShowShadow () {
305+ return showShadow ;
306+ }
152307}
0 commit comments