comparison Platforms/Wasm/Defaults.h @ 236:f73d722d98c8 am

renamed folder
author am@osimis.io
date Tue, 19 Jun 2018 16:06:32 +0200
parents Platforms/WebAssembly/Defaults.h@68856534f005
children 092db46c6291
comparison
equal deleted inserted replaced
235:ce4405d98b92 236:f73d722d98c8
1 #pragma once
2
3 #include <emscripten/emscripten.h>
4
5 #include <Framework/dev.h>
6 #include <Framework/Viewport/WidgetViewport.h>
7 #include <Framework/Widgets/LayerWidget.h>
8 #include <Framework/Widgets/LayoutWidget.h>
9 #include <Applications/Wasm/BasicWasmApplication.h>
10 #include <Applications/Wasm/BasicWasmApplicationContext.h>
11
12 typedef OrthancStone::WidgetViewport* ViewportHandle; // the objects exchanged between JS and C++
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 // JS methods accessible from C++
19 extern void ScheduleWebViewportRedrawFromCpp(ViewportHandle cppViewportHandle);
20
21 // C++ methods accessible from JS
22 extern void EMSCRIPTEN_KEEPALIVE CreateWasmApplication(ViewportHandle cppViewportHandle);
23
24 #ifdef __cplusplus
25 }
26 #endif
27
28 extern OrthancStone::BasicWasmApplication* CreateUserApplication();
29
30 namespace OrthancStone {
31
32 // default Ovserver to trigger Viewport redraw when something changes in the Viewport
33 class ChangeObserver :
34 public OrthancStone::IViewport::IObserver
35 {
36 private:
37 // Flag to avoid flooding JavaScript with redundant Redraw requests
38 bool isScheduled_;
39
40 public:
41 ChangeObserver() :
42 isScheduled_(false)
43 {
44 }
45
46 void Reset()
47 {
48 isScheduled_ = false;
49 }
50
51 virtual void NotifyChange(const OrthancStone::IViewport &viewport)
52 {
53 if (!isScheduled_)
54 {
55 ScheduleWebViewportRedrawFromCpp((ViewportHandle)&viewport); // loosing constness when transmitted to Web
56 isScheduled_ = true;
57 }
58 }
59 };
60
61 // default status bar to log messages on the console/stdout
62 class StatusBar : public OrthancStone::IStatusBar
63 {
64 public:
65 virtual void ClearMessage()
66 {
67 }
68
69 virtual void SetMessage(const std::string& message)
70 {
71 printf("%s\n", message.c_str());
72 }
73 };
74 }