From 65c8dfe923ed6b2be84e11dcdd45636222ca4d5a Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 2 Feb 2023 17:09:27 +0000 Subject: [PATCH] LibGUI: Convert AboutDialog layout to GML --- Userland/Libraries/LibGUI/AboutDialog.cpp | 58 ++++------------ Userland/Libraries/LibGUI/AboutDialog.gml | 83 +++++++++++++++++++++++ Userland/Libraries/LibGUI/CMakeLists.txt | 2 + 3 files changed, 99 insertions(+), 44 deletions(-) create mode 100644 Userland/Libraries/LibGUI/AboutDialog.gml diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index b05648b947..27a6e56f63 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -1,12 +1,14 @@ /* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. + * Copyright (c) 2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #include #include +#include #include #include #include @@ -31,56 +33,24 @@ AboutDialog::AboutDialog(StringView name, StringView version, Gfx::Bitmap const* set_icon(parent_window->icon()); auto widget = set_main_widget().release_value_but_fixme_should_propagate_errors(); - widget->set_fill_with_background_color(true); - widget->set_layout(); - widget->layout()->set_spacing(0); - - auto& banner_image = widget->add(); - banner_image.load_from_file("/res/graphics/brand-banner.png"sv); - - auto& content_container = widget->add(); - content_container.set_layout(); - - auto& left_container = content_container.add(); - left_container.set_fixed_width(60); - left_container.set_layout(); - left_container.layout()->set_margins({ 12, 0, 0 }); + widget->load_from_gml(about_dialog_gml).release_value_but_fixme_should_propagate_errors(); + auto icon_wrapper = find_descendant_of_type_named("icon_wrapper"); if (icon) { - auto& icon_wrapper = left_container.add(); - icon_wrapper.set_fixed_size(32, 48); - icon_wrapper.set_layout(); - - auto& icon_image = icon_wrapper.add(); - icon_image.set_bitmap(m_icon); + icon_wrapper->set_visible(true); + auto icon_image = find_descendant_of_type_named("icon"); + icon_image->set_bitmap(m_icon); + } else { + icon_wrapper->set_visible(false); } - auto& right_container = content_container.add(); - right_container.set_layout(); - right_container.layout()->set_margins({ 12, 4, 4, 0 }); - - auto make_label = [&](StringView text, bool bold = false) { - auto& label = right_container.add