Skip to content

Commit

Permalink
Add the checking of the width and height attribute for svg elements. (#…
Browse files Browse the repository at this point in the history
…283)

This enables svg elements to be resized at will with the width and height attributes.
  • Loading branch information
EhWhoAmI authored Feb 7, 2022
1 parent 12eeeaa commit 34a77f7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Source/SVG/ElementSVG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 34a77f7

Please sign in to comment.