mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
LibGUI: Make GUI::ColorPicker
interactive
There is now a `on_color_changed` callback that clients can optionally hook into to receive real-time updates while the user is picking a color. If the user hits Cancel, the callback gets called once more with the color passed in while constructing `ColorPicker`. If the user hits OK, the same happens with the currently selected color instead. Programs therefore can perform all their updates with this callback, and only care about `ExecResult` if they want to make a decision, like if we should write the result to `ConfigServer`, for example.
This commit is contained in:
parent
ca1a98ba9f
commit
825c9eaeb1
3 changed files with 13 additions and 2 deletions
|
@ -26,6 +26,7 @@ public:
|
|||
bool color_has_alpha_channel() const { return m_color_has_alpha_channel; }
|
||||
void set_color_has_alpha_channel(bool);
|
||||
Color color() const { return m_color; }
|
||||
Function<void(Color)> on_color_changed;
|
||||
|
||||
private:
|
||||
explicit ColorPicker(Color, Window* parent_window = nullptr, DeprecatedString title = "Color Picker");
|
||||
|
@ -36,6 +37,7 @@ private:
|
|||
void update_color_widgets();
|
||||
void create_color_button(Widget& container, unsigned rgb);
|
||||
|
||||
Color m_original_color;
|
||||
Color m_color;
|
||||
bool m_color_has_alpha_channel { true };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue