瀏覽代碼

Propagate window resize to viewer plugins.

Former-commit-id: 0f113c3617820842dea7f528c75284c6644ed5d8
Jérémie Dumas 8 年之前
父節點
當前提交
82a3add1c8
共有 3 個文件被更改,包括 13 次插入4 次删除
  1. 7 3
      include/igl/viewer/Viewer.cpp
  2. 1 1
      include/igl/viewer/Viewer.h
  3. 5 0
      include/igl/viewer/ViewerPlugin.h

+ 7 - 3
include/igl/viewer/Viewer.cpp

@@ -154,7 +154,7 @@ static void glfw_window_size(GLFWwindow* window, int width, int height)
   int w = width*highdpi;
   int w = width*highdpi;
   int h = height*highdpi;
   int h = height*highdpi;
 
 
-  __viewer->resize_callback(w, h);
+  __viewer->post_resize(w, h);
 
 
   // TODO: repositioning of the nanogui
   // TODO: repositioning of the nanogui
 }
 }
@@ -847,13 +847,17 @@ namespace viewer
     if (window) {
     if (window) {
       glfwSetWindowSize(window, w/highdpi, h/highdpi);
       glfwSetWindowSize(window, w/highdpi, h/highdpi);
     } else {
     } else {
-      resize_callback(w, h);
+      post_resize(w, h);
     }
     }
   }
   }
 
 
-  IGL_INLINE void Viewer::resize_callback(int w,int h)
+  IGL_INLINE void Viewer::post_resize(int w,int h)
   {
   {
     core.viewport = Eigen::Vector4f(0,0,w,h);
     core.viewport = Eigen::Vector4f(0,0,w,h);
+    for (unsigned int i = 0; i<plugins.size(); ++i)
+    {
+      plugins[i]->post_resize(w, h);
+    }
   }
   }
 
 
   IGL_INLINE void Viewer::snap_to_canonical_quaternion()
   IGL_INLINE void Viewer::snap_to_canonical_quaternion()

+ 1 - 1
include/igl/viewer/Viewer.h

@@ -120,7 +120,7 @@ namespace viewer
 
 
     // OpenGL context resize
     // OpenGL context resize
     IGL_INLINE void resize(int w,int h); // explicitly set window size
     IGL_INLINE void resize(int w,int h); // explicitly set window size
-    IGL_INLINE void resize_callback(int w,int h); // external resize due to user interaction
+    IGL_INLINE void post_resize(int w,int h); // external resize due to user interaction
 
 
     // Helper functions
     // Helper functions
     IGL_INLINE void snap_to_canonical_quaternion();
     IGL_INLINE void snap_to_canonical_quaternion();

+ 5 - 0
include/igl/viewer/ViewerPlugin.h

@@ -96,6 +96,11 @@ public:
     return false;
     return false;
   }
   }
 
 
+  // This function is called after the window has been resized
+  IGL_INLINE virtual void post_resize(int w, int h)
+  {
+  }
+
   // This function is called when the mouse button is pressed
   // This function is called when the mouse button is pressed
   // - button can be GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON or GLUT_RIGHT_BUTTON
   // - button can be GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON or GLUT_RIGHT_BUTTON
   // - modifiers is a bitfield that might one or more of the following bits Preview3D::NO_KEY, Preview3D::SHIFT, Preview3D::CTRL, Preview3D::ALT;
   // - modifiers is a bitfield that might one or more of the following bits Preview3D::NO_KEY, Preview3D::SHIFT, Preview3D::CTRL, Preview3D::ALT;