|
@@ -23,7 +23,7 @@ ColorInput::ColorInput()
|
|
|
TextEditor::on_change = [this] {
|
|
|
auto parsed_color = Color::from_string(text());
|
|
|
if (parsed_color.has_value())
|
|
|
- set_color_without_changing_text(parsed_color.value());
|
|
|
+ set_color_internal(parsed_color.value(), AllowCallback::Yes, false);
|
|
|
};
|
|
|
|
|
|
REGISTER_STRING_PROPERTY("color_picker_title", color_picker_title, set_color_picker_title);
|
|
@@ -37,21 +37,21 @@ Gfx::IntRect ColorInput::color_rect() const
|
|
|
return { width() - color_box_size - color_box_padding, color_box_padding, color_box_size, color_box_size };
|
|
|
}
|
|
|
|
|
|
-void ColorInput::set_color_without_changing_text(Color color)
|
|
|
+void ColorInput::set_color_internal(Color color, AllowCallback allow_callback, bool change_text)
|
|
|
{
|
|
|
if (m_color == color)
|
|
|
return;
|
|
|
m_color = color;
|
|
|
+ if (change_text)
|
|
|
+ set_text(m_color_has_alpha_channel ? color.to_string() : color.to_string_without_alpha(), AllowCallback::No);
|
|
|
update();
|
|
|
- if (on_change)
|
|
|
+ if (allow_callback == AllowCallback::Yes && on_change)
|
|
|
on_change();
|
|
|
}
|
|
|
|
|
|
-void ColorInput::set_color(Color color)
|
|
|
+void ColorInput::set_color(Color color, AllowCallback allow_callback)
|
|
|
{
|
|
|
- if (m_color == color)
|
|
|
- return;
|
|
|
- set_text(m_color_has_alpha_channel ? color.to_string() : color.to_string_without_alpha());
|
|
|
+ set_color_internal(color, allow_callback, true);
|
|
|
};
|
|
|
|
|
|
void ColorInput::mousedown_event(MouseEvent& event)
|