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

Refactor ColorPicker shapes #99515

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Nov 21, 2024

Closes godotengine/godot-proposals#4353
Basically #62075, but for picker shapes.

Adds a new class ColorPickerShape, which is an abstraction of picker shapes (similar to ColorMode). This allows to split some behemoth methods into a more manageable pieces. For now I removed the huge _hsv_draw() method, which had entangled code for drawing every piece of ColorPicker. Now each part has its own method. The shapes should appear as before.

TODO:

  • Re-implement shape input (this will be tricky; I did one, but the code can be better)
  • Rework initialization of shape controls to only create them when requested (right now the internal control count is a bit higher than before, because shapes don't share them)
  • Cleanup


ColorPickerShapeRectangle::ColorPickerShapeRectangle(ColorPicker *p_color_picker) :
ColorPickerShape(p_color_picker) {
int64_t self = reinterpret_cast<int64_t>(this); // Hack to allow connecting non-Object methods.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this hack, but I didn't have better idea. Alternative is making the shapes Object/RefCounted, but that would make them heavier than necessary (and each ColorPicker has a copy). It would make the code cleaner though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor ColorPicker
1 participant