mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
PixelPaint: Move properties for RectangleTool to ToolPropertiesWidget
Remove the context menu and move the options to the tool properties widget.
This commit is contained in:
parent
3392c66c94
commit
201b901cb1
2 changed files with 34 additions and 13 deletions
|
@ -8,8 +8,11 @@
|
||||||
#include "ImageEditor.h"
|
#include "ImageEditor.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
|
#include <LibGUI/BoxLayout.h>
|
||||||
|
#include <LibGUI/Label.h>
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
|
#include <LibGUI/RadioButton.h>
|
||||||
#include <LibGfx/Rect.h>
|
#include <LibGfx/Rect.h>
|
||||||
|
|
||||||
namespace PixelPaint {
|
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) {
|
if (!m_properties_widget) {
|
||||||
m_context_menu = GUI::Menu::construct();
|
m_properties_widget = GUI::Widget::construct();
|
||||||
m_context_menu->add_action(GUI::Action::create("Fill", [this](auto&) {
|
m_properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||||
m_mode = Mode::Fill;
|
|
||||||
}));
|
auto& mode_container = m_properties_widget->add<GUI::Widget>();
|
||||||
m_context_menu->add_action(GUI::Action::create("Outline", [this](auto&) {
|
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_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;
|
m_mode = Mode::Gradient;
|
||||||
}));
|
};
|
||||||
|
|
||||||
|
outline_mode_radio.set_checked(true);
|
||||||
}
|
}
|
||||||
m_context_menu->popup(event.screen_position());
|
|
||||||
|
return m_properties_widget.ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ public:
|
||||||
virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override;
|
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_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_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_second_paint(Layer const&, GUI::PaintEvent&) override;
|
||||||
virtual void on_keydown(GUI::KeyEvent&) override;
|
virtual void on_keydown(GUI::KeyEvent&) override;
|
||||||
|
virtual GUI::Widget* get_properties_widget() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
|
@ -33,10 +33,10 @@ private:
|
||||||
|
|
||||||
void draw_using(GUI::Painter&, Gfx::IntRect const&);
|
void draw_using(GUI::Painter&, Gfx::IntRect const&);
|
||||||
|
|
||||||
|
RefPtr<GUI::Widget> m_properties_widget;
|
||||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||||
Gfx::IntPoint m_rectangle_start_position;
|
Gfx::IntPoint m_rectangle_start_position;
|
||||||
Gfx::IntPoint m_rectangle_end_position;
|
Gfx::IntPoint m_rectangle_end_position;
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
|
||||||
Mode m_mode { Mode::Outline };
|
Mode m_mode { Mode::Outline };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue