aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java48
1 files changed, 44 insertions, 4 deletions
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;
/** <h1>Create a new ColorPalette.</h1>
* 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);
+ }
+
+ /** <h1>Create a new ColorPalette.</h1>
+ * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more.
+ * <br> 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};
}
/** <h1>Create a new ColorPalette.</h1>
* 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());
}
/** <h1>Create a new ColorPalette.</h1>
* This color palette is used with animations, and the elements like BasicButton, BasicElement, and more.
- * <br> This method takes {@link Color} in ARGB format.
+ * <br> 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());
+ }
+
+ /** <h1>Create a new ColorPalette.</h1>
+ * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more.
+ * <br> 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());
}
/** <h1>Create a new ColorPalette.</h1>
@@ -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. */
@@ -118,6 +148,11 @@ public class ColorPalette {
}
/** 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;
+ }
+
}