mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Welcome: Port to GML Compiler
This commit is contained in:
parent
0a4ef6f3b7
commit
69ffdd5738
5 changed files with 15 additions and 16 deletions
|
@ -4,16 +4,13 @@ serenity_component(
|
||||||
DEPENDS Help WebContent
|
DEPENDS Help WebContent
|
||||||
)
|
)
|
||||||
|
|
||||||
stringify_gml(WelcomeWindow.gml WelcomeWindowGML.h welcome_window_gml)
|
compile_gml(WelcomeWindow.gml WelcomeWindowGML.cpp)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
WelcomeWindowGML.cpp
|
||||||
WelcomeWidget.cpp
|
WelcomeWidget.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GENERATED_SOURCES
|
|
||||||
WelcomeWindowGML.h
|
|
||||||
)
|
|
||||||
|
|
||||||
serenity_app(Welcome ICON app-welcome)
|
serenity_app(Welcome ICON app-welcome)
|
||||||
target_link_libraries(Welcome PRIVATE LibConfig LibCore LibGfx LibGUI LibWebView LibWeb LibMain)
|
target_link_libraries(Welcome PRIVATE LibConfig LibCore LibGfx LibGUI LibWebView LibWeb LibMain)
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "WelcomeWidget.h"
|
#include "WelcomeWidget.h"
|
||||||
#include <AK/Random.h>
|
#include <AK/Random.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <Applications/Welcome/WelcomeWindowGML.h>
|
|
||||||
#include <LibConfig/Client.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -19,9 +18,10 @@
|
||||||
#include <LibGUI/Process.h>
|
#include <LibGUI/Process.h>
|
||||||
#include <LibGfx/Palette.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());
|
TRY(welcome_widget->create_widgets());
|
||||||
|
|
||||||
return welcome_widget;
|
return welcome_widget;
|
||||||
|
@ -29,8 +29,6 @@ ErrorOr<NonnullRefPtr<WelcomeWidget>> WelcomeWidget::try_create()
|
||||||
|
|
||||||
ErrorOr<void> WelcomeWidget::create_widgets()
|
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_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));
|
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))));
|
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());
|
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 <LibGfx/Font/BitmapFont.h>
|
||||||
#include <LibWebView/OutOfProcessWebView.h>
|
#include <LibWebView/OutOfProcessWebView.h>
|
||||||
|
|
||||||
|
namespace Welcome {
|
||||||
class WelcomeWidget final : public GUI::Widget {
|
class WelcomeWidget final : public GUI::Widget {
|
||||||
C_OBJECT(WelcomeWidget);
|
C_OBJECT(WelcomeWidget);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ErrorOr<NonnullRefPtr<WelcomeWidget>> try_create();
|
static ErrorOr<NonnullRefPtr<WelcomeWidget>> create();
|
||||||
virtual ~WelcomeWidget() override = default;
|
virtual ~WelcomeWidget() override = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WelcomeWidget() = default;
|
WelcomeWidget() = default;
|
||||||
ErrorOr<void> create_widgets();
|
ErrorOr<void> create_widgets();
|
||||||
|
static ErrorOr<NonnullRefPtr<WelcomeWidget>> try_create();
|
||||||
|
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
|
|
||||||
|
@ -41,3 +43,4 @@ private:
|
||||||
size_t m_tip_index { 0 };
|
size_t m_tip_index { 0 };
|
||||||
Vector<String> m_tips;
|
Vector<String> m_tips;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@GUI::Widget {
|
@Welcome::WelcomeWidget {
|
||||||
fill_with_background_color: true
|
fill_with_background_color: true
|
||||||
layout: @GUI::VerticalBoxLayout {
|
layout: @GUI::VerticalBoxLayout {
|
||||||
margins: [8]
|
margins: [8]
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
@GUI::Label {
|
@GUI::Label {
|
||||||
name: "tip_label"
|
name: "tip_label"
|
||||||
text_alignment: "TopLeft"
|
text_alignment: "TopLeft"
|
||||||
word_wrap: true
|
text_wrapping: "Wrap"
|
||||||
font_size: 12
|
font_size: 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,13 +91,13 @@
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
name: "help_button"
|
name: "help_button"
|
||||||
text: "Help Contents"
|
text: "Help Contents"
|
||||||
icon: "/res/icons/16x16/book-open.png"
|
icon_from_path: "/res/icons/16x16/book-open.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
name: "next_button"
|
name: "next_button"
|
||||||
text: "Next Tip"
|
text: "Next Tip"
|
||||||
icon: "/res/icons/16x16/go-forward.png"
|
icon_from_path: "/res/icons/16x16/go-forward.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Layout::Spacer {}
|
@GUI::Layout::Spacer {}
|
||||||
|
|
|
@ -32,7 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
window->center_on_screen();
|
window->center_on_screen();
|
||||||
window->set_title("Welcome");
|
window->set_title("Welcome");
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
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->set_main_widget(welcome_widget);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue