#include #include #include #include #include #include #include #include #include static constexpr ui::Color TASKBAR_COLOR = ui::Color::from_rgb(83, 83, 83); void sigchld_handler(int) { wait(nullptr); } Result create_widget_group_for_app(ui::HorizontalLayout& layout, Slice args, StringView icon) { auto* button = new (std::nothrow) ui::Button({ 0, 0, 50, 50 }); if (!button) return err(ENOMEM); layout.add_widget(*button); auto* container = new (std::nothrow) ui::Container({ 0, 0, 50, 50 }, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center); if (!container) return err(ENOMEM); button->set_widget(*container); button->set_action([=] { os::Process::spawn(args[0], args, false); }); auto image = TRY(ui::ImageWidget::load(icon)); container->set_widget(*image); image.leak(); return {}; } Result luna_main(int argc, char** argv) { ui::App app; TRY(app.init(argc, argv)); signal(SIGCHLD, sigchld_handler); ui::Rect screen = app.screen_rect(); ui::Rect bar = ui::Rect { ui::Point { 0, screen.height - 50 }, screen.width, 50 }; auto window = TRY(ui::Window::create(bar, ui::WindowType::System)); app.set_main_window(window); window->set_background(TASKBAR_COLOR); ui::HorizontalLayout layout(ui::Margins { 0, 0, 0, 0 }, ui::AdjustHeight::Yes, ui::AdjustWidth::No); window->set_main_widget(layout); StringView terminal_command[] = { "/usr/bin/terminal" }; TRY(create_widget_group_for_app(layout, { terminal_command, 1 }, "/usr/share/icons/32x32/app-terminal.tga")); StringView about_command[] = { "/usr/bin/about" }; TRY(create_widget_group_for_app(layout, { about_command, 1 }, "/usr/share/icons/32x32/app-about.tga")); window->draw(); return app.run(); }