]> git.mxchange.org Git - flightgear.git/commitdiff
Canvas: UTF-8 support and more settings exposed.
authorThomas Geymayer <tomgey@gmail.com>
Mon, 16 Jul 2012 23:02:03 +0000 (01:02 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Tue, 31 Jul 2012 21:19:23 +0000 (23:19 +0200)
 - Allow hiding objects
 - Use UTF-8 encoding for text elements
 - Add paramter max-width to text elements
 - Support stroke-linecap for path elements
 - Fix mouse coords
 - Set better mipmap filter

src/Canvas/elements/element.cxx
src/Canvas/elements/path.cxx
src/Canvas/elements/text.cxx
src/GUI/CanvasWidget.cxx
src/Instrumentation/od_gauge.cxx

index 15934556f5d84f3b2dc792e85f600d8e5f136477..b01b36966c473d89d35375358cb23973b87609b7 100644 (file)
@@ -40,6 +40,10 @@ namespace canvas
   //----------------------------------------------------------------------------
   void Element::update(double dt)
   {
+    if( !_transform->getNodeMask() )
+      // Don't do anything if element is hidden
+      return;
+
     if( _transform_dirty )
     {
       osg::Matrix m;
@@ -201,6 +205,9 @@ namespace canvas
     {
       if( child->getNameString() == "update" )
         update(0);
+      else if( child->getNameString() == "visible" )
+        // TODO check if we need another nodemask
+        _transform->setNodeMask( child->getBoolValue() ? 0xffffffff : 0 );
       else
         childChanged(child);
     }
index a002f509b6859d40f0158626ed1c16a50c6424d6..63b34f17000907e3028835131c4d9fbe3b83fcd0 100644 (file)
@@ -41,6 +41,7 @@ namespace canvas
         _paint_fill(VG_INVALID_HANDLE),
         _attributes_dirty(~0),
         _stroke_width(1),
+        _stroke_linecap(VG_CAP_BUTT),
         _fill(false)
       {
         setSupportsDisplayList(false);
@@ -114,6 +115,21 @@ namespace canvas
         _attributes_dirty |= FILL_COLOR;
       }
 
+      /**
+       * Set stroke-linecap
+       *
+       * @see http://www.w3.org/TR/SVG/painting.html#StrokeLinecapProperty
+       */
+      void setStrokeLinecap(const std::string& linecap)
+      {
+        if( linecap == "round" )
+          _stroke_linecap = VG_CAP_ROUND;
+        else if( linecap == "square" )
+          _stroke_linecap = VG_CAP_SQUARE;
+        else
+          _stroke_linecap = VG_CAP_BUTT;
+      }
+
       /**
        * Draw callback
        */
@@ -175,6 +191,7 @@ namespace canvas
           vgSetPaint(_paint, VG_STROKE_PATH);
 
           vgSetf(VG_STROKE_LINE_WIDTH, _stroke_width);
+          vgSeti(VG_STROKE_CAP_STYLE, _stroke_linecap);
           vgSetfv( VG_STROKE_DASH_PATTERN,
                    _stroke_dash.size(),
                    _stroke_dash.empty() ? 0 : &_stroke_dash[0] );
@@ -244,6 +261,7 @@ namespace canvas
       VGfloat               _stroke_color[4];
       VGfloat               _stroke_width;
       std::vector<VGfloat>  _stroke_dash;
+      VGCapStyle            _stroke_linecap;
 
       bool      _fill;
       VGfloat   _fill_color[4];
@@ -371,6 +389,8 @@ namespace canvas
     else if(    child->getNameString() == "stroke-width"
              || child->getNameString() == "stroke-dasharray" )
       _attributes_dirty |= STROKE;
+    else if( child->getNameString() == "stroke-linecap" )
+      _path->setStrokeLinecap( child->getStringValue() );
     else if( child->getNameString() == "fill" )
       _path->enableFill( child->getBoolValue() );
   }
index dd23e921fc7ce9c7962be660430c44e6662e568b..291765d3c8d3217d797ac13388facc648175c019 100644 (file)
@@ -149,7 +149,13 @@ namespace canvas
     if( _font_size == child || _font_aspect == child )
       _attributes_dirty |= FONT_SIZE;
     else if( child->getNameString() == "text" )
-      _text->setText( child->getStringValue() );
+      _text->setText
+      (
+        osgText::String( child->getStringValue(),
+                         osgText::String::ENCODING_UTF8 )
+      );
+    else if( child->getNameString() == "max-width" )
+      _text->setMaximumWidth( child->getFloatValue() );
     else if( child->getNameString() == "font" )
       setFont( child->getStringValue() );
   }
index f1647d49645c2ac6efcec5cddf266bcadd6d2845..003660de5d844d2ac31b1ff6f90cd46d60b59f04 100644 (file)
@@ -95,7 +95,7 @@ void CanvasWidget::doHit(int button, int updown, int x, int y)
     return;
 
   _mouse_x->setIntValue(x - abox.min[0]);
-  _mouse_y->setIntValue(y - abox.min[1]);
+  _mouse_y->setIntValue(abox.max[1] - y);
 
   if( updown == PU_DRAG )
     _mouse_drag->setIntValue(button);
index 6daab2ba88407eaa2db4d21929793b1f84dfa5b4..6314e734a754c7b3d602ef7a7d392369fb41c241 100644 (file)
@@ -255,7 +255,7 @@ void FGODGauge::updateSampling()
 
   texture->setFilter(
     osg::Texture2D::MIN_FILTER,
-    _use_mipmapping ? osg::Texture2D::LINEAR_MIPMAP_NEAREST
+    _use_mipmapping ? osg::Texture2D::LINEAR_MIPMAP_LINEAR
                     : osg::Texture2D::LINEAR
   );
   camera->attach(