summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorMarcus Nilsson <brainbomb@gmail.com>2021-08-02 22:51:12 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-03 09:04:57 +0200
commit201b901cb1124f9f260a00fe238119a03ba727b7 (patch)
tree7b28ab91ae609222068344272e62c0ebc119b08a /Userland
parent3392c66c94a7227ca45e3b173c270b067fcd456f (diff)
downloadserenity-201b901cb1124f9f260a00fe238119a03ba727b7.zip
PixelPaint: Move properties for RectangleTool to ToolPropertiesWidget
Remove the context menu and move the options to the tool properties widget.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/RectangleTool.cpp43
-rw-r--r--Userland/Applications/PixelPaint/RectangleTool.h4
2 files changed, 34 insertions, 13 deletions
diff --git a/Userland/Applications/PixelPaint/RectangleTool.cpp b/Userland/Applications/PixelPaint/RectangleTool.cpp
index 239d4d82b7..fde6e4a8ee 100644
--- a/Userland/Applications/PixelPaint/RectangleTool.cpp
+++ b/Userland/Applications/PixelPaint/RectangleTool.cpp
@@ -8,8 +8,11 @@
#include "ImageEditor.h"
#include "Layer.h"
#include <LibGUI/Action.h>
+#include <LibGUI/BoxLayout.h>
+#include <LibGUI/Label.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Painter.h>
+#include <LibGUI/RadioButton.h>
#include <LibGfx/Rect.h>
namespace PixelPaint {
@@ -96,21 +99,39 @@ void RectangleTool::on_keydown(GUI::KeyEvent& event)
}
}
-void RectangleTool::on_tool_button_contextmenu(GUI::ContextMenuEvent& event)
+GUI::Widget* RectangleTool::get_properties_widget()
{
- if (!m_context_menu) {
- m_context_menu = GUI::Menu::construct();
- m_context_menu->add_action(GUI::Action::create("Fill", [this](auto&) {
- m_mode = Mode::Fill;
- }));
- m_context_menu->add_action(GUI::Action::create("Outline", [this](auto&) {
+ if (!m_properties_widget) {
+ m_properties_widget = GUI::Widget::construct();
+ m_properties_widget->set_layout<GUI::VerticalBoxLayout>();
+
+ auto& mode_container = m_properties_widget->add<GUI::Widget>();
+ mode_container.set_fixed_height(70);
+ mode_container.set_layout<GUI::HorizontalBoxLayout>();
+ auto& mode_label = mode_container.add<GUI::Label>("Mode:");
+ mode_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
+ mode_label.set_fixed_size(80, 20);
+
+ auto& mode_radio_container = mode_container.add<GUI::Widget>();
+ mode_radio_container.set_layout<GUI::VerticalBoxLayout>();
+ auto& outline_mode_radio = mode_radio_container.add<GUI::RadioButton>("Outline");
+ auto& fill_mode_radio = mode_radio_container.add<GUI::RadioButton>("Fill");
+ auto& gradient_mode_radio = mode_radio_container.add<GUI::RadioButton>("Gradient");
+
+ outline_mode_radio.on_checked = [&](bool) {
m_mode = Mode::Outline;
- }));
- m_context_menu->add_action(GUI::Action::create("Gradient", [this](auto&) {
+ };
+ fill_mode_radio.on_checked = [&](bool) {
+ m_mode = Mode::Fill;
+ };
+ gradient_mode_radio.on_checked = [&](bool) {
m_mode = Mode::Gradient;
- }));
+ };
+
+ outline_mode_radio.set_checked(true);
}
- m_context_menu->popup(event.screen_position());
+
+ return m_properties_widget.ptr();
}
}
diff --git a/Userland/Applications/PixelPaint/RectangleTool.h b/Userland/Applications/PixelPaint/RectangleTool.h
index 52c74d8668..5395f73605 100644
--- a/Userland/Applications/PixelPaint/RectangleTool.h
+++ b/Userland/Applications/PixelPaint/RectangleTool.h
@@ -20,9 +20,9 @@ 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:
enum class Mode {
@@ -33,10 +33,10 @@ private:
void draw_using(GUI::Painter&, Gfx::IntRect const&);
+ RefPtr<GUI::Widget> m_properties_widget;
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
Gfx::IntPoint m_rectangle_start_position;
Gfx::IntPoint m_rectangle_end_position;
- RefPtr<GUI::Menu> m_context_menu;
Mode m_mode { Mode::Outline };
};