1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:27:35 +00:00

guitest2: Add a simple launcher so I can easily spawn more Terminals.

Also update GButton coding style.
This commit is contained in:
Andreas Kling 2019-01-21 00:31:11 +01:00
parent 3271c115e2
commit 6c4f1bad09
3 changed files with 45 additions and 12 deletions

View file

@ -11,15 +11,20 @@
#include <LibGUI/GWindow.h>
#include <LibGUI/GWidget.h>
#include <LibGUI/GLabel.h>
#include <LibGUI/GButton.h>
#include <LibGUI/GEventLoop.h>
static GWindow* make_font_test_window();
static GWindow* make_launcher_window();
int main(int argc, char** argv)
{
GEventLoop loop;
auto* window = make_font_test_window();
window->show();
auto* font_test_window = make_font_test_window();
font_test_window->show();
auto* launcher_window = make_launcher_window();
launcher_window->show();
return loop.exec();
}
@ -51,3 +56,31 @@ GWindow* make_font_test_window()
return window;
}
GWindow* make_launcher_window()
{
auto* window = new GWindow;
window->set_title("Launcher");
window->set_rect({ 100, 400, 80, 200 });
auto* widget = new GWidget;
window->set_main_widget(widget);
widget->setWindowRelativeRect({ 0, 0, 80, 200 });
auto* label = new GLabel(widget);
label->setWindowRelativeRect({ 0, 0, 80, 20 });
label->setText("Apps");
auto* button = new GButton(widget);
button->setWindowRelativeRect({ 5, 20, 70, 20 });
button->set_caption("Terminal");
button->on_click = [] (GButton&) {
if (!fork()) {
execve("/bin/Terminal", nullptr, nullptr);
ASSERT_NOT_REACHED();
}
};
return window;
}