Clone in a terminal:
Commit a379158
Johan Mattsson - 2016-01-18T06:54:16+00:00
a3791589a709124bdc60e6ed7effa96c32a5266fjohan.mattsson.m@gmail.com

Select top path first

Changed files (3)

Diff

diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 76fe075..c801013 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1209,7 +1209,10 @@ public class Glyph : FontDisplay { 	}  	public SvgBird.Object? get_object_at (double x, double y) {-		foreach (SvgBird.Object o in get_current_layer ().objects) {+		Layer layer = get_current_layer ();+		for (int i = layer.objects.size - 1; i >= 0; i--) {+			SvgBird.Object o = layer.objects.get_object (i);+			 			if (o.is_over (x, y)) { 				return o; 			}diff --git a/libsvgbird/EmptyObject.vala b/libsvgbird/EmptyObject.valanew file mode 100644index 0000000..fb1bc4d--- /dev/null+++ b/libsvgbird/EmptyObject.vala@@ -0,0 +1,56 @@+/*+	Copyright (C) 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 +	published by the Free Software Foundation; either version 3 of the +	License, or (at your option) any later version.++	This library is distributed in the hope that it will be useful, but +	WITHOUT ANY WARRANTY; without even the implied warranty of +	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +	Lesser General Public License for more details.+*/++using Cairo;++namespace SvgBird {++public class EmptyObject : Object {++	public EmptyObject () {+	}+	+	public override bool is_over (double x, double y) {+		return false;+	}+			+	public override void draw_outline (Context cr) {+	}++	public override void move (double dx, double dy) {+	}+	+	public override void update_region_boundaries () {+	}++	public override void rotate (double theta, double xc, double yc) {+	}+	+	public override bool is_empty () {+		return false;+	}+	+	public override void resize (double ratio_x, double ratio_y) {+	}+	+	public override Object copy () {+		return new EmptyObject ();+	}++	public override string to_string () {+		return "Empty";+	}+}++}diff --git a/libsvgbird/ObjectGroup.vala b/libsvgbird/ObjectGroup.valaindex b44c336..259d04c 100644--- a/libsvgbird/ObjectGroup.vala+++ b/libsvgbird/ObjectGroup.vala@@ -27,6 +27,15 @@ public class ObjectGroup : GLib.Object { 		 objects = new Gee.ArrayList<Object> (); 	} +	public Object get_object (int index) {+		if (unlikely (index < 0 || index >= size)) {+			warning ("Index out of bounds.");+			return new EmptyObject ();+		}+		+		return objects.get (index);+	}+ 	public int index_of (Object o) { 		return objects.index_of (o); 	}

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112