Commit 400013d
Draw color in color toolbox
Changed files (7)
modifiedlibbirdfont/Color.valamodifiedlibbirdfont/ColorTool.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/OverView.valamodifiedlibbirdfont/OverViewItem.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/PenTool.vala
Diff
@@ -66,6 +66,14 @@ public class Color { public static Color magenta () { return new Color (103.0 / 255, 33.0 / 255, 120.0 / 255, 1); }+ + public string to_string () {+ return @"r: $r, g: $g, b: $b, a: $a";+ }+ + public Color copy () {+ return new Color (r, g, b, a);+ } } }@@ -33,7 +33,7 @@ public class ColorTool : Tool { }); color_updated.connect (() => {- MainWindow.get_toolbox ().redraw ((int)x, (int)y, (int)x + 20, (int)y + 20);+ redraw (); GlyphCanvas.redraw (); }); }@@ -43,15 +43,18 @@ public class ColorTool : Tool { } public void signal_color_updated () {+ print (get_color ().to_string ()); color_updated (); } - public override void draw (Context cr) {+ public override void draw_tool (Context cr, double px, double py) { double scale = Toolbox.get_scale ();+ double x = this.x - px;+ double y = this.y - py; double xt = x + w / 2 - 8 * scale; double yt = y + h / 2 - 8 * scale;- - base.draw (cr);+ + base.draw_tool (cr, px, py); cr.save (); cr.set_source_rgba (color_r, color_g, color_b, 1);@@ -55,7 +55,7 @@ public class Glyph : FontDisplay { double zoom_y1 = 0; double zoom_x2 = 0; double zoom_y2 = 0;- bool zoom_area_is_visible = false;+ public bool zoom_area_is_visible = false; bool view_is_moving = false; public double move_offset_x = 0;@@ -73,7 +73,7 @@ public class Glyph : FontDisplay { // x-height, lsb, etc. public Gee.ArrayList<Line> vertical_help_lines = new Gee.ArrayList<Line> (); public Gee.ArrayList<Line> horizontal_help_lines = new Gee.ArrayList<Line> ();- bool show_help_lines = true;+ public bool show_help_lines = true; bool xheight_lines_visible = false; bool margin_boundaries_visible = false; string new_guide_name = "";@@ -1520,7 +1520,7 @@ public class Glyph : FontDisplay { return background_image_visible; } - private void draw_coordinate (Context cr) {+ public void draw_coordinate (Context cr) { Theme.color (cr, "Table Border"); cr.set_font_size (12); cr.move_to (0, 10);@@ -1536,7 +1536,6 @@ public class Glyph : FontDisplay { cr.save (); cr.new_path (); foreach (Path p in get_visible_paths ()) {- if (c != null) { color = (!) c; } else if (p.color != null) {@@ -1601,7 +1600,8 @@ public class Glyph : FontDisplay { cr.new_path (); foreach (Path p in get_visible_paths ()) { if (p.stroke == 0) {- p.draw_path (cr, this, get_path_fill_color ());+ color = p.color == null ? get_path_fill_color () : (!) p.color;+ p.draw_path (cr, this, color); } } cr.fill ();@@ -1626,7 +1626,8 @@ public class Glyph : FontDisplay { cr.new_path (); foreach (Path p in get_visible_paths ()) { if (p.stroke == 0) {- p.draw_path (cr, this, Color.black ());+ color = p.color == null ? Color.black () : (!) p.color;+ p.draw_path (cr, this, color); } } cr.close_path ();@@ -1669,7 +1670,7 @@ public class Glyph : FontDisplay { } } - private void draw_zoom_area(Context cr) {+ public void draw_zoom_area(Context cr) { cr.save (); cr.set_line_width (2.0); Theme.color (cr, "Selection Border");@@ -1678,7 +1679,7 @@ public class Glyph : FontDisplay { cr.restore (); } - private void draw_background_color (Context cr, double opacity) {+ public void draw_background_color (Context cr, double opacity) { if (opacity > 0) { cr.save (); cr.rectangle (0, 0, allocation.width, allocation.height);@@ -1688,7 +1689,7 @@ public class Glyph : FontDisplay { } } - private void draw_help_lines (Context cr) {+ public void draw_help_lines (Context cr) { foreach (Line line in get_all_help_lines ()) { cr.save (); line.draw (cr, allocation);@@ -139,7 +139,7 @@ public class OverView : FontDisplay { OverviewTools.update_overview_characterset (); return glyph_collection; }- + public GlyphCollection add_empty_character_to_font (unichar character, bool unassigned, string name) { return add_character_to_font (character, true, unassigned); }@@ -210,7 +210,7 @@ public class OverView : FontDisplay { return null; } - private void set_initial_zoom () {+ public void set_initial_zoom () { Toolbox tools = MainWindow.get_toolbox (); ZoomTool z = (ZoomTool) tools.get_tool ("zoom_tool"); z.store_current_view ();@@ -226,7 +226,7 @@ public class OverViewItem : GLib.Object { g.add_help_lines (); c.translate (gx - g.get_lsb () - Glyph.xc (), g.get_baseline () + gy - Glyph.yc ());- + g.draw_paths (c, color); c.restore (); } else {@@ -281,7 +281,10 @@ public class Path { // fill path cr.close_path (); - if (color != null) {+ if (this.color != null) {+ c = (!) this.color;+ cr.set_source_rgba (c.r, c.g, c.b, c.a);+ } else if (color != null) { c = (!) color; cr.set_source_rgba (c.r, c.g, c.b, c.a); } else {@@ -107,7 +107,7 @@ public class PenTool : Tool { // retain path direction clockwise = new Gee.ArrayList<Path> (); counter_clockwise = new Gee.ArrayList<Path> ();-+ begin_action_x = x; begin_action_y = y;