Refactor of ColorPicker#62075
Conversation
ba983e2 to
a84ac3b
Compare
There was a problem hiding this comment.
I wonder if there's a way to avoid allocating memory on the heap, theoretically if it's just returning 5 pointers, then it shouldn't need to. Probably doesn't matter that much though.
|
Docs are failing because you need to update the class reference: https://docs.godotengine.org/en/stable/community/contributing/updating_the_class_reference.html#updating-the-documentation-template |
Thanks, will apply them :) |
a84ac3b to
47a4c0c
Compare
|
For |
There was a problem hiding this comment.
Hard coded, suggest using current_sliders_count instead of 4
There was a problem hiding this comment.
This needs to apply to all sliders. It could use a constant though.
There was a problem hiding this comment.
In this case, it can be 4, and there is no need to write the following alpha_scroll separately.
There was a problem hiding this comment.
alpha_scroll is actually separate from the 4 sliders.
The 4th slider is unused for now. It's potentially useful for CMYK or other color mode with more sliders (if there is any...). Although maybe it could be removed for now 🤔 This would be trivial if 4 was a constant not hard-coded.
There was a problem hiding this comment.
So it's better to use current_sliders_count, which is reset according to the mode in ColorPicker::_update_controls.
There was a problem hiding this comment.
Should I define a constant with 3 as its value? we will change it to 4 in future if needed.
There was a problem hiding this comment.
alpha_scrollis actually separate from the 4 sliders. The 4th slider is unused for now. It's potentially useful for CMYK or other color mode with more sliders (if there is any...). Although maybe it could be removed for now 🤔 This would be trivial if 4 was a constant not hard-coded.
What if element 0 was always used for the alpha slider, and then all the code duplication with the other sliders and the alpha slider wouldn't be necessary? Would that work? 🤔
There was a problem hiding this comment.
This shouldn't exist. Any code related to specific color modes should be handled by these modes.
There was a problem hiding this comment.
There are checks for color mode being HSV or OKHSL in _w_input.
There was a problem hiding this comment.
Yeah but this is more related to shapes than color modes. Maybe it's possible to handle it more nicely.
There was a problem hiding this comment.
Is this condition necessary?
You can set h/s/v even for modes that don't need it.
There was a problem hiding this comment.
Did this as it was checking for HSV mode previously but the call to _set_pick_color will do this anyway. Will remove this condition.
|
Ok I looked through the code. Not all of it, but:
|
This will be done in a follow-up PR.
It was briefly discussed in #31679, but didn't gain much interest. |
Thanks for the review, will fix these bugs :) |
Is this still needs to done even if the OptionButton to change shape will be added?
Not able to reproduce this, am I doing something wrong?
This was happening before too, but I will see if I can fix this. |
eeba57f to
67fbd7c
Compare
Yes I think so, because OKHSV only works with the circle shape. I'd expect that the shape would be temporarily overridden while in OKHSV mode and then go back whenever switching to another mode. If an OptionButton for changing shape is added, then the button should probably be
Ok, I'll try to figure out how to reproduce it. Maybe it only happens under certain conditions? |
|
I noticed that when you set picker shape to OKHSL circle and color mode to OKHSL in a ColorPicker node and then start the project, the picker will change to square when you change color mode at runtime. The problem is property order. Color mode comes before picker shape, so when ColorPicker is created, it assumes the square mode to be "last_shape". So setting picker shape has no effect. I see two solutions to this:
|
|
I looked through the whole code and aside from some comments I left (especially the one about |
In constructor of ColorPicker we were doing |
|
Unfortunately using |
ec38f9d to
bc372f9
Compare
KoBeWi
left a comment
There was a problem hiding this comment.
Looks like there are no major problems left. Aside from the comments I just left, some details can still be improved later.
|
Last thing you'll probably want to do is squash the commits :) |
|
Thanks! |














This PR covers the refactoring part of Refactor and UX Updates of ColorPicker GSoC'22 project with @akien-mga and @KoBeWi as mentors. The original proposal for refactoring can be found here and the wireframes for UX updates can be found here.