|
5 | 5 | * Author: arturo
|
6 | 6 | */
|
7 | 7 |
|
8 |
| -#include <ofMainLoop.h> |
| 8 | +#include "ofMainLoop.h" |
9 | 9 | #include "ofWindowSettings.h"
|
10 | 10 | #include "ofAppBaseWindow.h"
|
11 | 11 | #include "ofBaseApp.h"
|
| 12 | +#include "ofConstants.h" |
12 | 13 |
|
13 | 14 | //========================================================================
|
14 | 15 | // default windowing
|
@@ -67,6 +68,23 @@ std::shared_ptr<ofAppBaseWindow> ofMainLoop::createWindow(const ofWindowSettings
|
67 | 68 | return window;
|
68 | 69 | }
|
69 | 70 |
|
| 71 | +template<typename Window> |
| 72 | +void ofMainLoop::addWindow(const std::shared_ptr<Window> & window){ |
| 73 | + allowMultiWindow = Window::allowsMultiWindow(); |
| 74 | + if(Window::doesLoop()){ |
| 75 | + windowLoop = Window::loop; |
| 76 | + } |
| 77 | + if(Window::needsPolling()){ |
| 78 | + windowPollEvents = Window::pollEvents; |
| 79 | + } |
| 80 | + if(!allowMultiWindow){ |
| 81 | + windowsApps.clear(); |
| 82 | + } |
| 83 | + windowsApps[window] = std::shared_ptr<ofBaseApp>(); |
| 84 | + currentWindow = window; |
| 85 | + ofAddListener(window->events().keyPressed,this,&ofMainLoop::keyPressed); |
| 86 | +} |
| 87 | + |
70 | 88 | void ofMainLoop::run(const std::shared_ptr<ofAppBaseWindow> & window, std::shared_ptr<ofBaseApp> && app){
|
71 | 89 | windowsApps[window] = app;
|
72 | 90 | if(app){
|
@@ -162,7 +180,7 @@ void ofMainLoop::exit(){
|
162 | 180 | for(auto i: windowsApps){
|
163 | 181 | std::shared_ptr<ofAppBaseWindow> window = i.first;
|
164 | 182 | std::shared_ptr<ofBaseApp> app = i.second;
|
165 |
| - |
| 183 | + |
166 | 184 | if(window == nullptr) {
|
167 | 185 | continue;
|
168 | 186 | }
|
@@ -260,5 +278,5 @@ void ofMainLoop::setEscapeQuitsLoop(bool quits){
|
260 | 278 | void ofMainLoop::keyPressed(ofKeyEventArgs & key){
|
261 | 279 | if (key.key == OF_KEY_ESC && escapeQuits == true){ // "escape"
|
262 | 280 | shouldClose(0);
|
263 |
| - } |
| 281 | + } |
264 | 282 | }
|
0 commit comments