.
1 /*
2 Copyright (C) 2013 Johan Mattsson
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the
7 License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 */
14
15 using Math;
16 using Cairo;
17
18 namespace BirdFont {
19
20 /** One selected point and its path. */
21 public class PointSelection : GLib.Object {
22
23 public EditPointHandle handle;
24 public EditPoint point;
25 public Path path;
26
27 public PointSelection (EditPoint ep, Path p) {
28 path = p;
29 point = ep;
30 handle = new EditPointHandle.empty ();
31 }
32
33 public PointSelection.handle_selection (EditPointHandle h, Path p) {
34 path = p;
35 point = new EditPoint ();
36 handle = h;
37 }
38
39 public PointSelection.empty () {
40 path = new Path ();
41 point = new EditPoint ();
42 handle = new EditPointHandle.empty ();
43 }
44
45 /** @return true if this point is the first point in the path. */
46 public bool is_first () {
47 return_val_if_fail (path.points.size > 0, false);
48 return path.points.get (0) == point;
49 }
50
51 /** @return true if this point is the last point in the path. */
52 public bool is_last () {
53 return_val_if_fail (path.points.size > 0, false);
54 return path.points.get (path.points.size - 1) == point;
55 }
56
57 public bool is_endpoint () {
58 return is_first () || is_last ();
59 }
60 }
61
62 }
63