comparison 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
comparison
equal deleted inserted replaced
384:d20d75f20c5d 385:6cc3ce74dc05
18 static std::unique_ptr<OrthancStone::WasmPlatformApplicationAdapter> applicationWasmAdapter = NULL; 18 static std::unique_ptr<OrthancStone::WasmPlatformApplicationAdapter> applicationWasmAdapter = NULL;
19 static std::unique_ptr<OrthancStone::StoneApplicationContext> context; 19 static std::unique_ptr<OrthancStone::StoneApplicationContext> context;
20 static OrthancStone::StartupParametersBuilder startupParametersBuilder; 20 static OrthancStone::StartupParametersBuilder startupParametersBuilder;
21 static OrthancStone::MessageBroker broker; 21 static OrthancStone::MessageBroker broker;
22 22
23 static OrthancStone::ViewportContentChangedObserver viewportContentChangedObserver_; 23 static OrthancStone::ViewportContentChangedObserver viewportContentChangedObserver_(broker);
24 static OrthancStone::StatusBar statusBar_; 24 static OrthancStone::StatusBar statusBar_;
25 25
26 static std::list<std::shared_ptr<OrthancStone::WidgetViewport>> viewports_; 26 static std::list<std::shared_ptr<OrthancStone::WidgetViewport>> viewports_;
27 27
28 std::shared_ptr<OrthancStone::WidgetViewport> FindViewportSharedPtr(ViewportHandle viewport) { 28 std::shared_ptr<OrthancStone::WidgetViewport> FindViewportSharedPtr(ViewportHandle viewport) {
42 using namespace OrthancStone; 42 using namespace OrthancStone;
43 43
44 // when WASM needs a C++ viewport 44 // when WASM needs a C++ viewport
45 ViewportHandle EMSCRIPTEN_KEEPALIVE CreateCppViewport() { 45 ViewportHandle EMSCRIPTEN_KEEPALIVE CreateCppViewport() {
46 46
47 std::shared_ptr<OrthancStone::WidgetViewport> viewport(new OrthancStone::WidgetViewport); 47 std::shared_ptr<OrthancStone::WidgetViewport> viewport(new OrthancStone::WidgetViewport(broker));
48 printf("viewport %x\n", (int)viewport.get()); 48 printf("viewport %x\n", (int)viewport.get());
49 49
50 viewports_.push_back(viewport); 50 viewports_.push_back(viewport);
51 51
52 printf("There are now %d viewports in C++\n", viewports_.size()); 52 printf("There are now %d viewports in C++\n", viewports_.size());
53 53
54 viewport->SetStatusBar(statusBar_); 54 viewport->SetStatusBar(statusBar_);
55 viewport->Register(viewportContentChangedObserver_); 55
56 viewport->RegisterObserverCallback(
57 new Callable<ViewportContentChangedObserver, IViewport::ViewportChangedMessage>
58 (viewportContentChangedObserver_, &ViewportContentChangedObserver::OnViewportChanged));
56 59
57 return viewport.get(); 60 return viewport.get();
58 } 61 }
59 62
60 // when WASM does not need a viewport anymore, it should release it 63 // when WASM does not need a viewport anymore, it should release it