Commit 0cdd561
Move groups
Changed files (5)
modifiedlibsvgbird/Layer.valamodifiedlibsvgbird/Object.valamodifiedlibsvgbird/SvgDrawing.valamodifiedlibsvgbird/SvgFile.valamodifiedlibsvgbird/ViewBox.vala
Diff
@@ -1,5 +1,5 @@ /*- Copyright (C) 2015 Johan Mattsson+ Copyright (C) 2015 2016 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -32,6 +32,20 @@ public class Layer : Object { transforms = new SvgTransforms (); } + public override void move (double dx, double dy) {+ left += dx;+ right += dx;+ top += dy;+ bottom += dy;++ foreach (Object object in objects.objects) {+ object.move (dx, dy);+ }+ + update_view_matrix ();+ }++ public override bool update_boundaries (Context cr) { if (objects.size == 0) { return false;@@ -294,7 +294,6 @@ public abstract class Object : GLib.Object { parent_matrix = copy_matrix (context.get_matrix ()); apply_transform (context);- view_matrix = copy_matrix (context.get_matrix ()); if (style.fill_gradient != null) { apply_gradient (context, (!) style.fill_gradient);@@ -311,6 +310,8 @@ public abstract class Object : GLib.Object { } draw_outline (context);+ + view_matrix = copy_matrix (context.get_matrix ()); context.set_matrix (Matrix.identity ()); if (has_stroke) {@@ -28,9 +28,10 @@ public class SvgDrawing : Object { public double height = 0; public override bool update_boundaries (Context cr) {- parent_matrix = cr.get_matrix ();- apply_transform (cr);- view_matrix = cr.get_matrix ();+ parent_matrix = copy_matrix (cr.get_matrix ());+ base.apply_transform (cr);+ apply_view_box (cr);+ view_matrix = copy_matrix (cr.get_matrix ()); root_layer.update_boundaries (cr); @@ -39,7 +40,7 @@ public class SvgDrawing : Object { top = root_layer.top; bottom = root_layer.bottom; - return true;+ return root_layer.right - root_layer.left > 0; } public override bool is_over (double x, double y) {@@ -50,20 +51,25 @@ public class SvgDrawing : Object { if (view_box != null) { ViewBox box = (!) view_box; Matrix view_box_matrix = box.get_matrix (width, height);- Matrix view_matrix = cr.get_matrix ();- view_box_matrix.multiply (view_box_matrix, view_matrix); + Matrix object_matrix = cr.get_matrix ();+ view_box_matrix.multiply (view_box_matrix, object_matrix); cr.set_matrix (view_box_matrix); } } public override void apply_transform (Context cr) {+ Matrix view_matrix = cr.get_matrix ();+ Matrix object_matrix = transforms.get_matrix ();+ object_matrix.multiply (object_matrix, view_matrix); + cr.set_matrix (object_matrix);+ apply_view_box (cr);- base.apply_transform (cr); } public void draw (Context cr) { cr.save ();- apply_transform (cr);+ base.apply_transform (cr);+ apply_view_box (cr); root_layer.draw (cr); cr.restore (); }@@ -762,6 +762,8 @@ public class SvgFile : GLib.Object { SvgTransform transform = new SvgTransform (); transform.type = TransformType.SCALE; + print (@"scale $parameters len $(p.length)\n");+ if (p.length > 0) { transform.arguments.add (parse_double (p[0])); }@@ -95,7 +95,11 @@ public class ViewBox : GLib.Object { scale_x = original_width / width; scale_y = original_height / height; - bool scale_width = scale_x > scale_y;+ print (@"minx miny $minx $miny\n");+ print (@"scale_x > scale_y $scale_x > $scale_y\n");+ print (@"original_width $original_width $width $original_height $height\n");+ + bool scale_width = scale_x * original_height > scale_y * original_width; if (scale_width) { scale = scale_y;