diff --git a/Userland/Applications/PixelPaint/LineTool.cpp b/Userland/Applications/PixelPaint/LineTool.cpp index 8514e0bf32..31040725a6 100644 --- a/Userland/Applications/PixelPaint/LineTool.cpp +++ b/Userland/Applications/PixelPaint/LineTool.cpp @@ -9,8 +9,11 @@ #include "Layer.h" #include #include +#include +#include #include #include +#include namespace PixelPaint { @@ -97,25 +100,30 @@ void LineTool::on_keydown(GUI::KeyEvent& event) } } -void LineTool::on_tool_button_contextmenu(GUI::ContextMenuEvent& event) +GUI::Widget* LineTool::get_properties_widget() { - if (!m_context_menu) { - m_context_menu = GUI::Menu::construct(); - m_thickness_actions.set_exclusive(true); - auto insert_action = [&](int size, bool checked = false) { - auto action = GUI::Action::create_checkable(String::number(size), [this, size](auto&) { - m_thickness = size; - }); - action->set_checked(checked); - m_thickness_actions.add_action(*action); - m_context_menu->add_action(move(action)); + if (!m_properties_widget) { + m_properties_widget = GUI::Widget::construct(); + m_properties_widget->set_layout(); + + auto& thickness_container = m_properties_widget->add(); + thickness_container.set_fixed_height(20); + thickness_container.set_layout(); + + auto& thickness_label = thickness_container.add("Thickness:"); + thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); + thickness_label.set_fixed_size(80, 20); + + auto& thickness_slider = thickness_container.add(); + thickness_slider.set_fixed_height(20); + thickness_slider.set_range(1, 10); + thickness_slider.set_value(m_thickness); + thickness_slider.on_change = [&](int value) { + m_thickness = value; }; - insert_action(1, true); - insert_action(2); - insert_action(3); - insert_action(4); } - m_context_menu->popup(event.screen_position()); + + return m_properties_widget.ptr(); } } diff --git a/Userland/Applications/PixelPaint/LineTool.h b/Userland/Applications/PixelPaint/LineTool.h index 20c8f29eb7..d61cf1bd9d 100644 --- a/Userland/Applications/PixelPaint/LineTool.h +++ b/Userland/Applications/PixelPaint/LineTool.h @@ -20,17 +20,16 @@ public: virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; - virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) override; virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; + virtual GUI::Widget* get_properties_widget() override; private: + RefPtr m_properties_widget; + GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; Gfx::IntPoint m_line_start_position; Gfx::IntPoint m_line_end_position; - - RefPtr m_context_menu; - GUI::ActionGroup m_thickness_actions; int m_thickness { 1 }; };