| 27 | #include "SkrGui/widgets/mouse_region.hpp" |
| 28 | |
| 29 | int main(void) |
| 30 | { |
| 31 | using namespace skr::gui; |
| 32 | |
| 33 | // log system |
| 34 | skr::log::LogConstants::gFlushBehavior = skr::log::LogFlushBehavior::kFlushImmediate; |
| 35 | |
| 36 | // create backends |
| 37 | SkrNativeDevice* device = SkrNew<SkrNativeDevice>(); |
| 38 | device->init(); |
| 39 | |
| 40 | // create sandbox |
| 41 | Sandbox* sandbox = SkrNew<Sandbox>(device); |
| 42 | sandbox->init(); |
| 43 | |
| 44 | // setup content |
| 45 | { |
| 46 | auto widget = SNewWidget(Counter){}; |
| 47 | sandbox->set_content(widget); |
| 48 | } |
| 49 | |
| 50 | // input system |
| 51 | skr::input::InputSystem* input_system = nullptr; |
| 52 | { |
| 53 | // init input system |
| 54 | skr::input::Input::Initialize(); |
| 55 | input_system = skr::input::InputSystem::Create(); |
| 56 | |
| 57 | // create mapping context |
| 58 | auto mapping_ctx = input_system->create_mapping_context(); |
| 59 | input_system->add_mapping_context(mapping_ctx, 0, {}); |
| 60 | |
| 61 | // bind events |
| 62 | bind_pointer_event(input_system, mapping_ctx, sandbox); |
| 63 | } |
| 64 | |
| 65 | // handler |
| 66 | bool b_quit = false; |
| 67 | auto handler = skr_system_get_default_handler(); |
| 68 | handler->add_window_close_handler( |
| 69 | +[](SWindowHandle window, void* pQuit) { |
| 70 | bool& quit = *(bool*)pQuit; |
| 71 | quit = true; |
| 72 | }, |
| 73 | &b_quit); |
| 74 | handler->add_window_resize_handler( |
| 75 | +[](SWindowHandle window, int32_t w, int32_t h, void* usr_data) { |
| 76 | auto sandbox = reinterpret_cast<Sandbox*>(usr_data); |
| 77 | sandbox->resize_window(w, h); |
| 78 | }, |
| 79 | sandbox); |
| 80 | |
| 81 | // show window |
| 82 | { |
| 83 | WindowDesc desc = {}; |
| 84 | desc.size = { 600, 600 }; |
| 85 | desc.pos = { 300, 300 }; |
| 86 | desc.name = u8"SkrGUI Sandbox"; |
nothing calls this directly
no test coverage detected