summaryrefslogtreecommitdiff
path: root/Applications/Browser/main.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-20 11:47:44 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-20 11:59:40 +0100
commit822dc56ef309e9fc053fd39dad7d7b33f397a566 (patch)
tree37f1ecdbcdd1db3e8454edcc02ffa5903bdc33c3 /Applications/Browser/main.cpp
parent18f1c49804f3888d3f588f68fee9f73e04258588 (diff)
downloadserenity-822dc56ef309e9fc053fd39dad7d7b33f397a566.zip
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. :^)
Diffstat (limited to 'Applications/Browser/main.cpp')
-rw-r--r--Applications/Browser/main.cpp4
1 files changed, 2 insertions, 2 deletions
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 <AK/StringBuilder.h>
-#include <Applications/Browser/BrowserWindowUI.h>
+#include <Applications/Browser/BrowserWindowGML.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/File.h>
@@ -138,7 +138,7 @@ int main(int argc, char** argv)
window->set_title("Browser");
auto& widget = window->set_main_widget<GUI::Widget>();
- widget.load_from_json(browser_window_ui_json);
+ widget.load_from_gml(browser_window_gml);
auto& tab_widget = static_cast<GUI::TabWidget&>(*widget.find_descendant_by_name("tab_widget"));