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

Function app_main

examples/complextextlayout.cpp:129–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129int app_main(int argc, char* argv[])
130{
131 SystemRef system = System::make();
132 system->setAppMode(AppMode::GUI);
133
134 FontMgrRef fontMgr = FontMgr::Make();
135 FontRef font = fontMgr->defaultFont(32);
136 if (!font) {
137 std::printf("Font not found\n");
138 return 1;
139 }
140
141 WindowRef window = system->makeWindow(800, 800, 2);
142 window->setTitle(kTitle);
143
144 system->finishLaunching();
145 system->activateApp();
146
147 // Wait until a key is pressed or the window is closed
148 EventQueue* queue = system->eventQueue();
149 gfx::Point mousePos;
150 bool running = true;
151 bool redraw = true;
152
153 system->handleWindowResize = [&](Window* w) { draw_window(w, fontMgr, font, mousePos); };
154
155 while (running) {
156 // Pick next event in the queue (without waiting)
157 Event ev;
158 queue->getEvent(ev, 0.0);
159
160 // If there are no more events in the queue (Event::None type),
161 // redraw the window and wait for some event. We do this so we
162 // don't need to redraw the text on each mouse movement (we can
163 // process several mouse movements at the same time and redraw
164 // when the messages stop).
165 if (ev.type() == Event::None) {
166 if (redraw) {
167 redraw = false;
168 draw_window(window.get(), fontMgr, font, mousePos);
169 }
170 queue->getEvent(ev);
171 }
172
173 switch (ev.type()) {
174 case Event::CloseWindow: running = false; break;
175
176 case Event::KeyDown:
177 switch (ev.scancode()) {
178 case kKeyEsc: running = false; break;
179 case kKey1:
180 case kKey2:
181 case kKey3:
182 case kKey4:
183 case kKey5:
184 case kKey6:
185 case kKey7:
186 case kKey8:

Callers

nothing calls this directly

Calls 14

eventQueueMethod · 0.80
scancodeMethod · 0.80
draw_windowFunction · 0.70
setAppModeMethod · 0.45
defaultFontMethod · 0.45
makeWindowMethod · 0.45
setTitleMethod · 0.45
finishLaunchingMethod · 0.45
activateAppMethod · 0.45
getEventMethod · 0.45
typeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected