mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:47:45 +00:00
HelloWorld: Add a simple "Hello World!" app showing the basics.
This also introduces a Demos/ directory where I hope to add cool things.
This commit is contained in:
parent
1930d48a38
commit
eaf03d4ddb
5 changed files with 65 additions and 0 deletions
3
Demos/HelloWorld/.gitignore
vendored
Normal file
3
Demos/HelloWorld/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
HelloWorld
|
||||
*.o
|
||||
*.d
|
22
Demos/HelloWorld/Makefile
Normal file
22
Demos/HelloWorld/Makefile
Normal file
|
@ -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
|
||||
|
37
Demos/HelloWorld/main.cpp
Normal file
37
Demos/HelloWorld/main.cpp
Normal file
|
@ -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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue