diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-10 21:13:29 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-10 21:13:29 +0200 |
commit | 0bf5c6fa3ae9bfbb560fbebfa5712c4ca60ed10b (patch) | |
tree | f3f548f033453281930f4177cc313b3dc7a38637 /Demos | |
parent | b3d431e3906014644e936232029f9a8a11332e68 (diff) | |
download | serenity-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')
-rw-r--r-- | Demos/HelloWorld2/.gitignore | 1 | ||||
-rw-r--r-- | Demos/HelloWorld2/HelloWorld2.frm | 1 | ||||
-rw-r--r-- | Demos/HelloWorld2/Makefile | 27 | ||||
-rw-r--r-- | Demos/HelloWorld2/main.cpp | 26 |
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(); +} |