Browse Source

Add the checking of the width and height attribute for svg elements. (#283)

This enables svg elements to be resized at will with the width and height attributes.
EhWhoAmI 3 years ago
parent
commit
34a77f7034
1 changed files with 14 additions and 0 deletions
  1. 14 0
      Source/SVG/ElementSVG.cpp

+ 14 - 0
Source/SVG/ElementSVG.cpp

@@ -54,6 +54,14 @@ bool ElementSVG::GetIntrinsicDimensions(Vector2f& dimensions, float& ratio)
 		LoadSource();
 
 	dimensions = intrinsic_dimensions;
+
+	if (HasAttribute("width")) {
+		dimensions.x = GetAttribute< float >("width", -1);
+	}
+	if (HasAttribute("height")) {
+		dimensions.y = GetAttribute< float >("height", -1);
+	}
+
 	if (dimensions.y > 0)
 		ratio = dimensions.x / dimensions.y;
 
@@ -87,6 +95,12 @@ void ElementSVG::OnAttributeChange(const ElementAttributes& changed_attributes)
 		source_dirty = true;
 		DirtyLayout();
 	}
+
+	if (changed_attributes.find("width") != changed_attributes.end() ||
+		changed_attributes.find("height") != changed_attributes.end())
+	{
+		DirtyLayout();
+	}
 }
 
 void ElementSVG::OnPropertyChange(const PropertyIdSet& changed_properties)