1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:57:34 +00:00

ThemeEditor: Convert layout to GML

This commit is contained in:
Sam Atkins 2021-10-27 15:20:35 +01:00 committed by Andreas Kling
parent daaf5890a6
commit c885722a94
3 changed files with 32 additions and 12 deletions

View file

@ -3,9 +3,12 @@ serenity_component(
TARGETS ThemeEditor TARGETS ThemeEditor
) )
compile_gml(ThemeEditor.gml ThemeEditorGML.h theme_editor_gml)
set(SOURCES set(SOURCES
PreviewWidget.cpp PreviewWidget.cpp
main.cpp main.cpp
ThemeEditorGML.h
) )
serenity_app(ThemeEditor ICON app-theme-editor) serenity_app(ThemeEditor ICON app-theme-editor)

View file

@ -0,0 +1,23 @@
@GUI::Widget {
layout: @GUI::VerticalBoxLayout
fill_with_background_color: true
@GUI::Frame {
layout: @GUI::HorizontalBoxLayout
name: "preview_frame"
}
@GUI::Widget {
layout: @GUI::HorizontalBoxLayout
fixed_height: 20
@GUI::ComboBox {
name: "color_combo_box"
model_only: true
}
@GUI::ColorInput {
name: "color_input"
}
}
}

View file

@ -6,6 +6,7 @@
*/ */
#include "PreviewWidget.h" #include "PreviewWidget.h"
#include <Applications/ThemeEditor/ThemeEditorGML.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/ConfigFile.h> #include <LibCore/ConfigFile.h>
#include <LibFileSystemAccessClient/Client.h> #include <LibFileSystemAccessClient/Client.h>
@ -98,20 +99,13 @@ int main(int argc, char** argv)
#undef __ENUMERATE_COLOR_ROLE #undef __ENUMERATE_COLOR_ROLE
auto& main_widget = window->set_main_widget<GUI::Widget>(); auto& main_widget = window->set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true); main_widget.load_from_gml(theme_editor_gml);
main_widget.set_layout<GUI::VerticalBoxLayout>();
auto& preview_widget = main_widget.add<ThemeEditor::PreviewWidget>(startup_preview_palette); auto& preview_widget = main_widget.find_descendant_of_type_named<GUI::Frame>("preview_frame")
preview_widget.set_fixed_size(480, 360); ->add<ThemeEditor::PreviewWidget>(startup_preview_palette);
auto& combo_box = *main_widget.find_descendant_of_type_named<GUI::ComboBox>("color_combo_box");
auto& color_input = *main_widget.find_descendant_of_type_named<GUI::ColorInput>("color_input");
auto& horizontal_container = main_widget.add<GUI::Widget>();
horizontal_container.set_layout<GUI::HorizontalBoxLayout>();
horizontal_container.set_fixed_size(480, 20);
auto& combo_box = horizontal_container.add<GUI::ComboBox>();
auto& color_input = horizontal_container.add<GUI::ColorInput>();
combo_box.set_only_allow_values_from_model(true);
combo_box.set_model(adopt_ref(*new ColorRoleModel(color_roles))); combo_box.set_model(adopt_ref(*new ColorRoleModel(color_roles)));
combo_box.on_change = [&](auto&, auto& index) { combo_box.on_change = [&](auto&, auto& index) {
auto role = index.model()->data(index, GUI::ModelRole::Custom).to_color_role(); auto role = index.model()->data(index, GUI::ModelRole::Custom).to_color_role();