The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Select top path first

These changes was commited to the Birdfont repository Mon, 18 Jan 2016 06:53:03 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 18 Jan 2016 06:53:03 +0000 (07:53 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 18 Jan 2016 06:54:16 +0000 (07:54 +0100)
commit a3791589a709124bdc60e6ed7effa96c32a5266f
tree 6859e732677b953a83e28ebfdf92c0adf3b6211d
parent 9e59597625f51ee3ec42b2b2f7f5804506531faa
Select top path first

libbirdfont/Glyph.vala
libsvgbird/EmptyObject.vala [new ]
libsvgbird/ObjectGroup.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1209,7 +1209,10 @@ } 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 libsvgbird/EmptyObject.vala(new)
--- /dev/null +++ b/libsvgbird/EmptyObject.vala @@ -1,1 +1,57 @@ + /* + 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"; + } + } + + }
--- a/libsvgbird/ObjectGroup.vala +++ b/libsvgbird/ObjectGroup.vala @@ -25,6 +25,15 @@ public ObjectGroup () { 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) {