diff --git a/Base/res/devel/templates/serenity-application.ini b/Base/res/devel/templates/serenity-application.ini new file mode 100644 index 00000000000..fe3a281bc05 --- /dev/null +++ b/Base/res/devel/templates/serenity-application.ini @@ -0,0 +1,5 @@ +[HackStudioTemplate] +Name=SerenityOS GUI Application (C++) +Description=Template for creating a GUI-based SerenityOS application with CMake. +Priority=90 +IconName32x=serenity-application diff --git a/Base/res/devel/templates/serenity-application.postcreate b/Base/res/devel/templates/serenity-application.postcreate new file mode 100644 index 00000000000..d28ead888f0 --- /dev/null +++ b/Base/res/devel/templates/serenity-application.postcreate @@ -0,0 +1,28 @@ +#!/bin/sh + +echo > $2/CMakeLists.txt <<-EOF +# NOTE! Make sure to edit this file and remove the comments before submitting a +# PR for a new application. + +# Defines your application component. If the application is essential to the +# system's operation, add REQUIRED. If it would be beneficial for the user that +# this application is built by default, add RECOMMENDED. +serenity_component( + $1 + TARGETS $1 +) + +# Place source files here. You should also add auto-generated headers, if you +# have any. +set(SOURCES + main.cpp +) + +# Change this to something cool. :^) +serenity_app($1 ICON filetype-executable) + +# You should place all the libraries that your application uses here. You can +# identify each library by their include path. An exception is LibCore, which +# is linked to all components by default. +target_link_libraries($1 LibGUI LibGfx) +EOF diff --git a/Base/res/devel/templates/serenity-application/main.cpp b/Base/res/devel/templates/serenity-application/main.cpp new file mode 100644 index 00000000000..d3e728bc711 --- /dev/null +++ b/Base/res/devel/templates/serenity-application/main.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + if (pledge("stdio recvfd sendfd rpath wpath cpath unix", nullptr) < 0) { + perror("pledge"); + return 1; + } + + auto app = GUI::Application::construct(argc, argv); + + if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) { + perror("pledge"); + return 1; + } + + auto window = GUI::Window::construct(); + window->set_title("Form1"); + window->resize(96, 44); + window->set_resizable(false); + + auto& main_widget = window->set_main_widget(); + main_widget.set_fill_with_background_color(true); + + auto& layout = main_widget.set_layout(); + layout.set_margins({ 16, 16, 16, 16 }); + + auto& button = main_widget.add("Click me!"); + button.on_click = [&](auto) { + GUI::MessageBox::show(window, "Hello friends!", ":^)"); + }; + + window->show(); + return app->exec(); +} diff --git a/Base/res/icons/hackstudio/templates-32x32/serenity-application.png b/Base/res/icons/hackstudio/templates-32x32/serenity-application.png new file mode 100644 index 00000000000..2d85ff27292 Binary files /dev/null and b/Base/res/icons/hackstudio/templates-32x32/serenity-application.png differ