Commit aebbe14
Valid region in redraw
Changed files (5)
modifiedlibbirdfont/ColorPicker.valamodifiedlibbirdfont/Expander.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/Layer.valamodifiedlibbirdfont/Toolbox.vala
Diff
@@ -101,7 +101,7 @@ public class ColorPicker : Tool { double step = 1.0 / Toolbox.allocation_width; Color c; double y = this.y - py;- + for (double p = 0; p < 1; p += step) { c = new Color.hsba (p, 1, 0.5, 1); cr.save ();@@ -144,13 +144,14 @@ public class ColorPicker : Tool { double y = this.y - py; double scale = Toolbox.get_scale (); double p;- p = bar_index * bar_height;+ + return_if_fail (y + p + bar_height - 2 * scale > 0); cr.save (); cr.set_line_width (1 * scale); cr.set_source_rgba (1, 1, 1, 1);- cr.move_to (val * Toolbox.allocation_width - 3 * scale, y + p + bar_height);+ cr.move_to (val * Toolbox.allocation_width * scale - 3 * scale, y + p + bar_height); cr.line_to (val * Toolbox.allocation_width, y + p + bar_height - 2 * scale); cr.line_to (val * Toolbox.allocation_width + 3 * scale, y + p + bar_height); cr.stroke_preserve ();@@ -161,7 +162,7 @@ public class ColorPicker : Tool { cr.save (); cr.set_line_width (1 * scale); cr.set_source_rgba (1, 1, 1, 1);- cr.move_to (val * Toolbox.allocation_width - 3 * scale, y + p);+ cr.move_to (val * Toolbox.allocation_width * scale - 3 * scale, y + p); cr.line_to (val * Toolbox.allocation_width, y + p + 2 * scale); cr.line_to (val * Toolbox.allocation_width + 3 * scale, y + p); cr.stroke_preserve ();@@ -196,6 +196,10 @@ public class Expander : GLib.Object { content_height += 5 * scale; }+ + if (unlikely (content_height < 0)) {+ warning (@"content_height < 0"); + } } public void set_scroll (double scroll) {@@ -279,7 +283,7 @@ public class Expander : GLib.Object { double text_height = 17 * Toolbox.get_scale (); double offset_y = 0;- + cache = new Surface.similar (cr.get_target (), Cairo.Content.COLOR_ALPHA, Toolbox.allocation_width, (int) (h + content_height)); cc = new Context (cache); @@ -298,6 +302,7 @@ public class Expander : GLib.Object { cache = (!) cached; cr.save (); cr.set_antialias (Cairo.Antialias.NONE);+ cr.set_source_surface (cache, 0, (int) (y + scroll)); cr.paint (); cr.restore ();@@ -308,7 +313,7 @@ public class Expander : GLib.Object { double offset_y = 0; double offset_x = 0; - update_tool_position (); //FIXME+ update_tool_position (); if (tool.size > 0) { offset_x = tool.get (0).x;@@ -156,7 +156,7 @@ public class Glyph : FontDisplay { } public Gee.ArrayList<Path> get_paths_in_current_layer () {- return get_current_layer ().paths.paths;+ return get_current_layer ().get_all_paths ().paths; } public Gee.ArrayList<Path> get_all_paths () {@@ -87,11 +87,24 @@ public class Layer : GLib.Object { } public void print (int indent = 0) {+ foreach (Path p in paths.paths) {+ for (int i = 0; i < indent; i++) {+ stdout.printf ("\t");+ }+ stdout.printf ("Path");+ + if (p.color != null) {+ stdout.printf (" %s", ((!) p.color).to_rgb_hex ());+ }+ + stdout.printf ("\n");+ }+ foreach (Layer l in subgroups) { for (int i = 0; i < indent; i++) { stdout.printf ("\t"); }- stdout.printf ("%s\n", l.name); + stdout.printf ("%s\n", l.name); l.print (indent + 1); } }@@ -372,7 +372,7 @@ public class Toolbox : GLib.Object { public void select_tool (Tool tool) { bool update;- + int offset_y; foreach (Expander exp in current_set.get_expanders ()) { if (exp.visible) { foreach (Tool t in exp.tool) {@@ -389,8 +389,9 @@ public class Toolbox : GLib.Object { tool.select_action (tool); - if (update) { - redraw ((int) exp.x - 10, (int) exp.y - 10, allocation_width, (int) (allocation_height - exp.y + 10));+ if (update) {+ offset_y = (int) (exp.y - scroll_y);+ redraw ((int) exp.x - 10, (int) offset_y - 10, allocation_width, (int) (allocation_height - offset_y + 10)); } set_current_tool (tool);