]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/layout/NasalWidget.cxx
canvas::Layout: support for alignment.
[simgear.git] / simgear / canvas / layout / NasalWidget.cxx
index 01d3f55af2e30f179cbf2e8ebd242afdc42ffb10..5c027e8518359be9470a54f39c766ae63b5313e8 100644 (file)
@@ -46,41 +46,6 @@ namespace canvas
     onRemove();
   }
 
-  //----------------------------------------------------------------------------
-  void NasalWidget::invalidate()
-  {
-    LayoutItem::invalidate();
-    _flags |= LAYOUT_DIRTY;
-  }
-
-  //----------------------------------------------------------------------------
-  void NasalWidget::setGeometry(const SGRect<int>& geom)
-  {
-    if( _geometry != geom )
-    {
-      _geometry = geom;
-      _flags |= LAYOUT_DIRTY;
-    }
-
-    if( !_set_geometry || !(_flags & LAYOUT_DIRTY) )
-      return;
-
-    try
-    {
-      nasal::Context c;
-      _set_geometry(nasal::to_nasal(c, this), geom);
-      _flags &= ~LAYOUT_DIRTY;
-    }
-    catch( std::exception const& ex )
-    {
-      SG_LOG(
-        SG_GUI,
-        SG_WARN,
-        "NasalWidget::setGeometry: callback error: '" << ex.what() << "'"
-      );
-    }
-  }
-
   //----------------------------------------------------------------------------
   void NasalWidget::onRemove()
   {
@@ -186,22 +151,6 @@ namespace canvas
     return !_height_for_width.empty() || !_min_height_for_width.empty();
   }
 
-  //----------------------------------------------------------------------------
-  int NasalWidget::heightForWidth(int w) const
-  {
-    return callHeightForWidthFunc( _height_for_width.empty()
-                                 ? _min_height_for_width
-                                 : _height_for_width, w );
-  }
-
-  //----------------------------------------------------------------------------
-  int NasalWidget::minimumHeightForWidth(int w) const
-  {
-    return callHeightForWidthFunc( _min_height_for_width.empty()
-                                 ? _height_for_width
-                                 : _min_height_for_width, w );
-  }
-
   //----------------------------------------------------------------------------
   static naRef f_makeNasalWidget(const nasal::CallContext& ctx)
   {
@@ -285,5 +234,62 @@ namespace canvas
     );
   }
 
+
+  //----------------------------------------------------------------------------
+  int NasalWidget::heightForWidthImpl(int w) const
+  {
+    return callHeightForWidthFunc( _height_for_width.empty()
+                                 ? _min_height_for_width
+                                 : _height_for_width, w );
+  }
+
+  //----------------------------------------------------------------------------
+  int NasalWidget::minimumHeightForWidthImpl(int w) const
+  {
+    return callHeightForWidthFunc( _min_height_for_width.empty()
+                                 ? _height_for_width
+                                 : _min_height_for_width, w );
+  }
+
+
+  //----------------------------------------------------------------------------
+  void NasalWidget::contentsRectChanged(const SGRect<int>& rect)
+  {
+    if( !_set_geometry )
+      return;
+
+    try
+    {
+      nasal::Context c;
+      _set_geometry(nasal::to_nasal(c, this), rect);
+      _flags &= ~LAYOUT_DIRTY;
+    }
+    catch( std::exception const& ex )
+    {
+      SG_LOG(
+        SG_GUI,
+        SG_WARN,
+        "NasalWidget::setGeometry: callback error: '" << ex.what() << "'"
+      );
+    }
+  }
+
+  //----------------------------------------------------------------------------
+  void NasalWidget::visibilityChanged(bool visible)
+  {
+    try
+    {
+      callMethod<void>("visibilityChanged", visible);
+    }
+    catch( std::exception const& ex )
+    {
+      SG_LOG(
+        SG_GUI,
+        SG_WARN,
+        "NasalWidget::visibilityChanged: callback error: '" << ex.what() << "'"
+      );
+    }
+  }
+
 } // namespace canvas
 } // namespace simgear