annotate Platforms/Wasm/Defaults.h @ 1357:0dc5b8a4b3a0 broker

hgignore
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 Apr 2020 15:23:07 +0200
parents c35e98d22764
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
1 #pragma once
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
2
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
3 #include <emscripten/emscripten.h>
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
4
732
c35e98d22764 move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 726
diff changeset
5 #include "../../Framework/Deprecated/Viewport/WidgetViewport.h"
c35e98d22764 move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 726
diff changeset
6 #include "../../Framework/Deprecated/Widgets/LayoutWidget.h"
288
8c8da145fefa renamings and doc
am@osimis.io
parents: 287
diff changeset
7 #include <Applications/IStoneApplication.h>
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 288
diff changeset
8 #include <Platforms/Wasm/WasmPlatformApplicationAdapter.h>
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
9
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 603
diff changeset
10 typedef Deprecated::WidgetViewport* ViewportHandle; // the objects exchanged between JS and C++
227
c8f11437a6fd getting ready for multiple viewports
am@osimis.io
parents: 223
diff changeset
11
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
12 #ifdef __cplusplus
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
13 extern "C" {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
14 #endif
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
15
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
16 // JS methods accessible from C++
229
b0ba3b38a23c ScheduleRedraw can handle multiple viewports
am@osimis.io
parents: 228
diff changeset
17 extern void ScheduleWebViewportRedrawFromCpp(ViewportHandle cppViewportHandle);
508
7105a0bad250 - Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents: 389
diff changeset
18 extern void UpdateStoneApplicationStatusFromCppWithString(const char* statusUpdateMessage);
7105a0bad250 - Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents: 389
diff changeset
19 extern void UpdateStoneApplicationStatusFromCppWithSerializedMessage(const char* statusUpdateMessage);
603
70992b38aa8a new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
Benjamin Golinvaux <bgo@osimis.io>
parents: 508
diff changeset
20 extern void stone_console_error(const char*);
70992b38aa8a new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
Benjamin Golinvaux <bgo@osimis.io>
parents: 508
diff changeset
21 extern void stone_console_warning(const char*);
70992b38aa8a new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
Benjamin Golinvaux <bgo@osimis.io>
parents: 508
diff changeset
22 extern void stone_console_info(const char*);
70992b38aa8a new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
Benjamin Golinvaux <bgo@osimis.io>
parents: 508
diff changeset
23 extern void stone_console_trace(const char*);
70992b38aa8a new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
Benjamin Golinvaux <bgo@osimis.io>
parents: 508
diff changeset
24
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
25 // C++ methods accessible from JS
229
b0ba3b38a23c ScheduleRedraw can handle multiple viewports
am@osimis.io
parents: 228
diff changeset
26 extern void EMSCRIPTEN_KEEPALIVE CreateWasmApplication(ViewportHandle cppViewportHandle);
254
abc1c6231947 cleanup
am@osimis.io
parents: 253
diff changeset
27 extern void EMSCRIPTEN_KEEPALIVE SetStartupParameter(const char* keyc, const char* value);
abc1c6231947 cleanup
am@osimis.io
parents: 253
diff changeset
28
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
29
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
30 #ifdef __cplusplus
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
31 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
32 #endif
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
33
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 288
diff changeset
34 // these methods must be implemented in the custom app "mainWasm.cpp"
288
8c8da145fefa renamings and doc
am@osimis.io
parents: 287
diff changeset
35 extern OrthancStone::IStoneApplication* CreateUserApplication(OrthancStone::MessageBroker& broker);
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 288
diff changeset
36 extern OrthancStone::WasmPlatformApplicationAdapter* CreateWasmApplicationAdapter(OrthancStone::MessageBroker& broker, OrthancStone::IStoneApplication* application);
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
37
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
38 namespace OrthancStone {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
39
287
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 278
diff changeset
40 // default Observer to trigger Viewport redraw when something changes in the Viewport
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
41 class ViewportContentChangedObserver : public IObserver
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
42 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
43 private:
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
44 // Flag to avoid flooding JavaScript with redundant Redraw requests
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
45 bool isScheduled_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
46
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
47 public:
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
48 ViewportContentChangedObserver(MessageBroker& broker) :
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
49 IObserver(broker),
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
50 isScheduled_(false)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
51 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
52 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
53
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
54 void Reset()
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
55 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
56 isScheduled_ = false;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
57 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
58
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 603
diff changeset
59 void OnViewportChanged(const Deprecated::IViewport::ViewportChangedMessage& message)
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
60 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
61 if (!isScheduled_)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
62 {
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
63 ScheduleWebViewportRedrawFromCpp((ViewportHandle)&message.GetOrigin()); // loosing constness when transmitted to Web
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
64 isScheduled_ = true;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
65 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
66 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
67 };
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
68
223
d30a10d574ec refactoring continued - not working
am@osimis.io
parents: 222
diff changeset
69 // default status bar to log messages on the console/stdout
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 603
diff changeset
70 class StatusBar : public Deprecated::IStatusBar
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
71 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
72 public:
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
73 virtual void ClearMessage()
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
74 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
75 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
76
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
77 virtual void SetMessage(const std::string& message)
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
78 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
79 printf("%s\n", message.c_str());
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
80 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
81 };
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 307
diff changeset
82 }