mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Welcome: Port to GML Compiler
This commit is contained in:
parent
0a4ef6f3b7
commit
69ffdd5738
|
@ -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)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "WelcomeWidget.h"
|
||||
#include <AK/Random.h>
|
||||
#include <AK/String.h>
|
||||
#include <Applications/Welcome/WelcomeWindowGML.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -19,9 +18,10 @@
|
|||
#include <LibGUI/Process.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
ErrorOr<NonnullRefPtr<WelcomeWidget>> WelcomeWidget::try_create()
|
||||
namespace Welcome {
|
||||
ErrorOr<NonnullRefPtr<WelcomeWidget>> 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<NonnullRefPtr<WelcomeWidget>> WelcomeWidget::try_create()
|
|||
|
||||
ErrorOr<void> WelcomeWidget::create_widgets()
|
||||
{
|
||||
TRY(load_from_gml(welcome_window_gml));
|
||||
|
||||
m_banner_widget = find_descendant_of_type_named<GUI::Widget>("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<int>(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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,16 +10,18 @@
|
|||
#include <LibGfx/Font/BitmapFont.h>
|
||||
#include <LibWebView/OutOfProcessWebView.h>
|
||||
|
||||
namespace Welcome {
|
||||
class WelcomeWidget final : public GUI::Widget {
|
||||
C_OBJECT(WelcomeWidget);
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<WelcomeWidget>> try_create();
|
||||
static ErrorOr<NonnullRefPtr<WelcomeWidget>> create();
|
||||
virtual ~WelcomeWidget() override = default;
|
||||
|
||||
private:
|
||||
WelcomeWidget() = default;
|
||||
ErrorOr<void> create_widgets();
|
||||
static ErrorOr<NonnullRefPtr<WelcomeWidget>> try_create();
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
|
||||
|
@ -41,3 +43,4 @@ private:
|
|||
size_t m_tip_index { 0 };
|
||||
Vector<String> m_tips;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 {}
|
||||
|
|
|
@ -32,7 +32,7 @@ ErrorOr<int> 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();
|
||||
|
|
Loading…
Reference in a new issue