diff Platforms/Wasm/Defaults.cpp @ 385:6cc3ce74dc05

using message broker in widgets
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 07 Nov 2018 20:49:41 +0100
parents 8716176ff7f0
children e33659decec5
line wrap: on
line diff
--- a/Platforms/Wasm/Defaults.cpp	Wed Nov 07 16:17:02 2018 +0100
+++ b/Platforms/Wasm/Defaults.cpp	Wed Nov 07 20:49:41 2018 +0100
@@ -20,7 +20,7 @@
 static OrthancStone::StartupParametersBuilder startupParametersBuilder;
 static OrthancStone::MessageBroker broker;
 
-static OrthancStone::ViewportContentChangedObserver viewportContentChangedObserver_;
+static OrthancStone::ViewportContentChangedObserver viewportContentChangedObserver_(broker);
 static OrthancStone::StatusBar statusBar_;
 
 static std::list<std::shared_ptr<OrthancStone::WidgetViewport>> viewports_;
@@ -44,7 +44,7 @@
   // when WASM needs a C++ viewport
   ViewportHandle EMSCRIPTEN_KEEPALIVE CreateCppViewport() {
     
-    std::shared_ptr<OrthancStone::WidgetViewport> viewport(new OrthancStone::WidgetViewport);
+    std::shared_ptr<OrthancStone::WidgetViewport> viewport(new OrthancStone::WidgetViewport(broker));
     printf("viewport %x\n", (int)viewport.get());
 
     viewports_.push_back(viewport);
@@ -52,7 +52,10 @@
     printf("There are now %d viewports in C++\n", viewports_.size());
 
     viewport->SetStatusBar(statusBar_);
-    viewport->Register(viewportContentChangedObserver_);
+
+    viewport->RegisterObserverCallback(
+      new Callable<ViewportContentChangedObserver, IViewport::ViewportChangedMessage>
+      (viewportContentChangedObserver_, &ViewportContentChangedObserver::OnViewportChanged));
 
     return viewport.get();
   }