diff --git a/Userland/Applications/ThemeEditor/CMakeLists.txt b/Userland/Applications/ThemeEditor/CMakeLists.txt index f98563a658..ff9a28496d 100644 --- a/Userland/Applications/ThemeEditor/CMakeLists.txt +++ b/Userland/Applications/ThemeEditor/CMakeLists.txt @@ -9,6 +9,7 @@ compile_gml(ColorProperty.gml ColorPropertyGML.h color_property_gml) compile_gml(FlagProperty.gml FlagPropertyGML.h flag_property_gml) compile_gml(MetricProperty.gml MetricPropertyGML.h metric_property_gml) compile_gml(PathProperty.gml PathPropertyGML.h path_property_gml) +compile_gml(Previews/WindowPreview.gml WindowPreviewGML.h window_preview_gml) set(SOURCES main.cpp @@ -20,6 +21,7 @@ set(SOURCES MetricPropertyGML.h PathPropertyGML.h ThemeEditorGML.h + WindowPreviewGML.h ) serenity_app(ThemeEditor ICON app-theme-editor) diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp index 900567080b..4847e8e847 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp +++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp @@ -10,19 +10,13 @@ #include "PreviewWidget.h" #include #include +#include #include #include -#include -#include -#include #include #include -#include -#include -#include #include #include -#include namespace ThemeEditor { @@ -46,37 +40,13 @@ public: private: MiniWidgetGallery() { - m_button = add(); - m_button->set_text("Button"); - m_checkbox = add(); - m_checkbox->set_text("Check box"); - m_radio = add(); - m_radio->set_text("Radio button"); - m_statusbar = add(); - m_statusbar->set_text("Status bar"); - m_editor = add(); - m_editor->set_text("Text editor\nwith multiple\nlines."); + load_from_gml(window_preview_gml); for_each_child_widget([](auto& child) { child.set_focus_policy(GUI::FocusPolicy::NoFocus); return IterationDecision::Continue; }); } - - virtual void resize_event(GUI::ResizeEvent&) override - { - m_editor->set_relative_rect(10, 70, 200, 125); - m_button->set_relative_rect(10, 10, 200, 20); - m_checkbox->set_relative_rect(10, 30, 200, 20); - m_radio->set_relative_rect(10, 50, 200, 20); - m_statusbar->set_relative_rect(0, height() - 16, width(), 16); - } - - RefPtr m_editor; - RefPtr m_button; - RefPtr m_checkbox; - RefPtr m_radio; - RefPtr m_statusbar; }; PreviewWidget::PreviewWidget(Gfx::Palette const& initial_preview_palette) diff --git a/Userland/Applications/ThemeEditor/Previews/WindowPreview.gml b/Userland/Applications/ThemeEditor/Previews/WindowPreview.gml new file mode 100644 index 0000000000..3f9a782f28 --- /dev/null +++ b/Userland/Applications/ThemeEditor/Previews/WindowPreview.gml @@ -0,0 +1,29 @@ +@GUI::Frame { + layout: @GUI::VerticalBoxLayout {} + + @GUI::Widget { + layout: @GUI::VerticalBoxLayout { + margins: [8, 100, 8, 8] + } + + @GUI::Button { + text: "Button" + } + + @GUI::CheckBox { + text: "Check box" + } + + @GUI::RadioButton { + text: "Radio button" + } + + @GUI::TextEditor { + text: "Text editor\nwith multiple\nlines." + } + } + + @GUI::Statusbar { + text: "Status bar" + } +}