]> git.mxchange.org Git - flightgear.git/blobdiff - src/Canvas/window.cxx
toggle fullscreen: also adapt GUI plane when resizing
[flightgear.git] / src / Canvas / window.cxx
index 43c9a1654b764942c445792c64d619375831c43f..d79e1cb7a03573ae7772b41a35161f3fbcb095a8 100644 (file)
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "window.hxx"
-#include <Canvas/canvas.hxx>
+#include <simgear/canvas/Canvas.hxx>
 
 #include <osgGA/GUIEventHandler>
 
@@ -28,8 +28,12 @@ namespace canvas
   //----------------------------------------------------------------------------
   Window::Window(SGPropertyNode* node):
     PropertyBasedElement(node),
-    _image(node)
+    _image( simgear::canvas::CanvasPtr(),
+            node,
+            simgear::canvas::Style() )
   {
+    _image.removeListener();
+
     // TODO probably better remove default position and size
     node->setFloatValue("x", 50);
     node->setFloatValue("y", 100);
@@ -44,10 +48,7 @@ namespace canvas
   //----------------------------------------------------------------------------
   Window::~Window()
   {
-    BOOST_FOREACH(osg::Group* parent, getGroup()->getParents())
-    {
-      parent->removeChild(getGroup());
-    }
+
   }
 
   //----------------------------------------------------------------------------
@@ -59,7 +60,10 @@ namespace canvas
   //----------------------------------------------------------------------------
   void Window::valueChanged(SGPropertyNode * node)
   {
-    _image.valueChanged(node);
+    if( node->getParent() == _node && node->getNameString() == "raise-top" )
+      doRaise(node);
+    else
+      _image.valueChanged(node);
   }
 
   //----------------------------------------------------------------------------
@@ -69,25 +73,25 @@ namespace canvas
   }
 
   //----------------------------------------------------------------------------
-  const Rect<float>& Window::getRegion() const
+  const simgear::Rect<float>& Window::getRegion() const
   {
     return _image.getRegion();
   }
 
   //----------------------------------------------------------------------------
-  void Window::setCanvas(CanvasPtr canvas)
+  void Window::setCanvas(simgear::canvas::CanvasPtr canvas)
   {
-    _image.setCanvas(canvas);
+    _image.setSrcCanvas(canvas);
   }
 
   //----------------------------------------------------------------------------
-  CanvasWeakPtr Window::getCanvas() const
+  simgear::canvas::CanvasWeakPtr Window::getCanvas() const
   {
-    return _image.getCanvas();
+    return _image.getSrcCanvas();
   }
 
   //----------------------------------------------------------------------------
-  bool Window::handleMouseEvent(const MouseEvent& event)
+  bool Window::handleMouseEvent(const simgear::canvas::MouseEvent& event)
   {
     if( !getCanvas().expired() )
       return getCanvas().lock()->handleMouseEvent(event);
@@ -95,4 +99,22 @@ namespace canvas
       return false;
   }
 
+  //----------------------------------------------------------------------------
+  void Window::doRaise(SGPropertyNode* node_raise)
+  {
+    if( !node_raise->getBoolValue() )
+      return;
+
+    BOOST_FOREACH(osg::Group* parent, getGroup()->getParents())
+    {
+      // Remove window...
+      parent->removeChild(getGroup());
+
+      // ...and add again as topmost window
+      parent->addChild(getGroup());
+    }
+
+    node_raise->setBoolValue(false);
+  }
+
 } // namespace canvas