Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update themed CSS #4189

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package net.rptools.maptool.model.library.builtin.themecss;

import java.awt.Color;
import java.util.function.Function;
import javax.swing.UIDefaults;

/**
Expand Down Expand Up @@ -51,20 +53,18 @@ public class ButtonCssContext {
* Creates a new <code>ButtonCssContext</code>
*
* @param uiDef the {@link UIDefaults} to extract information from.
* @param formatColor the function to use to format the color.
*/
public ButtonCssContext(UIDefaults uiDef) {
foregroundColor = ThemeCssContext.formatColor(uiDef.getColor("Button.foreground"));
startBackgroundColor = ThemeCssContext.formatColor(uiDef.getColor("Button.startBackground"));
endBackgroundColor = ThemeCssContext.formatColor(uiDef.getColor("Button.endBackground"));
pressedBackgroundColor =
ThemeCssContext.formatColor(uiDef.getColor("Button.pressedBackground"));
disabledBackgroundColor =
ThemeCssContext.formatColor(uiDef.getColor("Button.disabledBackground"));
disabledForegroundColor =
ThemeCssContext.formatColor(uiDef.getColor("Button.disabledForeground"));
public ButtonCssContext(UIDefaults uiDef, Function<Color, String> formatColor) {
foregroundColor = formatColor.apply(uiDef.getColor("Button.foreground"));
startBackgroundColor = formatColor.apply(uiDef.getColor("Button.startBackground"));
endBackgroundColor = formatColor.apply(uiDef.getColor("Button.endBackground"));
pressedBackgroundColor = formatColor.apply(uiDef.getColor("Button.pressedBackground"));
disabledBackgroundColor = formatColor.apply(uiDef.getColor("Button.disabledBackground"));
disabledForegroundColor = formatColor.apply(uiDef.getColor("Button.disabledForeground"));
disabledBorderSize = uiDef.getInt("Button.disabledBorderSize") + "px";
disabledBorderColor = ThemeCssContext.formatColor(uiDef.getColor("Button.disabledBorderColor"));
hoverBackgroundColor = ThemeCssContext.formatColor(uiDef.getColor("Button.hoverBackground"));
disabledBorderColor = formatColor.apply(uiDef.getColor("Button.disabledBorderColor"));
hoverBackgroundColor = formatColor.apply(uiDef.getColor("Button.hoverBackground"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package net.rptools.maptool.model.library.builtin.themecss;

import com.formdev.flatlaf.FlatIconColors;
import java.awt.Color;
import java.util.function.Function;
import javax.swing.UIDefaults;

/**
Expand Down Expand Up @@ -74,40 +76,31 @@ public class ColorCssContext {
*
* @param uiDef The UI defaults to extract the colors from.
*/
public ColorCssContext(UIDefaults uiDef) {
actionsBlue = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_BLUE.key));
actionsBlueDark =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_BLUE_DARK.key));
actionsGreen = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_GREEN.key));
actionsGreenDark =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_GREEN_DARK.key));
actionsGrey = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_GREY.key));
actionsGreyDark =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_GREY_DARK.key));
actionsGreyInline =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_GREYINLINE.key));
public ColorCssContext(UIDefaults uiDef, Function<Color, String> formatColor) {
actionsBlue = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_BLUE.key));
actionsBlueDark = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_BLUE_DARK.key));
actionsGreen = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_GREEN.key));
actionsGreenDark = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_GREEN_DARK.key));
actionsGrey = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_GREY.key));
actionsGreyDark = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_GREY_DARK.key));
actionsGreyInline = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_GREYINLINE.key));
actionsGreyInlineDark =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_GREYINLINE_DARK.key));
actionsRed = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_RED.key));
actionsRedDark =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_RED_DARK.key));
actionsYellow = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_YELLOW.key));
actionsYellowDark =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.ACTIONS_YELLOW_DARK.key));
objectsBlackText =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_BLACK_TEXT.key));
objectsBlue = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_BLUE.key));
objectsGreen = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_GREEN.key));
formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_GREYINLINE_DARK.key));
actionsRed = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_RED.key));
actionsRedDark = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_RED_DARK.key));
actionsYellow = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_YELLOW.key));
actionsYellowDark = formatColor.apply(uiDef.getColor(FlatIconColors.ACTIONS_YELLOW_DARK.key));
objectsBlackText = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_BLACK_TEXT.key));
objectsBlue = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_BLUE.key));
objectsGreen = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_GREEN.key));
objectsGreenAndroid =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_GREEN_ANDROID.key));
objectsGrey = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_GREY.key));
objectsPink = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_PINK.key));
objectsRed = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_RED.key));
objectsRedStatus =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_RED_STATUS.key));
objectsYellow = ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_YELLOW.key));
objectsYellowDark =
ThemeCssContext.formatColor(uiDef.getColor(FlatIconColors.OBJECTS_YELLOW_DARK.key));
formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_GREEN_ANDROID.key));
objectsGrey = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_GREY.key));
objectsPink = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_PINK.key));
objectsRed = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_RED.key));
objectsRedStatus = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_RED_STATUS.key));
objectsYellow = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_YELLOW.key));
objectsYellowDark = formatColor.apply(uiDef.getColor(FlatIconColors.OBJECTS_YELLOW_DARK.key));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* This software Copyright by the RPTools.net development team, and
* licensed under the Affero GPL Version 3 or, at your option, any later
* version.
*
* MapTool Source Code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public
* License * along with this source Code. If not, please visit
* <http://www.gnu.org/licenses/> and specifically the Affero license
* text at <http://www.gnu.org/licenses/agpl.html>.
*/
package net.rptools.maptool.model.library.builtin.themecss;

import java.awt.Color;
import java.util.function.Function;
import javax.swing.UIDefaults;

public class ProgressBarCSSContext {

/** The progress bar arc. */
private final int arc;

/** The progress bar background color. */
private final String backgroundColor;

/** The progress bar font family. */
private final String fontFamily;

/** The progress bar font size. */
private final String fontSize;

/**
* Creates a new instance of the theme CSS context.
*
* @param uiDef the UI defaults to use.
* @param formatColor the function to use to format colors.
*/
public ProgressBarCSSContext(UIDefaults uiDef, Function<Color, String> formatColor) {
arc = uiDef.getInt("ProgressBar.arc");
backgroundColor = formatColor.apply(uiDef.getColor("ProgressBar.background"));
fontFamily = uiDef.getFont("ProgressBar.font").getFamily();
fontSize = uiDef.getFont("ProgressBar.font").getSize() + "px";
}

/**
* Gets the progress bar arc.
*
* @return The progress bar arc.
*/
public int getArc() {
return arc;
}

/** Gets the progress bar background color. */
public String getBackgroundColor() {
return backgroundColor;
}

/** Gets the progress bar font family. */
public String getFontFamily() {
return fontFamily;
}

/** Gets the progress bar font size. */
public String getFontSize() {
return fontSize;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
* This software Copyright by the RPTools.net development team, and
* licensed under the Affero GPL Version 3 or, at your option, any later
* version.
*
* MapTool Source Code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public
* License * along with this source Code. If not, please visit
* <http://www.gnu.org/licenses/> and specifically the Affero license
* text at <http://www.gnu.org/licenses/agpl.html>.
*/
package net.rptools.maptool.model.library.builtin.themecss;

import java.awt.Color;
import java.util.function.Function;
import javax.swing.UIDefaults;

/**
* A context for the scroll bar CSS. This is used to extract and provide the scroll bar CSS values.
*/
public class ScrollBarCSSContext {
/** The progress bar foreground color. */
private final String backgroundColor;

/** The scroll bar border color. */
private final int showButtons;

/** The scroll bar border color. */
private final String thumbHighlightColor;

/** The scroll bar border color. */
private final int thumbArc;

/** The scroll bar border color. */
private final String thumbBorderColor;

/** The scroll bar border color. */
private final String thumbShadowColor;

/** The scroll bar border color. */
private final String thumbDarkShadowColor;

/** The scroll bar border color. */
private final String thumbColor;

/** The scroll bar border color. */
private final int thumbInsetsLeft;

/** The scroll bar border color. */
private final int thumbInsetsTop;

/** The scroll bar border color. */
private final int thumbInsetsRight;

/** The scroll bar border color. */
private final int thumbInsetsBottom;

/**
* Creates a new instance of the theme CSS context.
*
* @param uiDef the UI defaults to use.
*/
public ScrollBarCSSContext(UIDefaults uiDef, Function<Color, String> formatColor) {
backgroundColor = formatColor.apply(uiDef.getColor("ScrollBar.background"));
showButtons = uiDef.getBoolean("ScrollBar.showButtons") ? 1 : 0;
thumbHighlightColor = formatColor.apply(uiDef.getColor("ScrollBar.thumbHighlight"));
thumbArc = uiDef.getInt("ScrollBar.thumbArc");
thumbBorderColor = formatColor.apply(uiDef.getColor("ScrollBar.thumbBorderColor"));
thumbShadowColor = formatColor.apply(uiDef.getColor("ScrollBar.thumbShadow"));
thumbDarkShadowColor = formatColor.apply(uiDef.getColor("ScrollBar.thumbDarkShadow"));
thumbColor = formatColor.apply(uiDef.getColor("ScrollBar.thumb"));
thumbInsetsLeft = uiDef.getInt("ScrollBar.thumbInsets.left");
thumbInsetsTop = uiDef.getInt("ScrollBar.thumbInsets.top");
thumbInsetsRight = uiDef.getInt("ScrollBar.thumbInsets.right");
thumbInsetsBottom = uiDef.getInt("ScrollBar.thumbInsets.bottom");
}

/** Gets the scroll background color. */
public String getBackgroundColor() {
return backgroundColor;
}

/** Gets the scroll bar show buttons. */
public int getShowButtons() {
return showButtons;
}

/** Gets the scroll bar thumb highlight color. */
public String getThumbHighlightColor() {
return thumbHighlightColor;
}

/** Gets the scroll bar thumb arc. */
public int getThumbArc() {
return thumbArc;
}

/** Gets the scroll bar thumb border color. */
public String getThumbBorderColor() {
return thumbBorderColor;
}

/** Gets the scroll bar thumb shadow color. */
public String getThumbShadowColor() {
return thumbShadowColor;
}

/** Gets the scroll bar thumb dark shadow color. */
public String getThumbDarkShadowColor() {
return thumbDarkShadowColor;
}

/** Gets the scroll bar thumb color. */
public String getThumbColor() {
return thumbColor;
}

/** Gets the scroll bar thumb insets left. */
public int getThumbInsetsLeft() {
return thumbInsetsLeft;
}

/** Gets the scroll bar thumb insets top. */
public int getThumbInsetsTop() {
return thumbInsetsTop;
}

/** Gets the scroll bar thumb insets right. */
public int getThumbInsetsRight() {
return thumbInsetsRight;
}

/** Gets the scroll bar thumb insets bottom. */
public int getThumbInsetsBottom() {
return thumbInsetsBottom;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package net.rptools.maptool.model.library.builtin.themecss;

import java.awt.Color;
import java.util.function.Function;
import javax.swing.UIDefaults;

/**
Expand All @@ -37,13 +39,13 @@ public class TextInputCssContext {
* Creates a new instance of the text input css context.
*
* @param uiDef The UI defaults to use to extract the values.
* @param formatColor The function to use to format the color.
*/
public TextInputCssContext(UIDefaults uiDef) {
foregroundColor = ThemeCssContext.formatColor(uiDef.getColor("TextField.foreground"));
backgroundColor = ThemeCssContext.formatColor(uiDef.getColor("TextField.background"));
public TextInputCssContext(UIDefaults uiDef, Function<Color, String> formatColor) {
foregroundColor = formatColor.apply(uiDef.getColor("TextField.foreground"));
backgroundColor = formatColor.apply(uiDef.getColor("TextField.background"));
disabledBorderSize = "1px";
disabledBorderColor =
ThemeCssContext.formatColor(uiDef.getColor("TextField.inactiveForeground"));
disabledBorderColor = formatColor.apply(uiDef.getColor("TextField.inactiveForeground"));
}

/**
Expand Down
Loading
Loading