MCPcopy Create free account
hub / github.com/aseprite/laf / app_main

Function app_main

examples/custom_window.cpp:230–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230int app_main(int argc, char* argv[])
231{
232 SystemRef system = System::make();
233 system->setAppMode(AppMode::GUI);
234
235 FontRef font = FontMgr::Make()->defaultFont();
236 WindowRef window = create_window();
237 Hit hit = Hit::None; // Current area which the mouse cursor hits
238 window->activate();
239
240 system->handleWindowResize = [&](Window* w) { draw_window(w, font, hit); };
241 system->finishLaunching();
242 system->activateApp();
243
244 EventQueue* queue = system->eventQueue();
245 bool running = true;
246 bool redraw = true;
247 while (running) {
248 if (redraw) {
249 redraw = false;
250 draw_window(window.get(), font, hit);
251 }
252
253 Event ev;
254 queue->getEvent(ev);
255
256 switch (ev.type()) {
257 case Event::CloseApp:
258 case Event::CloseWindow: running = false; break;
259
260 case Event::KeyDown:
261 switch (ev.scancode()) {
262 case kKeyEsc: running = false; break;
263 case kKeyF:
264 case kKeyF11: window->setFullscreen(!window->isFullscreen()); break;
265 default: break;
266 }
267 break;
268
269 case Event::MouseEnter:
270 case Event::MouseMove:
271 redraw = update_hit(window.get(), ev, hit);
272 handle_mouse_move(window.get(), hit);
273 break;
274
275 case Event::MouseDown:
276 redraw = update_hit(window.get(), ev, hit);
277 if (!handle_mouse_down(window.get(), ev, hit))
278 running = false;
279 break;
280
281 case Event::MouseLeave: redraw = update_hit(window.get(), ev, hit); break;
282
283 default: break;
284 }
285 }
286
287 return 0;

Callers

nothing calls this directly

Calls 15

update_hitFunction · 0.85
handle_mouse_moveFunction · 0.85
handle_mouse_downFunction · 0.85
eventQueueMethod · 0.80
scancodeMethod · 0.80
create_windowFunction · 0.70
draw_windowFunction · 0.70
setAppModeMethod · 0.45
defaultFontMethod · 0.45
activateMethod · 0.45
finishLaunchingMethod · 0.45
activateAppMethod · 0.45

Tested by

no test coverage detected