mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
PixelPaint: ColorPicker updates user colors while dragging
Now the user can hold primary and/or secondary mouse buttons and move the mouse around while previewing the color on the statusbar and fine tune their selection. The color will update live so the color selected when mouse is released is the final color used.
This commit is contained in:
parent
29665668b6
commit
ab8522aa17
3 changed files with 22 additions and 2 deletions
|
@ -350,9 +350,9 @@ void ImageEditor::set_editor_color_to_color_at_mouse_position(GUI::MouseEvent co
|
||||||
if (!color.alpha())
|
if (!color.alpha())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.button() == GUI::MouseButton::Primary)
|
if (event.buttons() & GUI::MouseButton::Primary)
|
||||||
set_primary_color(color);
|
set_primary_color(color);
|
||||||
else if (event.button() == GUI::MouseButton::Secondary)
|
if (event.buttons() & GUI::MouseButton::Secondary)
|
||||||
set_secondary_color(color);
|
set_secondary_color(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,24 @@ void PickerTool::on_mousedown(Layer* layer, MouseEvent& event)
|
||||||
m_editor->set_editor_color_to_color_at_mouse_position(layer_event, m_sample_all_layers);
|
m_editor->set_editor_color_to_color_at_mouse_position(layer_event, m_sample_all_layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PickerTool::on_mouseup(Layer*, MouseEvent& event)
|
||||||
|
{
|
||||||
|
auto layer_event = event.layer_event();
|
||||||
|
if (layer_event.buttons() & GUI::MouseButton::Primary || layer_event.buttons() & GUI::MouseButton::Secondary)
|
||||||
|
return;
|
||||||
|
m_editor->set_appended_status_info(DeprecatedString::empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PickerTool::on_mousemove(Layer* layer, MouseEvent& event)
|
||||||
|
{
|
||||||
|
if (!layer)
|
||||||
|
return;
|
||||||
|
auto layer_event = event.layer_event();
|
||||||
|
if (!(layer_event.buttons() & GUI::MouseButton::Primary || layer_event.buttons() & GUI::MouseButton::Secondary))
|
||||||
|
return;
|
||||||
|
m_editor->set_editor_color_to_color_at_mouse_position(layer_event, m_sample_all_layers);
|
||||||
|
}
|
||||||
|
|
||||||
GUI::Widget* PickerTool::get_properties_widget()
|
GUI::Widget* PickerTool::get_properties_widget()
|
||||||
{
|
{
|
||||||
if (!m_properties_widget) {
|
if (!m_properties_widget) {
|
||||||
|
|
|
@ -18,6 +18,8 @@ public:
|
||||||
virtual ~PickerTool() override = default;
|
virtual ~PickerTool() override = default;
|
||||||
|
|
||||||
virtual void on_mousedown(Layer*, MouseEvent&) override;
|
virtual void on_mousedown(Layer*, MouseEvent&) override;
|
||||||
|
virtual void on_mouseup(Layer*, MouseEvent&) override;
|
||||||
|
virtual void on_mousemove(Layer*, MouseEvent&) override;
|
||||||
|
|
||||||
virtual GUI::Widget* get_properties_widget() override;
|
virtual GUI::Widget* get_properties_widget() override;
|
||||||
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Eyedropper; }
|
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Eyedropper; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue