From 822dc56ef309e9fc053fd39dad7d7b33f397a566 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 20 Dec 2020 11:47:44 +0100 Subject: LibGUI: Introduce GML - a simple GUI Markup Language :^) This patch replaces the UI-from-JSON mechanism with a more human-friendly DSL. The current implementation simply converts the GML into a JSON object that can be consumed by GUI::Widget::load_from_json(). The parser is not very helpful if you make a mistake. The language offers a very simple way to instantiate any registered Core::Object class by simply saying @ClassName @GUI::Label { text: "Hello friends!" tooltip: ":^)" } Layouts are Core::Objects and can be assigned to the "layout" property: @GUI::Widget { layout: @GUI::VerticalBoxLayout { spacing: 2 margins: [8, 8, 8, 8] } } And finally, child objects are simply nested within their parent: @GUI::Widget { layout: @GUI::HorizontalBoxLayout { } @GUI::Button { text: "OK" } @GUI::Button { text: "Cancel" } } This feels a *lot* more pleasant to write than the JSON we had. The fact that no new code was being written with the JSON mechanism was pretty telling, so let's approach this with developer convenience in mind. :^) --- Applications/Browser/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Applications/Browser/main.cpp') diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index 7fe4e5f94d..3624ca6076 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -30,7 +30,7 @@ #include "Tab.h" #include "WindowActions.h" #include -#include +#include #include #include #include @@ -138,7 +138,7 @@ int main(int argc, char** argv) window->set_title("Browser"); auto& widget = window->set_main_widget(); - widget.load_from_json(browser_window_ui_json); + widget.load_from_gml(browser_window_gml); auto& tab_widget = static_cast(*widget.find_descendant_by_name("tab_widget")); -- cgit v1.2.3