Files
mirage/example/src/main.cpp
2025-03-24 13:22:47 +08:00

43 lines
1.1 KiB
C++

//
// Created by Administrator on 25-2-26.
//
#include "mirage.h"
#include "core/window/mwindow.h"
#include "widget/compound_widget/mbutton.h"
#include "widget/panel_widget/mbox.h"
int main(int argc, char* argv[]) {
mirage_app app;
app.init();
auto window = std::make_shared<mwindow>();
window->create_window(800, 600, L"Hello, World!");
window->show();
mirage_app::get_render_context()->setup_surface(window.get());
widget_manager::get().init_window(window);
auto weak_vbox = widget_manager::get().new_widget<mv_box>(window.get());
auto vbox = weak_vbox.lock();
vbox->add_child<mbutton>().margin({ 5 });
vbox->add_child<mbutton>().margin({ 5 }).stretch(1);
auto weak_hbox = vbox->add_child<mh_box>().stretch(2).get();
auto hbox = std::static_pointer_cast<mh_box>(weak_hbox.lock());
hbox->add_child<mbutton>().margin({ 5 });
hbox->add_child<mbutton>().margin({ 5 }).stretch();
hbox->add_child<mbutton>().margin({ 5 });
vbox->add_child<mbutton>().margin({ 5 });
vbox->add_child<mbutton>().margin({ 5 });
window->set_content(vbox);
app.run();
return 0;
}