#include "PaintableWidget.h" #include "PaletteWidget.h" #include "ToolboxWidget.h" #include #include #include #include #include #include #include #include #include int main(int argc, char** argv) { GApplication app(argc, argv); auto* window = new GWindow; window->set_title("PaintBrush"); window->set_rect(100, 100, 640, 480); auto* horizontal_container = new GWidget(nullptr); window->set_main_widget(horizontal_container); horizontal_container->set_layout(make(Orientation::Horizontal)); horizontal_container->layout()->set_spacing(0); new ToolboxWidget(horizontal_container); auto* vertical_container = new GWidget(horizontal_container); vertical_container->set_layout(make(Orientation::Vertical)); vertical_container->layout()->set_spacing(0); auto* paintable_widget = new PaintableWidget(vertical_container); new PaletteWidget(*paintable_widget, vertical_container); window->show(); auto menubar = make(); auto app_menu = make("PaintBrush"); app_menu->add_action(GCommonActions::make_quit_action([](auto&) { GApplication::the().quit(0); return; })); menubar->add_menu(move(app_menu)); auto file_menu = make("File"); file_menu->add_action(GCommonActions::make_open_action([&](auto&) { GFilePicker picker; if (picker.exec() == GFilePicker::ExecOK) { auto filename = picker.selected_file().string(); auto bitmap = load_png(filename); if (!bitmap) { GMessageBox msgbox(String::format("Failed to load '%s'", filename.characters()), "Open failed", GMessageBox::Type::Error, GMessageBox::InputType::OK, window); msgbox.exec(); return; } paintable_widget->set_bitmap(*bitmap); } })); menubar->add_menu(move(file_menu)); auto edit_menu = make("Edit"); menubar->add_menu(move(edit_menu)); auto help_menu = make("Help"); help_menu->add_action(GAction::create("About", [](const GAction&) { dbgprintf("FIXME: Implement Help/About\n"); })); menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); return app.exec(); }