mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
PixelPaint: Add GUI for editing layer names :^)
This commit is contained in:
parent
955d3c22c7
commit
65ec655b0d
Notes:
sideshowbarker
2024-07-19 04:39:08 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/65ec655b0dd
4 changed files with 30 additions and 1 deletions
|
@ -69,4 +69,12 @@ void Layer::set_opacity_percent(int opacity_percent)
|
|||
m_image.layer_did_modify_properties({}, *this);
|
||||
}
|
||||
|
||||
void Layer::set_name(const String& name)
|
||||
{
|
||||
if (m_name == name)
|
||||
return;
|
||||
m_name = name;
|
||||
m_image.layer_did_modify_properties({}, *this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
Gfx::IntRect rect() const { return { {}, size() }; }
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
void set_name(const String& name) { m_name = name; }
|
||||
void set_name(const String&);
|
||||
|
||||
void did_modify_bitmap(Image&);
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <LibGUI/GroupBox.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/Slider.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGfx/Font.h>
|
||||
|
||||
namespace PixelPaint {
|
||||
|
@ -44,6 +45,24 @@ LayerPropertiesWidget::LayerPropertiesWidget()
|
|||
|
||||
layout.set_margins({ 10, 20, 10, 10 });
|
||||
|
||||
auto& name_container = group_box.add<GUI::Widget>();
|
||||
name_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
name_container.set_preferred_size(0, 20);
|
||||
name_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
||||
auto& name_label = name_container.add<GUI::Label>("Name:");
|
||||
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
name_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||
name_label.set_preferred_size(80, 20);
|
||||
|
||||
m_name_textbox = name_container.add<GUI::TextBox>();
|
||||
m_name_textbox->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_name_textbox->set_preferred_size(0, 20);
|
||||
m_name_textbox->on_change = [this] {
|
||||
if (m_layer)
|
||||
m_layer->set_name(m_name_textbox->text());
|
||||
};
|
||||
|
||||
auto& opacity_container = group_box.add<GUI::Widget>();
|
||||
opacity_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
opacity_container.set_preferred_size(0, 20);
|
||||
|
@ -83,6 +102,7 @@ void LayerPropertiesWidget::set_layer(Layer* layer)
|
|||
|
||||
if (layer) {
|
||||
m_layer = layer->make_weak_ptr();
|
||||
m_name_textbox->set_text(layer->name());
|
||||
m_opacity_slider->set_value(layer->opacity_percent());
|
||||
m_visibility_checkbox->set_checked(layer->is_visible());
|
||||
set_enabled(true);
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
|
||||
RefPtr<GUI::CheckBox> m_visibility_checkbox;
|
||||
RefPtr<GUI::HorizontalSlider> m_opacity_slider;
|
||||
RefPtr<GUI::TextBox> m_name_textbox;
|
||||
|
||||
WeakPtr<Layer> m_layer;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue