From d444724d240efd71ee8a5038280536e979606b81 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Mon, 26 Sep 2022 08:58:00 -0400 Subject: [PATCH] ThemeEditor: Update GML and polish interface Registers the PreviewWidget for addition directly into GML. Fixes its previous double Frame borders. Also standardizes the Apply and Reset buttons as DialogButtons and spaces them consistently with other apps. Gives the TabWidget some tasteful container margins. --- .../Applications/ThemeEditor/MainWidget.cpp | 8 ++--- .../ThemeEditor/PreviewWidget.cpp | 2 ++ .../Applications/ThemeEditor/PreviewWidget.h | 1 + .../Applications/ThemeEditor/ThemeEditor.gml | 33 ++++++++++--------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index 43517bde33c..4006456491e 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -191,8 +190,7 @@ MainWidget::MainWidget() m_alignment_model = MUST(AlignmentModel::try_create()); - m_preview_widget = find_descendant_of_type_named("preview_frame") - ->add(m_current_palette); + m_preview_widget = find_descendant_of_type_named("preview_widget"); m_property_tabs = find_descendant_of_type_named("property_tabs"); add_property_tab(window_tab); add_property_tab(widgets_tab); @@ -371,8 +369,8 @@ void MainWidget::build_override_controls() { auto* theme_override_controls = find_descendant_of_type_named("theme_override_controls"); - m_theme_override_apply = theme_override_controls->find_child_of_type_named("apply"); - m_theme_override_reset = theme_override_controls->find_child_of_type_named("reset"); + m_theme_override_apply = theme_override_controls->find_child_of_type_named("apply_button"); + m_theme_override_reset = theme_override_controls->find_child_of_type_named("reset_button"); m_theme_override_apply->on_click = [&](auto) { auto encoded = encode(); diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp index 215d28e6412..9a804697350 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp +++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp @@ -18,6 +18,8 @@ #include #include +REGISTER_WIDGET(ThemeEditor, PreviewWidget); + namespace ThemeEditor { class MiniWidgetGallery final : public GUI::Widget { diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.h b/Userland/Applications/ThemeEditor/PreviewWidget.h index e0f5cad30b8..3ffba902fbf 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.h +++ b/Userland/Applications/ThemeEditor/PreviewWidget.h @@ -10,6 +10,7 @@ #pragma once #include +#include #include #include #include diff --git a/Userland/Applications/ThemeEditor/ThemeEditor.gml b/Userland/Applications/ThemeEditor/ThemeEditor.gml index 1cf611e35ea..475ae019f2d 100644 --- a/Userland/Applications/ThemeEditor/ThemeEditor.gml +++ b/Userland/Applications/ThemeEditor/ThemeEditor.gml @@ -1,41 +1,44 @@ @GUI::Widget { - layout: @GUI::VerticalBoxLayout {} + layout: @GUI::VerticalBoxLayout { + margins: [0, 4, 4] + spacing: 6 + } fill_with_background_color: true @GUI::Widget { - layout: @GUI::HorizontalBoxLayout {} + layout: @GUI::HorizontalBoxLayout { + spacing: 4 + } - @GUI::Frame { - layout: @GUI::HorizontalBoxLayout {} - name: "preview_frame" + @ThemeEditor::PreviewWidget { + name: "preview_widget" } @GUI::TabWidget { name: "property_tabs" + container_margins: [5] } } @GUI::Widget { name: "theme_override_controls" layout: @GUI::HorizontalBoxLayout { - margins: [0, 4] + spacing: 6 } - fixed_height: 30 + preferred_height: "shrink" @GUI::Layout::Spacer {} - @GUI::Button { - name: "reset" - text: "Reset to Previous System Theme" + @GUI::DialogButton { + name: "reset_button" + text: "Reset" enabled: false - fixed_width: 190 } - @GUI::Button { - name: "apply" - text: "Apply as System Theme" + @GUI::DialogButton { + name: "apply_button" + text: "Apply" enabled: false - fixed_width: 140 } } }