From 68cc66b387a8a6a226289132dea331e6ecf3f76b Mon Sep 17 00:00:00 2001 From: nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> Date: Wed, 1 Jun 2022 18:02:52 +0100 Subject: color palette add disabled state --- .../oneconfig/utils/color/ColorPalette.java | 48 ++++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java index c2a1fec..a233266 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java @@ -50,9 +50,11 @@ public class ColorPalette { private final int colorNormal; private final int colorHovered; private final int colorPressed; + private final int colorDisabled; private final float[] colorNormalf; private final float[] colorHoveredf; private final float[] colorPressedf; + private final float[] colorDisabledf; /**

Create a new ColorPalette.

* This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. @@ -62,12 +64,26 @@ public class ColorPalette { * @param colorPressed the color of the element when it is pressed. */ public ColorPalette(int colorNormal, int colorHovered, int colorPressed) { + this(colorNormal, colorHovered, colorPressed, colorPressed); + } + + /**

Create a new ColorPalette.

+ * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. + *
This method takes integers in ARGB format, like many other classes, such as {@link OneColor} and {@link Color}. + * @param colorNormal the color of the element when it is not hovered or pressed. + * @param colorHovered the color of the element when it is hovered. + * @param colorPressed the color of the element when it is pressed. + * @param colorDisabled the color of the element when it is disabled. + */ + public ColorPalette(int colorNormal, int colorHovered, int colorPressed, int colorDisabled) { this.colorNormal = colorNormal; this.colorHovered = colorHovered; this.colorPressed = colorPressed; + this.colorDisabled = colorDisabled; this.colorNormalf = new float[]{ColorUtils.getRed(colorNormal) / 255f, ColorUtils.getGreen(colorNormal) / 255f, ColorUtils.getBlue(colorNormal) / 255f, ColorUtils.getAlpha(colorNormal) / 255f}; this.colorHoveredf = new float[]{ColorUtils.getRed(colorHovered) / 255f, ColorUtils.getGreen(colorHovered) / 255f, ColorUtils.getBlue(colorHovered) / 255f, ColorUtils.getAlpha(colorHovered) / 255f}; this.colorPressedf = new float[]{ColorUtils.getRed(colorPressed) / 255f, ColorUtils.getGreen(colorPressed) / 255f, ColorUtils.getBlue(colorPressed) / 255f, ColorUtils.getAlpha(colorPressed) / 255f}; + this.colorDisabledf = new float[]{ColorUtils.getRed(colorDisabled) / 255f, ColorUtils.getGreen(colorDisabled) / 255f, ColorUtils.getBlue(colorDisabled) / 255f, ColorUtils.getAlpha(colorDisabled) / 255f}; } /**

Create a new ColorPalette.

* This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. @@ -77,18 +93,30 @@ public class ColorPalette { * @param colorPressed the color of the element when it is pressed. */ public ColorPalette(OneColor colorNormal, OneColor colorHovered, OneColor colorPressed) { - this(colorNormal.getRGB(), colorHovered.getRGB(), colorPressed.getRGB()); + this(colorNormal.getRGB(), colorHovered.getRGB(), colorPressed.getRGB(), colorPressed.getRGB()); } /**

Create a new ColorPalette.

* This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. - *
This method takes {@link Color} in ARGB format. + *
This method takes {@link Color} in ARGB format. Disabled color is made from a darker version of the clicked color. * @param colorNormal the color of the element when it is not hovered or pressed. * @param colorHovered the color of the element when it is hovered. * @param colorPressed the color of the element when it is pressed. */ public ColorPalette(Color colorNormal, Color colorHovered, Color colorPressed) { - this(colorNormal.getRGB(), colorHovered.getRGB(), colorPressed.getRGB()); + this(colorNormal.getRGB(), colorHovered.getRGB(), colorPressed.getRGB(), colorPressed.darker().getRGB()); + } + + /**

Create a new ColorPalette.

+ * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. + *
This method takes {@link Color} in ARGB format. + * @param colorNormal the color of the element when it is not hovered or pressed. + * @param colorHovered the color of the element when it is hovered. + * @param colorPressed the color of the element when it is pressed. + * @param colorDisabled the color of the element when it is disabled. + */ + public ColorPalette(Color colorNormal, Color colorHovered, Color colorPressed, Color colorDisabled) { + this(colorNormal.getRGB(), colorHovered.getRGB(), colorPressed.getRGB(), colorDisabled.getRGB()); } /**

Create a new ColorPalette.

@@ -98,13 +126,15 @@ public class ColorPalette { * @param colorHovered the color of the element when it is hovered. * @param colorPressed the color of the element when it is pressed. */ - public ColorPalette(float[] colorNormal, float[] colorHovered, float[] colorPressed) { + public ColorPalette(float[] colorNormal, float[] colorHovered, float[] colorPressed, float[] colorDisabled) { this.colorNormalf = colorNormal; this.colorHoveredf = colorHovered; this.colorPressedf = colorPressed; + this.colorDisabledf = colorDisabled; this.colorNormal = ColorUtils.getColor(colorNormal[0], colorNormal[1], colorNormal[2], colorNormal[3]); this.colorHovered = ColorUtils.getColor(colorHovered[0], colorHovered[1], colorHovered[2], colorHovered[3]); this.colorPressed = ColorUtils.getColor(colorPressed[0], colorPressed[1], colorPressed[2], colorPressed[3]); + this.colorDisabled = ColorUtils.getColor(colorDisabled[0], colorDisabled[1], colorDisabled[2], colorDisabled[3]); } /** Return the color of the element when it is not hovered or pressed in ARGB format. */ @@ -117,6 +147,11 @@ public class ColorPalette { return colorHovered; } + /** Return the color of the element when it is pressed in ARGB format. */ + public int getDisabledColor() { + return colorDisabled; + } + /** Return the color of the element when it is pressed in ARGB format. */ public int getPressedColor() { return colorPressed; @@ -137,4 +172,9 @@ public class ColorPalette { return colorPressedf; } + /** Return the color of the element when it is disabled in a float array (r,g,b,a). */ + public float[] getDisabledColorf() { + return colorDisabledf; + } + } -- cgit