comparison Platforms/WebAssembly/Defaults.h @ 229:b0ba3b38a23c am

ScheduleRedraw can handle multiple viewports
author am@osimis.io
date Thu, 14 Jun 2018 16:51:43 +0200
parents 210c1ce8e1a6
children 68856534f005
comparison
equal deleted inserted replaced
228:210c1ce8e1a6 229:b0ba3b38a23c
7 #include <Framework/Widgets/LayerWidget.h> 7 #include <Framework/Widgets/LayerWidget.h>
8 #include <Framework/Widgets/LayoutWidget.h> 8 #include <Framework/Widgets/LayoutWidget.h>
9 #include <Applications/Wasm/BasicWasmApplication.h> 9 #include <Applications/Wasm/BasicWasmApplication.h>
10 #include <Applications/Wasm/BasicWasmApplicationContext.h> 10 #include <Applications/Wasm/BasicWasmApplicationContext.h>
11 11
12 typedef OrthancStone::WidgetViewport* ViewportHandle; // the objects exchanged between JS and C++ 12 typedef OrthancStone::IViewport* ViewportHandle; // the objects exchanged between JS and C++
13 13
14 #ifdef __cplusplus 14 #ifdef __cplusplus
15 extern "C" { 15 extern "C" {
16 #endif 16 #endif
17 17
18 // JS methods accessible from C++ 18 // JS methods accessible from C++
19 extern void ScheduleRedraw(); 19 extern void ScheduleWebViewportRedrawFromCpp(ViewportHandle cppViewportHandle);
20 20
21 // C++ methods accessible from JS 21 // C++ methods accessible from JS
22 extern void EMSCRIPTEN_KEEPALIVE CreateWasmApplication(ViewportHandle viewport); 22 extern void EMSCRIPTEN_KEEPALIVE CreateWasmApplication(ViewportHandle cppViewportHandle);
23 23
24 #ifdef __cplusplus 24 #ifdef __cplusplus
25 } 25 }
26 #endif 26 #endif
27 27
46 void Reset() 46 void Reset()
47 { 47 {
48 isScheduled_ = false; 48 isScheduled_ = false;
49 } 49 }
50 50
51 virtual void NotifyChange(const OrthancStone::IViewport &scene) 51 virtual void NotifyChange(const OrthancStone::IViewport &viewport)
52 { 52 {
53 if (!isScheduled_) 53 if (!isScheduled_)
54 { 54 {
55 ScheduleRedraw(); 55 ScheduleWebViewportRedrawFromCpp((ViewportHandle)&viewport); // loosing constness when transmitted to Web
56 isScheduled_ = true; 56 isScheduled_ = true;
57 } 57 }
58 } 58 }
59 }; 59 };
60 60