summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-08 01:18:36 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-08 01:18:36 +0200
commiteaf03d4ddb6e497451c273fb459153beffc37d93 (patch)
treeca7a450036ab231933686561931842a09d9ea182
parent1930d48a388810712c540335b57d9fd3989f4d08 (diff)
downloadserenity-eaf03d4ddb6e497451c273fb459153beffc37d93.zip
HelloWorld: Add a simple "Hello World!" app showing the basics.
This also introduces a Demos/ directory where I hope to add cool things.
-rw-r--r--Demos/HelloWorld/.gitignore3
-rw-r--r--Demos/HelloWorld/Makefile22
-rw-r--r--Demos/HelloWorld/main.cpp37
-rwxr-xr-xKernel/makeall.sh2
-rwxr-xr-xKernel/sync.sh1
5 files changed, 65 insertions, 0 deletions
diff --git a/Demos/HelloWorld/.gitignore b/Demos/HelloWorld/.gitignore
new file mode 100644
index 0000000000..17a4d1f7ae
--- /dev/null
+++ b/Demos/HelloWorld/.gitignore
@@ -0,0 +1,3 @@
+HelloWorld
+*.o
+*.d
diff --git a/Demos/HelloWorld/Makefile b/Demos/HelloWorld/Makefile
new file mode 100644
index 0000000000..fe106ee912
--- /dev/null
+++ b/Demos/HelloWorld/Makefile
@@ -0,0 +1,22 @@
+include ../../Makefile.common
+
+OBJS = \
+ main.o
+
+APP = HelloWorld
+
+DEFINES += -DUSERLAND
+
+all: $(APP)
+
+$(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 $(APPS) $(OBJS) *.d
+
diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp
new file mode 100644
index 0000000000..4f5d422b4b
--- /dev/null
+++ b/Demos/HelloWorld/main.cpp
@@ -0,0 +1,37 @@
+#include <LibGUI/GApplication.h>
+#include <LibGUI/GWindow.h>
+#include <LibGUI/GWidget.h>
+#include <LibGUI/GLabel.h>
+#include <LibGUI/GButton.h>
+#include <LibGUI/GBoxLayout.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* main_widget = new GWidget;
+ window->set_main_widget(main_widget);
+ main_widget->set_fill_with_background_color(true);
+ main_widget->set_background_color(Color::White);
+ main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
+ main_widget->layout()->set_margins({ 4, 4, 4, 4 });
+
+ auto* label = new GLabel(main_widget);
+ label->set_text("Hello World!");
+
+ auto* button = new GButton(main_widget);
+ button->set_caption("Good-bye");
+ button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
+ button->set_preferred_size({ 0, 20 });
+ button->on_click = [&] (GButton&) {
+ app.quit();
+ };
+
+ window->show();
+
+ return app.exec();
+}
diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh
index 1d9442a308..676853d2e2 100755
--- a/Kernel/makeall.sh
+++ b/Kernel/makeall.sh
@@ -48,6 +48,8 @@ $make_cmd -C ../Games/Snake clean && \
$make_cmd -C ../Games/Snake && \
$make_cmd -C ../Shell clean && \
$make_cmd -C ../Shell && \
+$make_cmd -C ../Demos/HelloWorld clean && \
+$make_cmd -C ../Demos/HelloWorld && \
$make_cmd clean &&\
$make_cmd && \
sudo ./sync.sh
diff --git a/Kernel/sync.sh b/Kernel/sync.sh
index 0592aec056..5afd159fee 100755
--- a/Kernel/sync.sh
+++ b/Kernel/sync.sh
@@ -78,6 +78,7 @@ ln -s Snake mnt/bin/sn
cp -v ../Shell/Shell mnt/bin/Shell
ln -s Shell mnt/bin/sh
cp -v kernel.map mnt/
+cp -v ../Demos/HelloWorld/HelloWorld mnt/bin/HelloWorld
# Run local sync script, if it exists
if [ -f sync-local.sh ]; then