Commit fadd6b3
Tool tip for beziér tool modifiers
Changed files (4)
modifiedlibbirdfont/BezierTool.valamodifiedlibbirdfont/HiddenTools.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/Toolbox.vala
Diff
@@ -47,7 +47,7 @@ public class BezierTool : Tool { bool swap = false; public BezierTool (string name) {- base (name, t_ ("Create Beziér curves"));+ base (name, ""); select_action.connect ((self) => { state = NONE;@@ -87,6 +87,24 @@ public class BezierTool : Tool { }); } + public override string get_tip () {+ string tip = t_ ("Create Beziér curves") + "\n";+ + tip += HiddenTools.bezier_line.get_key_binding ();+ tip += " - ";+ tip += t_ ("line") + "\n";++ tip += HiddenTools.bezier_corner.get_key_binding ();+ tip += " - ";+ tip += t_ ("corner") + "\n";++ tip += HiddenTools.move_along_axis.get_key_binding ();+ tip += " - ";+ tip += t_ ("on axis") + "\n";+ + return tip;+ }+ public void press (int b, int x, int y) { Glyph g = MainWindow.get_current_glyph (); double px, py;@@ -22,6 +22,10 @@ public class HiddenTools : ToolCollection { public Gee.ArrayList<Expander> expanders; public Expander hidden_expander; + public static Tool bezier_line;+ public static Tool bezier_corner;+ public static Tool move_along_axis;+ public HiddenTools () { hidden_expander = new Expander (); expanders = new Gee.ArrayList<Expander> ();@@ -40,7 +44,7 @@ public class HiddenTools : ToolCollection { }); hidden_expander.add_tool (zoom_out); - Tool bezier_line = new Tool ("bezier_line", t_("Convert the last segment to a straight line"));+ bezier_line = new Tool ("bezier_line", t_("Convert the last segment to a straight line")); bezier_line.select_action.connect ((self) => { DrawingTools.bezier_tool.switch_to_line_mode (); });@@ -48,7 +52,7 @@ public class HiddenTools : ToolCollection { hidden_expander.add_tool (bezier_line); bezier_line.set_tool_visibility (false); - Tool bezier_corner = new Tool ("bezier_corner", t_("Convert the last control point to a corner node"));+ bezier_corner = new Tool ("bezier_corner", t_("Convert the last control point to a corner node")); bezier_corner.select_action.connect ((self) => { DrawingTools.bezier_tool.create_corner (); });@@ -56,7 +60,7 @@ public class HiddenTools : ToolCollection { hidden_expander.add_tool (bezier_corner); bezier_corner.set_tool_visibility (false); - Tool move_along_axis = new Tool ("bezier", t_("Move handle along axis"));+ move_along_axis = new Tool ("bezier", t_("Move handle along axis")); move_along_axis.select_action.connect ((self) => { Tool t = MainWindow.get_toolbox ().get_current_tool (); if (t is BezierTool) {@@ -128,6 +128,10 @@ public class Tool : Widget { }); } + public virtual string get_tip () {+ return tip;+ }+ public override void draw (Context cr) { draw_tool (cr, 0, 0); }@@ -170,7 +174,7 @@ public class Tool : Widget { waiting_for_tooltip = true; timer_show = new TimeoutSource (timeout_interval); timer_show.set_callback (() => {- if (tip != "" && active_tooltip.is_active () && !active_tooltip.showing_this_tooltip) {+ if (get_tip () != "" && active_tooltip.is_active () && !active_tooltip.showing_this_tooltip) { show_tooltip (); } waiting_for_tooltip = false;@@ -205,7 +209,7 @@ public class Tool : Widget { active_tooltip.showing_this_tooltip = true; - tip = @"$(active_tooltip.tip)";+ tip = @"$(active_tooltip.get_tip ())"; key_binding = active_tooltip.get_key_binding (); if (key_binding != "") {@@ -263,10 +267,6 @@ public class Tool : Widget { public bool is_selected () { return selected; }- - public string get_tip () {- return tip;- } public new bool is_over (double xp, double yp) { bool r = (x <= xp <= x + w && y <= yp <= y + h);@@ -505,6 +505,10 @@ public class Toolbox : GLib.Object { t.widget_x = 10 * get_scale (); t.widget_y = tool_tip_y - t.height - 5 * get_scale (); + if (t.widget_y < 5) {+ t.widget_y = 5;+ }+ t.draw (cr); } }