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

Function app_main

examples/multiple_windows.cpp:102–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102int app_main(int argc, char* argv[])
103{
104 SystemRef system = System::make();
105 FontRef font = FontMgr::Make()->defaultFont(12);
106
107 system->setAppMode(AppMode::GUI);
108 system->handleWindowResize = [&font](Window* w) { redraw_window(w, font); };
109 system->handleWindowMoving = [&font](Window* w) {
110 redraw_window(w, font);
111 w->invalidate();
112 };
113
114 // Create four windows for each screen with the bounds of the
115 // workarea.
116 ScreenList screens;
117 system->listScreens(screens);
118 char chr = 'A';
119 for (ScreenRef& screen : screens) {
120 const std::string primary = (screen->isPrimary() ? std::string(" (primary screen)") :
121 std::string());
122
123 WindowSpec spec;
124 spec.titled(true);
125 spec.position(WindowSpec::Position::Frame);
126 spec.frame(screen->workarea());
127 spec.screen(screen);
128
129 gfx::Point pos[4] = {
130 { 0, 0 },
131 { 1, 0 },
132 { 0, 1 },
133 { 1, 1 }
134 };
135 for (auto& p : pos) {
136 WindowSpec s = spec;
137 gfx::Rect frame = s.frame();
138 frame.w /= 2;
139 frame.h /= 2;
140 frame.x = frame.x + frame.w * p.x;
141 frame.y = frame.y + frame.h * p.y;
142 s.frame(frame);
143 add_window(std::string(1, chr++) + primary, s, font);
144 }
145 }
146
147 system->finishLaunching();
148 system->activateApp();
149
150 EventQueue* queue = system->eventQueue();
151 Event ev;
152 while (!windows.empty()) {
153 queue->getEvent(ev);
154
155 switch (ev.type()) {
156 case Event::CloseApp:
157 windows.clear(); // Close all windows
158 break;
159

Callers

nothing calls this directly

Calls 15

add_windowFunction · 0.85
destroy_windowFunction · 0.85
check_show_all_windowsFunction · 0.85
titledMethod · 0.80
eventQueueMethod · 0.80
windowMethod · 0.80
scancodeMethod · 0.80
nativeCursorMethod · 0.80
redraw_windowFunction · 0.70
defaultFontMethod · 0.45
setAppModeMethod · 0.45
invalidateMethod · 0.45

Tested by

no test coverage detected