Color Picker Rewrite - Alpha Slider & Presets, Color Pickers Everywhere!#148
Open
Superkat32 wants to merge 9 commits into
Open
Color Picker Rewrite - Alpha Slider & Presets, Color Pickers Everywhere!#148Superkat32 wants to merge 9 commits into
Superkat32 wants to merge 9 commits into
Conversation
I would have waited longer to commit this, but there is a Windows update and I'm afraid of it destroying my progress
Awakened-Redstone
self-requested a review
July 18, 2026 00:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewrites the ColorPickerWidget from scratch, focusing on reduced repeated code, ease of use(implementation), and maintainability (I hope).
User Facing Changes:
Color Picker Widgets are now available on the following edit screens: Text Block & Properties, Sprite Block, Outline Block, Popup Block, and Note Item.
The Color Picker now has an alpha slider and alpha value presets if the color entry supports an alpha value. Each alpha value preset has some text indicating its hexadecimal value.
Each Color Picker Area (sat/value gradient, hue bar, presets) will be outlined when hovered or dragged. With that, the cursor will only display the pointer if something can be clicked, instead of when over the entire color picker.
The Color Picker is ever so slightly taller now (I think like 8 pixels, only affects preview area & sat/value area).
The Color Picker's hue bar now spans its entire length, instead of being cut off by a few pixels.
The Text Block's edit screen now contains its background color entry, and its "More..." button to open the Properties screen has been replaced with a gear icon.
The Text Block's "Color" and "Background Color" text translation keys have been changed to "Color (ARGB)" and "Background Color (ARGB)" to better indicate the hex code format.
General Internal Changes
A new
HexColorEditBoxwidget has been added specifically for color entries. It automatically handles converting between String HEX codes & color integers, and automatically sets any target(e.g. block entity)'s color using theColorSetterfunctional interface. It also comes with built in Color Picker support if you give it the Screen's ColorPickerWidget.The
ColorPickerIncludedScreeninterface has had multiple methods given default code, including handling rendering, clicking, and key pressing for the ColorPickerWidget, only needing itsgetColorPickerWidget()method to be implemented. This combined with theHexColorEditBoxmakes it much easier to include color pickers into new screens.Added methods for converting to and from HSV and RGB to
ColorUtil, and removed all instances ofjava.awt.Color. The conversion methods were taken fromjava.awt.Color, and are used in favor of awt's Color class because of some shenanigans with awt's Color class sometimes causing issues for Macs. Ask Falkreon for more info, or see this comment.Added
GuiGraphicsUtilfor horizontal gradients, hue gradient, and precise (float position instead of int) texture drawing for GUI extraction. Helps keep the ColorPickerWidget class slightly cleaner :)Color Picker Internal Changes
The Color Picker has been split up into multiple
PickerAreas, which contain positions, boundaries, andColorSetters for what to do when clicked. Overall, this helps reduce repeated code for checking if the hue bar or sat/value area or anything else was clicked and needing to set their values.The Color Picker's width and height are practically hard-coded now, instead of attempting some amount of dynamic scaling. With that, presets are now required instead of being toggleable. Both of these makes everything so much simpler and kept me from going insane. I did include comments about how I landed on most of the numbers, though.
The Color Picker now automatically hides itself and handles reverting/undoing color on cancel, instead of leaving those to the widget using Screen.
Removed
ColorPresetWidgetand the confirm/cancel button's usage ofButtonWidgetsin favor ofPickerPresetandPickerButtonareas (it was so annoying trying to combine widgets and custom stuff lol).All internal references of a color's brightness have been renamed from "light" to "value." I found out there's a difference, and I believe "value" is more accurate to what we have.
In theory, the Color Picker's render extraction should be slightly more efficient, as it now calculates the positions of everything upon targeting a widget, instead of every render extraction.
A majority of the methods and logic have been simplified I think (more assumptions are made about what logic to default to, like picker position upon target and what to do when a preset is clicked). I think there's like one or two more things here but I can't remember, I spent like 45 minutes writing this lol
Any changes can be made as needed. Thanks!