Mercurial > hg > orthanc-stone
comparison Platforms/Wasm/Defaults.h @ 385:6cc3ce74dc05
using message broker in widgets
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 07 Nov 2018 20:49:41 +0100 |
parents | be2660b6e40a |
children | 3e6e10a5a6c8 |
comparison
equal
deleted
inserted
replaced
384:d20d75f20c5d | 385:6cc3ce74dc05 |
---|---|
33 extern OrthancStone::WasmPlatformApplicationAdapter* CreateWasmApplicationAdapter(OrthancStone::MessageBroker& broker, OrthancStone::IStoneApplication* application); | 33 extern OrthancStone::WasmPlatformApplicationAdapter* CreateWasmApplicationAdapter(OrthancStone::MessageBroker& broker, OrthancStone::IStoneApplication* application); |
34 | 34 |
35 namespace OrthancStone { | 35 namespace OrthancStone { |
36 | 36 |
37 // default Observer to trigger Viewport redraw when something changes in the Viewport | 37 // default Observer to trigger Viewport redraw when something changes in the Viewport |
38 class ViewportContentChangedObserver : | 38 class ViewportContentChangedObserver : public IObserver |
39 public OrthancStone::IViewport::IObserver | |
40 { | 39 { |
41 private: | 40 private: |
42 // Flag to avoid flooding JavaScript with redundant Redraw requests | 41 // Flag to avoid flooding JavaScript with redundant Redraw requests |
43 bool isScheduled_; | 42 bool isScheduled_; |
44 | 43 |
45 public: | 44 public: |
46 ViewportContentChangedObserver() : | 45 ViewportContentChangedObserver(MessageBroker& broker) : |
46 IObserver(broker), | |
47 isScheduled_(false) | 47 isScheduled_(false) |
48 { | 48 { |
49 } | 49 } |
50 | 50 |
51 void Reset() | 51 void Reset() |
52 { | 52 { |
53 isScheduled_ = false; | 53 isScheduled_ = false; |
54 } | 54 } |
55 | 55 |
56 virtual void OnViewportContentChanged(const OrthancStone::IViewport &viewport) | 56 void OnViewportChanged(const IViewport::ViewportChangedMessage& message) |
57 { | 57 { |
58 if (!isScheduled_) | 58 if (!isScheduled_) |
59 { | 59 { |
60 ScheduleWebViewportRedrawFromCpp((ViewportHandle)&viewport); // loosing constness when transmitted to Web | 60 ScheduleWebViewportRedrawFromCpp((ViewportHandle)&message.GetOrigin()); // loosing constness when transmitted to Web |
61 isScheduled_ = true; | 61 isScheduled_ = true; |
62 } | 62 } |
63 } | 63 } |
64 }; | 64 }; |
65 | 65 |