1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:57:35 +00:00

LibGUI: Rename CallOnChange => AllowCallback and implement elsewhere

This is a helpful option to prevent unwanted side effects, distinguish
between user and programmatic input, etc. Sliders and SpinBoxes were
implementing it idiosyncratically, so let's generalize the API and
give Buttons and TextEditors the same ability.
This commit is contained in:
thankyouverycool 2021-09-21 17:02:48 -04:00 committed by Andreas Kling
parent d47e431d54
commit 92fffc3abc
15 changed files with 40 additions and 39 deletions

View file

@ -16,13 +16,13 @@ public:
virtual ~SpinBox() override;
int value() const { return m_value; }
void set_value(int);
void set_value(int, AllowCallback = AllowCallback::Yes);
int min() const { return m_min; }
int max() const { return m_max; }
void set_min(int min) { set_range(min, max()); }
void set_max(int max) { set_range(min(), max); }
void set_range(int min, int max, bool change = true);
void set_min(int min, AllowCallback allow_callback = AllowCallback::Yes) { set_range(min, max(), allow_callback); }
void set_max(int max, AllowCallback allow_callback = AllowCallback::Yes) { set_range(min(), max, allow_callback); }
void set_range(int min, int max, AllowCallback = AllowCallback::Yes);
Function<void(int value)> on_change;