mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:58:12 +00:00
PixelPaint: Tool properties panel
Each tool can have its own set of properties that can be modified through a panel on the right side. The tools I've added properties for are: Pen: Thickness Brush: Size Hardness Spray: Thickness Density Bucket: Threshold
This commit is contained in:
parent
544f2f3c96
commit
afd52e2576
13 changed files with 324 additions and 12 deletions
|
@ -28,8 +28,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/Slider.h>
|
||||
|
||||
namespace PixelPaint {
|
||||
|
||||
|
@ -94,4 +97,33 @@ void PenTool::on_tool_button_contextmenu(GUI::ContextMenuEvent& event)
|
|||
m_context_menu->popup(event.screen_position());
|
||||
}
|
||||
|
||||
GUI::Widget* PenTool::get_properties_widget()
|
||||
{
|
||||
if (!m_properties_widget) {
|
||||
m_properties_widget = GUI::Widget::construct();
|
||||
m_properties_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto& thickness_container = m_properties_widget->add<GUI::Widget>();
|
||||
thickness_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
thickness_container.set_preferred_size(0, 20);
|
||||
thickness_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
||||
auto& thickness_label = thickness_container.add<GUI::Label>("Thickness:");
|
||||
thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
thickness_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||
thickness_label.set_preferred_size(80, 20);
|
||||
|
||||
auto& thickness_slider = thickness_container.add<GUI::HorizontalSlider>();
|
||||
thickness_slider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
thickness_slider.set_preferred_size(0, 20);
|
||||
thickness_slider.set_range(1, 20);
|
||||
thickness_slider.set_value(m_thickness);
|
||||
thickness_slider.on_value_changed = [this](int value) {
|
||||
m_thickness = value;
|
||||
};
|
||||
}
|
||||
|
||||
return m_properties_widget.ptr();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue