summaryrefslogtreecommitdiff
path: root/Demos/HelloWorld2
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-10 21:13:29 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-10 21:13:29 +0200
commit0bf5c6fa3ae9bfbb560fbebfa5712c4ca60ed10b (patch)
treef3f548f033453281930f4177cc313b3dc7a38637 /Demos/HelloWorld2
parentb3d431e3906014644e936232029f9a8a11332e68 (diff)
downloadserenity-0bf5c6fa3ae9bfbb560fbebfa5712c4ca60ed10b.zip
Demos: Add a HelloWorld2 demo.
This is a simple test app with its UI generated from a VisualBuilder form. The name is probably silly, but who cares. :^)
Diffstat (limited to 'Demos/HelloWorld2')
-rw-r--r--Demos/HelloWorld2/.gitignore1
-rw-r--r--Demos/HelloWorld2/HelloWorld2.frm1
-rw-r--r--Demos/HelloWorld2/Makefile27
-rw-r--r--Demos/HelloWorld2/main.cpp26
4 files changed, 55 insertions, 0 deletions
diff --git a/Demos/HelloWorld2/.gitignore b/Demos/HelloWorld2/.gitignore
new file mode 100644
index 0000000000..0e7af5b54f
--- /dev/null
+++ b/Demos/HelloWorld2/.gitignore
@@ -0,0 +1 @@
+UI_*.h
diff --git a/Demos/HelloWorld2/HelloWorld2.frm b/Demos/HelloWorld2/HelloWorld2.frm
new file mode 100644
index 0000000000..932975dfe4
--- /dev/null
+++ b/Demos/HelloWorld2/HelloWorld2.frm
@@ -0,0 +1 @@
+{"name":"HelloWorld2","widgets":[{"name":"w1","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Hello world!","class":"GLabel","autofill":true,"enabled":true,"visible":true,"x":5,"height":26,"y":5,"width":121},{"name":"w2","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Lefty","class":"GButton","autofill":false,"enabled":true,"visible":true,"x":5,"height":26,"y":40,"width":51},{"name":"w3","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Righty","class":"GButton","autofill":false,"enabled":true,"visible":true,"x":80,"height":26,"y":40,"width":51},{"name":"w4","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":91,"y":5,"class":"GCheckBox","text":"Awesome","backcolor":"#d4d0c8ff","visible":true},{"name":"w5","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":51,"y":30,"class":"GCheckBox","text":"Cool","backcolor":"#d4d0c8ff","visible":true}]}
diff --git a/Demos/HelloWorld2/Makefile b/Demos/HelloWorld2/Makefile
new file mode 100644
index 0000000000..e80c421368
--- /dev/null
+++ b/Demos/HelloWorld2/Makefile
@@ -0,0 +1,27 @@
+include ../../Makefile.common
+
+OBJS = \
+ main.o
+
+APP = HelloWorld2
+
+DEFINES += -DUSERLAND
+
+all: $(APP)
+
+main.cpp: UI_HelloWorld2.h
+
+UI_HelloWorld2.h: HelloWorld2.frm
+ ../../DevTools/FormCompiler/FormCompiler $< > $@
+
+$(APP): $(OBJS)
+ $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lcore -lc
+
+.cpp.o:
+ @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
+
+-include $(OBJS:%.o=%.d)
+
+clean:
+ @echo "CLEAN"; rm -f $(APP) $(OBJS) *.d
+
diff --git a/Demos/HelloWorld2/main.cpp b/Demos/HelloWorld2/main.cpp
new file mode 100644
index 0000000000..1d3830c17c
--- /dev/null
+++ b/Demos/HelloWorld2/main.cpp
@@ -0,0 +1,26 @@
+#include <LibGUI/GApplication.h>
+#include <LibGUI/GBoxLayout.h>
+#include <LibGUI/GButton.h>
+#include <LibGUI/GLabel.h>
+#include <LibGUI/GWidget.h>
+#include <LibGUI/GWindow.h>
+#include "UI_HelloWorld2.h"
+
+int main(int argc, char** argv)
+{
+ GApplication app(argc, argv);
+
+ auto* window = new GWindow;
+ window->set_rect(100, 100, 240, 160);
+ window->set_title("Hello World!");
+
+ auto* ui = new UI_HelloWorld2;
+ window->set_main_widget(ui->main_widget);
+
+ ui->w3->on_click = [&](auto&) {
+ app.quit();
+ };
+
+ window->show();
+ return app.exec();
+}