Commit 84cb9e1
Set SVG padding in CSS and fix rounded rectangles
Changed files (3)
modifiedlibsvgbird/Doubles.valamodifiedlibsvgbird/Rectangle.valamodifiedlibsvgbird/SvgStyle.vala
Diff
@@ -94,7 +94,7 @@ public class Doubles : GLib.Object { string v = p.to_string (); char[] c = new char [501]; - v = p.format (c, "%3.15f");+ v = p.format (c, "%3.5f"); if (v.index_of ("e") != -1) { return "0.0";@@ -44,12 +44,15 @@ public class Rectangle : Object { } public void draw_rounded_corners (Context cr) {+ cr.save (); cr.new_path ();+ cr.translate (-rx, -ry); elliptical_arc (cr, x + width - rx, y + ry, -PI / 2, 0); elliptical_arc (cr, x + width - rx, y + height - ry, 0, PI / 2); elliptical_arc (cr, x + rx, y + height - ry, PI / 2, PI); elliptical_arc (cr, x + rx, y + ry, PI, PI + PI / 2); cr.close_path ();+ cr.restore (); } public void elliptical_arc (Context cr, double x, double y, double angle_start, double angle_stop) {@@ -26,10 +26,45 @@ public class SvgStyle : GLib.Object { public Gradient? fill_gradient = null; public LineCap line_cap = LineCap.BUTT; - public double padding_top = 0;- public double padding_right = 0;- public double padding_bottom = 0;- public double padding_left = 0;+ public double padding_top {+ get {+ return SvgFile.parse_number (get_css_property ("padding-top"));+ }+ + set {+ set_style ("padding-top", Doubles.round (value) + "px");+ }+ }+ + public double padding_right {+ get {+ return SvgFile.parse_number (get_css_property ("padding-right"));+ }+ + set {+ set_style ("padding-right", Doubles.round (value) + "px");+ }+ }+ + public double padding_bottom {+ get {+ return SvgFile.parse_number (get_css_property ("padding-bottom"));+ }+ + set {+ set_style ("padding-bottom", Doubles.round (value) + "px");+ }+ }+ + public double padding_left {+ get {+ return SvgFile.parse_number (get_css_property ("padding-left"));+ }+ + set {+ set_style ("padding-left", Doubles.round (value) + "px");+ }+ } public double stroke_width = 0; @@ -243,7 +278,7 @@ public class SvgStyle : GLib.Object { return s; } - static void set_style_properties (Defs? d, SvgStyle s) {+ public static void set_style_properties (Defs? d, SvgStyle s) { double fill_opacity = 1; double stroke_opacity = 1; @@ -277,11 +312,6 @@ public class SvgStyle : GLib.Object { Color color = (!) s.stroke; color.a = stroke_opacity; }- - s.padding_bottom = SvgFile.parse_number (s.get_css_property ("padding-bottom"));- s.padding_top = SvgFile.parse_number (s.get_css_property ("padding-top"));- s.padding_left = SvgFile.parse_number (s.get_css_property ("padding-left"));- s.padding_right = SvgFile.parse_number (s.get_css_property ("padding-right")); } void parse_key_value_pairs (string svg_style) {