The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Object properties

These changes was commited to the Birdfont repository Mon, 28 Dec 2015 18:19:01 +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, 28 Dec 2015 18:19:01 +0000 (19:19 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 28 Dec 2015 19:29:19 +0000 (20:29 +0100)
commit 9f893f4bfd7ffc60447a1d0c9fc029c53cc2536b
tree 75d8b2bb48621ed1d877fd31e303f60b733b8418
parent be51db8795f50914a4324ccea79c1b11d72681e6
Object properties

libbirdfont/FastPath.vala
libbirdfont/Glyph.vala
libbirdfont/Layer.vala
libbirdfont/Object.vala
libbirdfont/ObjectGroup.vala
--- a/libbirdfont/FastPath.vala +++ b/libbirdfont/FastPath.vala @@ -29,7 +29,115 @@ path.stroke = value; } } - + + public override double rotation { + get { + return path.rotation; + } + + set { + path.rotation = value; + } + } + + public override LineCap line_cap { + get { + return path.line_cap; + } + + set { + path.line_cap = value; + } + } + + public override bool fill { + get { + return path.fill; + } + + set { + path.fill = value; + } + } + + public override Color? color { + get { + return path.color; + } + + set { + path.color = value; + } + } + + public override Color? stroke_color { + get { + return path.stroke_color; + } + + set { + path.stroke_color = value; + } + } + + public override Gradient? gradient { + get { + return path.gradient; + } + + set { + path.gradient = value; + } + } + + public override double xmin { + get { + return path.xmin; + } + + set { + path.xmin = value; + } + + default = Glyph.CANVAS_MAX; + } + + public override double xmax { + get { + return path.xmax; + } + + set { + path.xmax = value; + } + + default = Glyph.CANVAS_MIN; + } + + public override double ymin { + get { + return path.ymin; + } + + set { + path.ymin = value; + } + + default = Glyph.CANVAS_MAX; + } + + public override double ymax { + get { + return path.ymax; + } + + set { + path.ymax = value; + } + + default = Glyph.CANVAS_MIN; + } + public FastPath () { path = new Path (); update_region_boundaries (); @@ -54,7 +162,6 @@ bool open; cr.save (); - cr.new_path (); if (c != null) { path_color = (!) c; @@ -82,7 +189,6 @@ } } - cr.fill (); cr.restore (); } @@ -111,8 +217,6 @@ public override void rotate (double theta, double xc, double yc) { path.rotate (theta, xc, yc); - rotation += theta; - rotation %= 2 * Math.PI; } public override bool is_empty () {
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -797,6 +797,10 @@ return; } } + } + + public void delete_object (Object o) { + layers.remove (o); } public void delete_path (Path p) { @@ -1677,9 +1681,16 @@ /** Draw filled paths. */ public void draw_paths (Context cr, Color? c = null) { + + cr.save (); + cr.new_path (); + foreach (Object o in get_visible_objects ()) { o.draw (cr, c); } + + cr.fill (); + cr.restore (); } public void draw_path (Context cr) {
--- a/libbirdfont/Layer.vala +++ b/libbirdfont/Layer.vala @@ -231,8 +231,20 @@ stdout.printf ("%s\n", l.name); l.print (indent + 1); } + } + + public PathList get_paths_in_layer () { + PathList paths = new PathList (); + + foreach (Object object in objects) { + if (object is FastPath) { + paths.add (((FastPath) object).get_path ()); + } + } + + return paths; } } }
--- a/libbirdfont/Object.vala +++ b/libbirdfont/Object.vala @@ -20,51 +20,26 @@ public abstract class Object : GLib.Object { bool open = false; - public Color? color = null; - public Color? stroke_color = null; - public Gradient? gradient = null; + public abstract Color? color { get; set; } + public abstract Color? stroke_color { get; set; } + public abstract Gradient? gradient { get; set; } /** Path boundaries */ - public double xmax = Glyph.CANVAS_MIN; - public double xmin = Glyph.CANVAS_MAX; - public double ymax = Glyph.CANVAS_MIN; - public double ymin = Glyph.CANVAS_MAX; - - public double rotation = 0; - public virtual double stroke { get; set; } - public LineCap line_cap = LineCap.BUTT; + public abstract double xmax { get; set; } + public abstract double xmin { get; set; } + public abstract double ymax { get; set; } + public abstract double ymin { get; set; } + public abstract double rotation { get; set; } + public abstract double stroke { get; set; } + public abstract LineCap line_cap { get; set; default = LineCap.BUTT; } + public abstract bool fill { get; set; } + public Object () { } public Object.create_copy (Object o) { open = o.open; - - if (color != null) { - color = ((!) color).copy (); - } else { - color = null; - } - - if (stroke_color != null) { - stroke_color = ((!) stroke_color).copy (); - } else { - stroke_color = null; - } - - if (gradient != null) { - gradient = ((!) gradient).copy (); - } else { - gradient = null; - } - - xmax = o.xmax; - xmin = o.xmin; - ymax = o.ymax; - ymin = o.ymin; - - rotation = o.rotation; - stroke = o.stroke; } public void set_open (bool open) {
--- a/libbirdfont/ObjectGroup.vala +++ b/libbirdfont/ObjectGroup.vala @@ -16,6 +16,12 @@ public class ObjectGroup : GLib.Object { public Gee.ArrayList<Object> objects; + + public int size { + get { + return objects.size; + } + } public ObjectGroup () { objects = new Gee.ArrayList<Object> ();