From 69ffdd5738faf94563be4e983e8b584058dfa321 Mon Sep 17 00:00:00 2001 From: "Mr.UNIX" Date: Fri, 19 Jan 2024 22:09:21 +0100 Subject: [PATCH] Welcome: Port to GML Compiler --- Userland/Applications/Welcome/CMakeLists.txt | 7 ++----- Userland/Applications/Welcome/WelcomeWidget.cpp | 9 ++++----- Userland/Applications/Welcome/WelcomeWidget.h | 5 ++++- Userland/Applications/Welcome/WelcomeWindow.gml | 8 ++++---- Userland/Applications/Welcome/main.cpp | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Userland/Applications/Welcome/CMakeLists.txt b/Userland/Applications/Welcome/CMakeLists.txt index 1cb6b01bd1..92936a78b1 100644 --- a/Userland/Applications/Welcome/CMakeLists.txt +++ b/Userland/Applications/Welcome/CMakeLists.txt @@ -4,16 +4,13 @@ serenity_component( DEPENDS Help WebContent ) -stringify_gml(WelcomeWindow.gml WelcomeWindowGML.h welcome_window_gml) +compile_gml(WelcomeWindow.gml WelcomeWindowGML.cpp) set(SOURCES + WelcomeWindowGML.cpp WelcomeWidget.cpp main.cpp ) -set(GENERATED_SOURCES - WelcomeWindowGML.h -) - serenity_app(Welcome ICON app-welcome) target_link_libraries(Welcome PRIVATE LibConfig LibCore LibGfx LibGUI LibWebView LibWeb LibMain) diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp index cdb3d718b5..318d5c9951 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.cpp +++ b/Userland/Applications/Welcome/WelcomeWidget.cpp @@ -7,7 +7,6 @@ #include "WelcomeWidget.h" #include #include -#include #include #include #include @@ -19,9 +18,10 @@ #include #include -ErrorOr> WelcomeWidget::try_create() +namespace Welcome { +ErrorOr> WelcomeWidget::create() { - auto welcome_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) WelcomeWidget())); + auto welcome_widget = TRY(WelcomeWidget::try_create()); TRY(welcome_widget->create_widgets()); return welcome_widget; @@ -29,8 +29,6 @@ ErrorOr> WelcomeWidget::try_create() ErrorOr WelcomeWidget::create_widgets() { - TRY(load_from_gml(welcome_window_gml)); - m_banner_widget = find_descendant_of_type_named("welcome_banner"); m_banner_font = TRY(Gfx::BitmapFont::try_load_from_uri("resource://fonts/MarietaRegular24.font"sv)); @@ -130,3 +128,4 @@ void WelcomeWidget::paint_event(GUI::PaintEvent& event) rect.set_x(rect.x() + static_cast(ceilf(m_banner_font->bold_variant().width("Serenity"sv)))); painter.draw_text(rect, "OS"sv, m_banner_font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().tray_text()); } +} diff --git a/Userland/Applications/Welcome/WelcomeWidget.h b/Userland/Applications/Welcome/WelcomeWidget.h index 744d60b28d..0cc3a20c13 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.h +++ b/Userland/Applications/Welcome/WelcomeWidget.h @@ -10,16 +10,18 @@ #include #include +namespace Welcome { class WelcomeWidget final : public GUI::Widget { C_OBJECT(WelcomeWidget); public: - static ErrorOr> try_create(); + static ErrorOr> create(); virtual ~WelcomeWidget() override = default; private: WelcomeWidget() = default; ErrorOr create_widgets(); + static ErrorOr> try_create(); virtual void paint_event(GUI::PaintEvent&) override; @@ -41,3 +43,4 @@ private: size_t m_tip_index { 0 }; Vector m_tips; }; +} diff --git a/Userland/Applications/Welcome/WelcomeWindow.gml b/Userland/Applications/Welcome/WelcomeWindow.gml index 63ce306bee..b3d447424c 100644 --- a/Userland/Applications/Welcome/WelcomeWindow.gml +++ b/Userland/Applications/Welcome/WelcomeWindow.gml @@ -1,4 +1,4 @@ -@GUI::Widget { +@Welcome::WelcomeWidget { fill_with_background_color: true layout: @GUI::VerticalBoxLayout { margins: [8] @@ -56,7 +56,7 @@ @GUI::Label { name: "tip_label" text_alignment: "TopLeft" - word_wrap: true + text_wrapping: "Wrap" font_size: 12 } } @@ -91,13 +91,13 @@ @GUI::Button { name: "help_button" text: "Help Contents" - icon: "/res/icons/16x16/book-open.png" + icon_from_path: "/res/icons/16x16/book-open.png" } @GUI::Button { name: "next_button" text: "Next Tip" - icon: "/res/icons/16x16/go-forward.png" + icon_from_path: "/res/icons/16x16/go-forward.png" } @GUI::Layout::Spacer {} diff --git a/Userland/Applications/Welcome/main.cpp b/Userland/Applications/Welcome/main.cpp index da1241ea49..6da0dd3038 100644 --- a/Userland/Applications/Welcome/main.cpp +++ b/Userland/Applications/Welcome/main.cpp @@ -32,7 +32,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->center_on_screen(); window->set_title("Welcome"); window->set_icon(app_icon.bitmap_for_size(16)); - auto welcome_widget = TRY(WelcomeWidget::try_create()); + auto welcome_widget = TRY(Welcome::WelcomeWidget::create()); window->set_main_widget(welcome_widget); window->show();