changeset 233:68856534f005 am

added layout to VSOL, SDL & wasm working
author am@osimis.io
date Fri, 15 Jun 2018 14:29:25 +0200
parents 7d3b2c4f9ba1
children 9afb50d1ac14
files Applications/IBasicApplication.h Applications/Sdl/BasicSdlApplication.cpp Applications/Sdl/BasicSdlApplicationContext.cpp Applications/Sdl/BasicSdlApplicationContext.h Platforms/WebAssembly/Defaults.cpp Platforms/WebAssembly/Defaults.h Platforms/WebAssembly/wasm-application.ts
diffstat 7 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/IBasicApplication.h	Fri Jun 15 11:23:04 2018 +0200
+++ b/Applications/IBasicApplication.h	Fri Jun 15 14:29:25 2018 +0200
@@ -65,9 +65,9 @@
                             const boost::program_options::variables_map& parameters) = 0;
 
 #if ORTHANC_ENABLE_SDL == 1
-  virtual BasicApplicationContext& CreateApplicationContext(Orthanc::WebServiceParameters& orthancWebService) = 0;
+  virtual BasicApplicationContext& CreateApplicationContext(Orthanc::WebServiceParameters& orthancWebService, OrthancStone::WidgetViewport* centralViewport) = 0;
 #else
-  virtual BasicApplicationContext& CreateApplicationContext(IWebService& orthancWebService) = 0;
+  virtual BasicApplicationContext& CreateApplicationContext(IWebService& orthancWebService, std::shared_ptr<WidgetViewport> centralViewport) = 0;
 #endif
 
     virtual std::string GetTitle() const = 0;
--- a/Applications/Sdl/BasicSdlApplication.cpp	Fri Jun 15 11:23:04 2018 +0200
+++ b/Applications/Sdl/BasicSdlApplication.cpp	Fri Jun 15 14:29:25 2018 +0200
@@ -243,7 +243,8 @@
       LOG(WARNING) << "Creating the widgets of the application";
 
       LogStatusBar statusBar;
-      BasicSdlApplicationContext& context = dynamic_cast<BasicSdlApplicationContext&>(application.CreateApplicationContext(webService));
+      OrthancStone::WidgetViewport* centralViewport = new OrthancStone::WidgetViewport();
+      BasicSdlApplicationContext& context = dynamic_cast<BasicSdlApplicationContext&>(application.CreateApplicationContext(webService, centralViewport));
 
       application.Initialize(statusBar, parameters);
 
--- a/Applications/Sdl/BasicSdlApplicationContext.cpp	Fri Jun 15 11:23:04 2018 +0200
+++ b/Applications/Sdl/BasicSdlApplicationContext.cpp	Fri Jun 15 14:29:25 2018 +0200
@@ -25,7 +25,7 @@
 {
   IWidget& BasicSdlApplicationContext::SetCentralWidget(IWidget* widget)   // Takes ownership
   {
-    centralViewport_.SetCentralWidget(widget);
+    centralViewport_->SetCentralWidget(widget);
     return *widget;
   }
 
@@ -44,10 +44,11 @@
   }
   
 
-  BasicSdlApplicationContext::BasicSdlApplicationContext(Orthanc::WebServiceParameters& orthanc) :
+  BasicSdlApplicationContext::BasicSdlApplicationContext(Orthanc::WebServiceParameters& orthanc, WidgetViewport* centralViewport) :
     oracle_(viewportMutex_, 4),  // Use 4 threads to download
     //oracle_(viewportMutex_, 1),  // Disable threading to be reproducible
     webService_(oracle_, orthanc),
+    centralViewport_(centralViewport),
     stopped_(true),
     updateDelay_(100)   // By default, 100ms between each refresh of the content
   {
@@ -59,7 +60,7 @@
   {
     oracle_.Start();
 
-    if (centralViewport_.HasUpdateContent())
+    if (centralViewport_->HasUpdateContent())
     {
       stopped_ = false;
       updateThread_ = boost::thread(UpdateThread, this);
--- a/Applications/Sdl/BasicSdlApplicationContext.h	Fri Jun 15 11:23:04 2018 +0200
+++ b/Applications/Sdl/BasicSdlApplicationContext.h	Fri Jun 15 14:29:25 2018 +0200
@@ -42,7 +42,7 @@
     Oracle              oracle_;
     OracleWebService    webService_;
     boost::mutex        viewportMutex_;
-    WidgetViewport      centralViewport_;
+    std::unique_ptr<WidgetViewport>      centralViewport_;
     boost::thread       updateThread_;
     bool                stopped_;
     unsigned int        updateDelay_;
@@ -57,7 +57,7 @@
     public:
       ViewportLocker(BasicSdlApplicationContext& that) :
         lock_(that.viewportMutex_),
-        viewport_(that.centralViewport_)
+        viewport_(*(that.centralViewport_.get()))
       {
       }
 
@@ -68,7 +68,7 @@
     };
 
     
-    BasicSdlApplicationContext(Orthanc::WebServiceParameters& orthanc);
+    BasicSdlApplicationContext(Orthanc::WebServiceParameters& orthanc, WidgetViewport* centralViewport);
 
     virtual ~BasicSdlApplicationContext() {}
 
--- a/Platforms/WebAssembly/Defaults.cpp	Fri Jun 15 11:23:04 2018 +0200
+++ b/Platforms/WebAssembly/Defaults.cpp	Fri Jun 15 14:29:25 2018 +0200
@@ -81,7 +81,7 @@
     boost::program_options::variables_map parameters;
     application->GetStartupParameters(parameters);
 
-    BasicWasmApplicationContext& context = dynamic_cast<BasicWasmApplicationContext&>(application->CreateApplicationContext(OrthancStone::WasmWebService::GetInstance()));
+    BasicWasmApplicationContext& context = dynamic_cast<BasicWasmApplicationContext&>(application->CreateApplicationContext(OrthancStone::WasmWebService::GetInstance(), NULL));
     application->Initialize(statusBar_, parameters);
 
 //    viewport->SetSize(width_, height_);
--- a/Platforms/WebAssembly/Defaults.h	Fri Jun 15 11:23:04 2018 +0200
+++ b/Platforms/WebAssembly/Defaults.h	Fri Jun 15 14:29:25 2018 +0200
@@ -9,7 +9,7 @@
 #include <Applications/Wasm/BasicWasmApplication.h>
 #include <Applications/Wasm/BasicWasmApplicationContext.h>
 
-typedef OrthancStone::IViewport* ViewportHandle; // the objects exchanged between JS and C++
+typedef OrthancStone::WidgetViewport* ViewportHandle; // the objects exchanged between JS and C++
 
 #ifdef __cplusplus
 extern "C" {
--- a/Platforms/WebAssembly/wasm-application.ts	Fri Jun 15 11:23:04 2018 +0200
+++ b/Platforms/WebAssembly/wasm-application.ts	Fri Jun 15 14:29:25 2018 +0200
@@ -103,7 +103,7 @@
     CreateWasmApplication = StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']);
     CreateCppViewport = StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []);
     ReleaseCppViewport = StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']);
-    StartWasmApplication = StoneFrameworkModule.cwrap('StartWasmApplication', null, []);
+    StartWasmApplication = StoneFrameworkModule.cwrap('StartWasmApplication', null, ['number']);
 
     WasmWebService_NotifySuccess = StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']);
     WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);