changeset 1948:d459477804bf

added SetFrame() in Stone Web viewer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Jul 2022 16:17:23 +0200
parents 31fd7aba48ca
children d3ae6858e77b
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Jul 15 14:35:05 2022 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Jul 15 16:17:23 2022 +0200
@@ -2860,6 +2860,18 @@
   }
 
 
+  void SetFrame(unsigned int frameNumber)
+  {
+    if (cursor_.get() != NULL &&
+        frameNumber < cursor_->GetFramesCount() &&
+        frameNumber != cursor_->GetCurrentIndex())
+    {
+      cursor_->SetCurrentIndex(frameNumber);
+      Redraw();
+    }
+  }
+
+
   void GoToFirstFrame()
   {
     if (cursor_.get() != NULL &&
@@ -4008,6 +4020,21 @@
 
 
   EMSCRIPTEN_KEEPALIVE
+  void SetFrame(const char* canvas,
+                int frameNumber)
+  {
+    try
+    {
+      if (frameNumber >= 0)
+      {
+        GetViewport(canvas)->SetFrame(static_cast<unsigned int>(frameNumber));
+      }
+    }
+    EXTERN_CATCH_EXCEPTIONS;
+  }
+
+
+  EMSCRIPTEN_KEEPALIVE
   void GoToFirstFrame(const char* canvas)
   {
     try