1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 09:37:34 +00:00

PixelPaint: Propagate errors from making tool property widgets

This commit is contained in:
Karol Kosek 2023-02-12 00:04:02 +01:00 committed by Sam Atkins
parent b409a40377
commit be717edd33
41 changed files with 499 additions and 468 deletions

View file

@ -176,29 +176,30 @@ void GuideTool::on_tool_activation()
m_editor->set_guide_visibility(true);
}
GUI::Widget* GuideTool::get_properties_widget()
ErrorOr<GUI::Widget*> GuideTool::get_properties_widget()
{
if (!m_properties_widget) {
m_properties_widget = GUI::Widget::construct();
m_properties_widget->set_layout<GUI::VerticalBoxLayout>();
auto properties_widget = TRY(GUI::Widget::try_create());
(void)TRY(properties_widget->try_set_layout<GUI::VerticalBoxLayout>());
auto& snapping_container = m_properties_widget->add<GUI::Widget>();
snapping_container.set_fixed_height(20);
snapping_container.set_layout<GUI::HorizontalBoxLayout>();
auto snapping_container = TRY(properties_widget->try_add<GUI::Widget>());
snapping_container->set_fixed_height(20);
(void)TRY(snapping_container->try_set_layout<GUI::HorizontalBoxLayout>());
auto& snapping_label = snapping_container.add<GUI::Label>("Snap offset:");
snapping_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
snapping_label.set_fixed_size(80, 20);
snapping_label.set_tooltip("Press Shift to snap");
auto snapping_label = TRY(snapping_container->try_add<GUI::Label>("Snap offset:"));
snapping_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
snapping_label->set_fixed_size(80, 20);
snapping_label->set_tooltip("Press Shift to snap");
auto& snapping_slider = snapping_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv));
snapping_slider.set_range(0, 50);
snapping_slider.set_value(m_snap_size);
auto snapping_slider = TRY(snapping_container->try_add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)));
snapping_slider->set_range(0, 50);
snapping_slider->set_value(m_snap_size);
snapping_slider.on_change = [&](int value) {
snapping_slider->on_change = [this](int value) {
m_snap_size = value;
};
set_primary_slider(&snapping_slider);
set_primary_slider(snapping_slider);
m_properties_widget = properties_widget;
}
return m_properties_widget.ptr();