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

@@ -53,7 +53,7 @@ void AbstractSlider::set_range(int min, int max)
update();
}
void AbstractSlider::set_value(int value, CallOnChange call_on_change)
void AbstractSlider::set_value(int value, AllowCallback allow_callback)
{
value = clamp(value, m_min, m_max);
if (m_value == value)
@@ -61,7 +61,7 @@ void AbstractSlider::set_value(int value, CallOnChange call_on_change)
m_value = value;
update();
if (on_change && call_on_change == CallOnChange::Yes)
if (on_change && allow_callback == AllowCallback::Yes)
on_change(m_value);
}