]> git.mxchange.org Git - flightgear.git/commitdiff
CanvasWidget: add auto-viewport property.
authorThomas Geymayer <tomgey@gmail.com>
Mon, 25 Feb 2013 14:30:01 +0000 (15:30 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 25 Feb 2013 14:32:07 +0000 (15:32 +0100)
The auto-viewport property allows to disable automatic
update of the canvas viewport update upon resizing
the PUI canvas widget.

src/GUI/CanvasWidget.cxx
src/GUI/CanvasWidget.hxx

index b2aeb59c48b6b969ebc8e5507e42f4f2bd7f2b5d..3c99f90910d0f469e4d170d5aacf42e89ebd67cd 100644 (file)
@@ -29,7 +29,8 @@ CanvasWidget::CanvasWidget( int x, int y,
   puObject(x, y, width, height),
   _canvas_mgr( dynamic_cast<CanvasMgr*>(globals->get_subsystem("Canvas")) ),
   _last_x(0),
-  _last_y(0)
+  _last_y(0),
+  _auto_viewport( props->getBoolValue("auto-viewport", true) )
 {
   if( !_canvas_mgr )
   {
@@ -185,8 +186,11 @@ void CanvasWidget::setSize(int w, int h)
 {
   puObject::setSize(w, h);
 
-  _canvas->getProps()->setIntValue("view[0]", w);
-  _canvas->getProps()->setIntValue("view[1]", h);
+  if( _auto_viewport )
+  {
+    _canvas->getProps()->setIntValue("view[0]", w);
+    _canvas->getProps()->setIntValue("view[1]", h);
+  }
 }
 
 //------------------------------------------------------------------------------
index a91193814eb6973998f3b5a3e069eac23782ba9c..8d4f60780fd569bcbd128e4cc2bceadc50e38cd2 100644 (file)
@@ -40,6 +40,9 @@ class CanvasWidget:
 
     float _last_x,
           _last_y;
+    bool  _auto_viewport; //!< Set true to get the canvas view dimensions
+                          //   automatically resized if the size of the widget
+                          //   changes.
 
     static SGPropertyNode_ptr _time,
                               _view_height;