Commit a379158
Select top path first
Changed files (3)
modifiedlibbirdfont/Glyph.valaaddedlibsvgbird/EmptyObject.valamodifiedlibsvgbird/ObjectGroup.vala
Diff
@@ -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; }new file mode 100644@@ -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";+ }+}++}@@ -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); }