Commit fb67f20
Rename tooltip area
Changed files (18)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/ColorTool.valamodifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/KerningDisplay.valamodifiedlibbirdfont/KerningRange.valamodifiedlibbirdfont/MainWindow.valamodifiedlibbirdfont/OpenFontFormat/Cmap.valamodifiedlibbirdfont/OpenFontFormat/GlyfData.valamodifiedlibbirdfont/OpenFontFormat/GlyfTable.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/PreviewTools.valamodifiedlibbirdfont/ProgressBar.valamodifiedlibbirdfont/StrokeTool.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/Toolbox.valamodifiedlibbirdfont/TooltipArea.vala
Diff
@@ -162,13 +162,13 @@ public class GtkWindow : Gtk.Window, NativeWindow { tab_box = new VBox (false, 0); - tab_box.pack_start (new TabbarCanvas (MainWindow.tabs), false, false, 0);+ tab_box.pack_start (new TabbarCanvas (MainWindow.get_tab_bar ()), false, false, 0); tab_box.pack_start (text_box, false, false, 5); tab_box.pack_start (canvas_box, true, true, 0); - tab_box.pack_start (new TooltipCanvas (MainWindow.tool_tip), false, false, 0);+ tab_box.pack_start (new TooltipCanvas (MainWindow.get_tooltip ()), false, false, 0); - toolbox = new ToolboxCanvas (MainWindow.tools); + toolbox = new ToolboxCanvas (MainWindow.get_toolbox ()); list_box = new HBox (false, 0); list_box.pack_start (tab_box, true, true, 0); list_box.pack_start (toolbox, false, false, 0);@@ -1,5 +1,5 @@ /*- Copyright (C) 2013 Johan Mattsson+ Copyright (C) 2013, 2014 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 @@ -169,7 +169,7 @@ class BirdFontFile { } ProgressBar.set_progress (0); - MainWindow.get_tool_tip ().show_text (t_("Saving"));+ TooltipArea.show_text (t_("Saving")); }); font.glyph_cache.for_each ((gc) => {@@ -200,7 +200,7 @@ class BirdFontFile { } ProgressBar.set_progress (0); - MainWindow.get_tool_tip ().show_text (t_("Saving"));+ TooltipArea.show_text (t_("Saving")); }); num_kerning_pairs = KerningClasses.get_instance ().classes_first.length ();@@ -250,7 +250,7 @@ class BirdFontFile { } ProgressBar.set_progress (0);- MainWindow.get_tool_tip ().show_text (t_("Saving"));+ TooltipArea.show_text (t_("Saving")); }); os.put_string ("</font>");@@ -261,6 +261,7 @@ class BirdFontFile { return false; } + TooltipArea.show_text (""); return true; } @@ -560,15 +561,16 @@ class BirdFontFile { parse_kerning (iter); } - ProgressBar.set_progress (++i / 1024.0);+ ProgressBar.set_progress (++i / 20480.0); - if (i == 1024) {+ if (i == 20480) { i = 0; } - MainWindow.get_tool_tip ().show_text (t_("Loading BirdFont XML data."));+ TooltipArea.show_text (t_("Loading XML data.")); } + TooltipArea.show_text (""); return true; } @@ -25,8 +25,8 @@ public class ColorTool : Tool { public signal void color_updated (); - public ColorTool (string tool_tip) {- base (null, tool_tip);+ public ColorTool (string tooltip) {+ base (null, tooltip); select_action.connect((self) => { MainWindow.native_window.color_selection (this);@@ -507,8 +507,8 @@ public class DrawingTools : ToolCollection { bg_selection.select_action.connect((self) => { Glyph? g = null; FontDisplay fd = MainWindow.get_current_display ();- TooltipArea tp = MainWindow.get_tool_tip ();- tp.show_text (t_("Creating thumbnails"));+ TooltipArea tp = MainWindow.get_tooltip ();+ TooltipArea.show_text (t_("Creating thumbnails")); Tool.yield (); @@ -521,7 +521,7 @@ public class DrawingTools : ToolCollection { BackgroundSelection bgs = new BackgroundSelection (); MainWindow.get_tab_bar ().add_unique_tab (bgs); - tp.show_text ("");+ TooltipArea.show_text (""); }); bg_selection.set_show_background (true);@@ -639,13 +639,13 @@ os.put_string ( } private static void status (string s) {- TooltipArea status = MainWindow.get_tool_tip ();+ TooltipArea status = MainWindow.get_tooltip (); if (is_null (status)) { return; } - status.show_text (s);+ TooltipArea.show_text (s); } } @@ -237,7 +237,7 @@ public class KerningDisplay : FontDisplay { private void display_kerning_value (double k) { string kerning_label = t_("Kerning:");- MainWindow.get_tool_tip ().show_text (@"$kerning_label $(k)");+ TooltipArea.show_text (@"$kerning_label $(k)"); } private void set_active_handle_index (int h) {@@ -47,7 +47,7 @@ public class KerningRange : Tool { active = is_over (tx, ty); if (active) {- MainWindow.get_tool_tip ().show_text (t_("Right click to edit the class and left click to kern glyphs in the class."));+ TooltipArea.show_text (t_("Right click to edit the class and left click to kern glyphs in the class.")); } return false;@@ -21,7 +21,7 @@ public class MainWindow { public static MainWindow singleton; public static MenuTab menu_tab; public static FileTab file_tab; - public static TooltipArea tool_tip; + public static TooltipArea tooltip; public static OverView over_view; public static TabBar tabs; public static NativeWindow native_window; @@ -36,7 +36,7 @@ public class MainWindow { tools = new Toolbox (glyph_canvas, tabs); menu_tab = new MenuTab (); file_tab = new FileTab (); - tool_tip = new TooltipArea (); + tooltip = new TooltipArea (); over_view = new OverView(); kerning_display = new KerningDisplay (); character_database = new CharDatabase (); @@ -108,8 +108,8 @@ public class MainWindow { return tabs.get_selected_tab (); } - public static TooltipArea get_tool_tip () { - return tool_tip; + public static TooltipArea get_tooltip () { + return tooltip; } public static bool select_tab (Tab t) { @@ -189,8 +189,8 @@ public class MainWindow { } public static void set_status (string s) { - if (!is_null (tool_tip)) { - tool_tip.show_text (s); + if (!is_null (tooltip)) { + TooltipArea.show_text (s); Tool.yield (); } } @@ -201,9 +201,6 @@ public class CmapSubtableWindowsUnicode : CmapSubtable { if (id_delta != null) delete id_delta; if (id_range_offset != null) delete id_range_offset; if (glyph_id_array != null) delete glyph_id_array;- - // it has a character for every glyph indice- // assert (validate_subtable ()); } public void process (FontData fd, GlyfTable glyf_table) throws GLib.Error {@@ -427,6 +424,7 @@ internal static uint16 largest_pow2 (uint16 max) { return l; } +/** Largest exponent for a power of two less than max. */ internal static uint16 largest_pow2_exponent (uint16 max) { uint16 exp = 0; uint16 l = 0;@@ -16,7 +16,7 @@ using Math; namespace BirdFont { -public class Coordinate {+public class CoordinateFlags { /** TTF coordinate flags. */ public static const uint8 NONE = 0;@@ -160,13 +160,13 @@ class GlyfData : GLib.Object { foreach (Path p in paths) { foreach (EditPoint e in p.points) {- flags.append (Coordinate.ON_PATH);+ flags.append (CoordinateFlags.ON_PATH); nflags++; type = e.get_right_handle ().type; // off curve- flags.append (Coordinate.NONE);+ flags.append (CoordinateFlags.NONE); nflags++; } }@@ -248,7 +248,7 @@ class GlyfData : GLib.Object { c += last; // Only on curve points are good for calculating bounding box- if ((flags.nth (i).data & Coordinate.ON_PATH) > 0) { + if ((flags.nth (i).data & CoordinateFlags.ON_PATH) > 0) { if (c < bounding_box_xmin) bounding_box_xmin = c; if (c > bounding_box_xmax) bounding_box_xmax = c; }@@ -266,7 +266,7 @@ class GlyfData : GLib.Object { foreach (int16 c in coordinate_y) { c += last; - if ((flags.nth (i).data & Coordinate.ON_PATH) > 0) {+ if ((flags.nth (i).data & CoordinateFlags.ON_PATH) > 0) { if (c < bounding_box_ymin) { bounding_box_ymin = c; }@@ -75,7 +75,7 @@ public class GlyfTable : Table { } public int16 get_average_width () {- return (int16) (total_width / non_zero_glyphs);+ return (int16) Math.rint (total_width / non_zero_glyphs); } public uint16 get_max_contours () {@@ -573,7 +573,7 @@ public class GlyfTable : Table { for (int i = 0; i < npoints; i++) { flags[i] = dis.read_byte (); - if ((flags[i] & Coordinate.REPEAT) > 0) {+ if ((flags[i] & CoordinateFlags.REPEAT) > 0) { repeat = dis.read_byte (); if (i + repeat >= npoints) {@@ -607,14 +607,14 @@ public class GlyfTable : Table { int16 last = 0; xcoordinates = new int16[npoints + 1]; for (int i = 0; i < npoints; i++) {- if ((flags[i] & Coordinate.X_SHORT_VECTOR) > 0) { - if ((flags[i] & Coordinate.X_SHORT_VECTOR_POSITIVE) > 0) {+ if ((flags[i] & CoordinateFlags.X_SHORT_VECTOR) > 0) { + if ((flags[i] & CoordinateFlags.X_SHORT_VECTOR_POSITIVE) > 0) { xcoordinates[i] = last + dis.read_byte (); } else { xcoordinates[i] = last - dis.read_byte (); } } else {- if ((flags[i] & Coordinate.X_IS_SAME) > 0) {+ if ((flags[i] & CoordinateFlags.X_IS_SAME) > 0) { xcoordinates[i] = last; } else { xcoordinates[i] = last + dis.read_short ();@@ -638,14 +638,14 @@ public class GlyfTable : Table { last = 0; ycoordinates = new int16[npoints + 1]; for (int i = 0; i < npoints; i++) {- if ((flags[i] & Coordinate.Y_SHORT_VECTOR) > 0) { - if ((flags[i] & Coordinate.Y_SHORT_VECTOR_POSITIVE) > 0) {+ if ((flags[i] & CoordinateFlags.Y_SHORT_VECTOR) > 0) { + if ((flags[i] & CoordinateFlags.Y_SHORT_VECTOR_POSITIVE) > 0) { ycoordinates[i] = last + dis.read_byte (); } else { ycoordinates[i] = last - dis.read_byte (); } } else {- if ((flags[i] & Coordinate.Y_IS_SAME) > 0) {+ if ((flags[i] & CoordinateFlags.Y_IS_SAME) > 0) { ycoordinates[i] = last; } else { ycoordinates[i] = last + dis.read_short ();@@ -705,7 +705,7 @@ public class GlyfTable : Table { x = xcoordinates[j] * 1000.0 / units_per_em; // in proportion to em width y = ycoordinates[j] * 1000.0 / units_per_em; - if ((flags[j] & Coordinate.ON_PATH) > 0) {+ if ((flags[j] & CoordinateFlags.ON_PATH) > 0) { // Point edit_point = new EditPoint (); edit_point.set_position (x, y);@@ -806,14 +806,28 @@ public class GlyfTable : Table { } } - if (end_points != null) delete end_points;- if (instructions != null) delete instructions;- if (flags != null) delete flags;- if (xcoordinates != null) delete xcoordinates;- if (ycoordinates != null) delete ycoordinates;+ if (end_points != null) {+ delete end_points;+ }+ + if (instructions != null) {+ delete instructions;+ }+ + if (flags != null) {+ delete flags;+ }+ + if (xcoordinates != null) {+ delete xcoordinates;+ }+ + if (ycoordinates != null) {+ delete ycoordinates;+ } if (error != null) {- warning ("failed to parse glyph");+ warning ("Failed to parse glyph"); throw (!) error; } @@ -1145,7 +1145,7 @@ public class Path { PointType right; double x, y; - for (unowned List<EditPoint> next = points.first (); !is_null (next); next = next.next ) {+ for (unowned List<EditPoint> next = points.first (); !is_null (next); next = next.next) { left = first.data.get_right_handle ().type; right = next.data.get_left_handle ().type; if (right == PointType.DOUBLE_CURVE || left == PointType.DOUBLE_CURVE) {@@ -1206,8 +1206,8 @@ public class Path { next = i.next; } - if (points.last ().data.get_right_handle ().type == PointType.CUBIC - || points.first ().data.get_left_handle ().type == PointType.CUBIC) {+ if (is_open () && (points.last ().data.get_right_handle ().type == PointType.CUBIC + || points.first ().data.get_left_handle ().type == PointType.CUBIC)) { add_quadratic_points (points.last ().data, points.first ().data); } else { quadratic_path.add_point (points.last ().data.copy ());@@ -1220,22 +1220,24 @@ public class Path { quadratic_path.add_hidden_double_points (); - quadratic_path.close (); quadratic_path.create_list (); process_quadratic_handles (); - quadratic_path.close (); quadratic_path.create_list (); process_cubic_handles ();- - quadratic_path.close (); foreach (EditPoint ep in quadratic_path.points) { if (ep.type == PointType.QUADRATIC) { ep.get_left_handle ().move_to_coordinate (ep.get_prev ().data.get_right_handle ().x (), ep.get_prev ().data.get_right_handle ().y ()); } }- ++ if (!is_open ()) {+ quadratic_path.close ();+ } else {+ quadratic_path.reopen ();+ }+ return quadratic_path; } @@ -64,7 +64,7 @@ public class PreviewTools : ToolCollection { suppress_event = true; ExportTool.export_ttf_font_sync (); ExportTool.export_svg_font ();- MainWindow.get_tool_tip ().show_text (t_("Three font files has been created.")); + TooltipArea.show_text (t_("Three font files has been created.")); suppress_event = false; } }@@ -36,7 +36,9 @@ class ProgressBar { current_progress = d; p.new_progress (); - MainWindow.get_tool_tip ().redraw ();+ if (is_null (MainWindow.get_tooltip ())) {+ MainWindow.get_tooltip ().redraw ();+ } } public static double get_progress () {@@ -19,7 +19,7 @@ namespace BirdFont { public class StrokeTool : Tool { - public StrokeTool (string tool_tip) {+ public StrokeTool (string tooltip) { select_action.connect((self) => { stroke_selected_paths (); });@@ -43,6 +43,7 @@ public class StrokeTool : Tool { foreach (Path p in g.active_paths) { paths.append (get_stroke (p, p.stroke)); paths.add (add_tangent_points (p));+ paths.add (p.get_quadratic_points ()); } foreach (Path np in paths.paths) {@@ -58,8 +59,8 @@ public class StrokeTool : Tool { outline = create_stroke (p, thickness); outline.close (); paths.add (outline);+ outline.update_region_boundaries (); } else if (!p.is_open () && !p.is_filled ()) {- outline = create_stroke (p, thickness); counter = create_stroke (p, -1 * thickness); @@ -78,6 +79,8 @@ public class StrokeTool : Tool { counter.force_direction (Direction.CLOCKWISE); } + outline.update_region_boundaries ();+ counter.update_region_boundaries (); } else if (p.is_open ()) { outline = create_stroke (p, thickness); counter = create_stroke (p, -1 * thickness);@@ -89,6 +92,7 @@ public class StrokeTool : Tool { merged.force_direction (Direction.COUNTER_CLOCKWISE); } + merged.update_region_boundaries (); paths.add (merged); } else { warning ("Can not create stroke.");@@ -228,11 +232,10 @@ public class StrokeTool : Tool { ep.set_position (x, y); // Stop processing when the first hidden point is found.- /* if (start.type == PointType.HIDDEN || stop.type == PointType.HIDDEN) {+ if (start.type == PointType.HIDDEN || stop.type == PointType.HIDDEN) { // FIXME: Rename tracker points return true; }- */ return_val_if_fail (prev != null, false); @@ -102,7 +102,7 @@ public class Tool : GLib.Object { next_id++; panel_press_action.connect ((self, button, x, y) => {- MainWindow.get_tool_tip ().set_text_from_tool ();+ MainWindow.get_tooltip ().set_text_from_tool (); }); panel_move_action.connect ((self, x, y) => {@@ -130,7 +130,7 @@ public class Tool : GLib.Object { waiting_for_tooltip = true; timer_show = new TimeoutSource (timeout_interval); timer_show.set_callback (() => {- if (active_tooltip.is_active () && !active_tooltip.showing_this_tooltip) {+ if (tip != "" && active_tooltip.is_active () && !active_tooltip.showing_this_tooltip) { show_tooltip (); } waiting_for_tooltip = false;@@ -200,7 +200,7 @@ public class Tool : GLib.Object { public bool set_selected (bool a) { TooltipArea? tpa = null; - tpa = MainWindow.get_tool_tip ();+ tpa = MainWindow.get_tooltip (); new_selection = true; selected = a;@@ -225,7 +225,7 @@ public class Toolbox : GLib.Object { TooltipArea? tpa = null; update = t.set_active (active);- tpa = MainWindow.get_tool_tip ();+ tpa = MainWindow.get_tooltip (); if (active && tpa != null) { ((!)tpa).update_text ();@@ -19,7 +19,7 @@ namespace BirdFont { public class TooltipArea : GLib.Object { - string tool_tip;+ string tooltip; ProgressBar progress_bar; public signal void redraw ();@@ -43,9 +43,13 @@ public class TooltipArea : GLib.Object { redraw (); } - public void show_text (string text) {- tool_tip = text;- redraw ();+ public static void show_text (string text) {+ if (is_null (MainWindow.get_tooltip ())) {+ return;+ }+ + MainWindow.get_tooltip ().tooltip = text;+ MainWindow.get_tooltip ().redraw (); } public void set_text_from_tool () {@@ -132,7 +136,7 @@ public class TooltipArea : GLib.Object { cr.save (); cr.set_font_size (14); cr.move_to (5, 15);- cr.show_text (tool_tip);+ cr.show_text (tooltip); cr.restore (); } }