mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
ThemeEditor: Convert the widget-preview layout to GML
This has the nice bonus of fixing the appearance of the status bar. :^)
This commit is contained in:
parent
4edc33b4a6
commit
48122e29c3
3 changed files with 33 additions and 32 deletions
|
@ -9,6 +9,7 @@ compile_gml(ColorProperty.gml ColorPropertyGML.h color_property_gml)
|
||||||
compile_gml(FlagProperty.gml FlagPropertyGML.h flag_property_gml)
|
compile_gml(FlagProperty.gml FlagPropertyGML.h flag_property_gml)
|
||||||
compile_gml(MetricProperty.gml MetricPropertyGML.h metric_property_gml)
|
compile_gml(MetricProperty.gml MetricPropertyGML.h metric_property_gml)
|
||||||
compile_gml(PathProperty.gml PathPropertyGML.h path_property_gml)
|
compile_gml(PathProperty.gml PathPropertyGML.h path_property_gml)
|
||||||
|
compile_gml(Previews/WindowPreview.gml WindowPreviewGML.h window_preview_gml)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
|
@ -20,6 +21,7 @@ set(SOURCES
|
||||||
MetricPropertyGML.h
|
MetricPropertyGML.h
|
||||||
PathPropertyGML.h
|
PathPropertyGML.h
|
||||||
ThemeEditorGML.h
|
ThemeEditorGML.h
|
||||||
|
WindowPreviewGML.h
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(ThemeEditor ICON app-theme-editor)
|
serenity_app(ThemeEditor ICON app-theme-editor)
|
||||||
|
|
|
@ -10,19 +10,13 @@
|
||||||
#include "PreviewWidget.h"
|
#include "PreviewWidget.h"
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
|
#include <Applications/ThemeEditor/WindowPreviewGML.h>
|
||||||
#include <LibCore/MimeData.h>
|
#include <LibCore/MimeData.h>
|
||||||
#include <LibFileSystemAccessClient/Client.h>
|
#include <LibFileSystemAccessClient/Client.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
|
||||||
#include <LibGUI/Button.h>
|
|
||||||
#include <LibGUI/CheckBox.h>
|
|
||||||
#include <LibGUI/MessageBox.h>
|
#include <LibGUI/MessageBox.h>
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGUI/RadioButton.h>
|
|
||||||
#include <LibGUI/Statusbar.h>
|
|
||||||
#include <LibGUI/TextEditor.h>
|
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/WindowTheme.h>
|
#include <LibGfx/WindowTheme.h>
|
||||||
#include <WindowServer/Compositor.h>
|
|
||||||
|
|
||||||
namespace ThemeEditor {
|
namespace ThemeEditor {
|
||||||
|
|
||||||
|
@ -46,37 +40,13 @@ public:
|
||||||
private:
|
private:
|
||||||
MiniWidgetGallery()
|
MiniWidgetGallery()
|
||||||
{
|
{
|
||||||
m_button = add<GUI::Button>();
|
load_from_gml(window_preview_gml);
|
||||||
m_button->set_text("Button");
|
|
||||||
m_checkbox = add<GUI::CheckBox>();
|
|
||||||
m_checkbox->set_text("Check box");
|
|
||||||
m_radio = add<GUI::RadioButton>();
|
|
||||||
m_radio->set_text("Radio button");
|
|
||||||
m_statusbar = add<GUI::Statusbar>();
|
|
||||||
m_statusbar->set_text("Status bar");
|
|
||||||
m_editor = add<GUI::TextEditor>();
|
|
||||||
m_editor->set_text("Text editor\nwith multiple\nlines.");
|
|
||||||
|
|
||||||
for_each_child_widget([](auto& child) {
|
for_each_child_widget([](auto& child) {
|
||||||
child.set_focus_policy(GUI::FocusPolicy::NoFocus);
|
child.set_focus_policy(GUI::FocusPolicy::NoFocus);
|
||||||
return IterationDecision::Continue;
|
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<GUI::TextEditor> m_editor;
|
|
||||||
RefPtr<GUI::Button> m_button;
|
|
||||||
RefPtr<GUI::CheckBox> m_checkbox;
|
|
||||||
RefPtr<GUI::RadioButton> m_radio;
|
|
||||||
RefPtr<GUI::Statusbar> m_statusbar;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PreviewWidget::PreviewWidget(Gfx::Palette const& initial_preview_palette)
|
PreviewWidget::PreviewWidget(Gfx::Palette const& initial_preview_palette)
|
||||||
|
|
29
Userland/Applications/ThemeEditor/Previews/WindowPreview.gml
Normal file
29
Userland/Applications/ThemeEditor/Previews/WindowPreview.gml
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue