Clone in a terminal:
Commit 85839ab
Johan Mattsson - 2015-03-24T20:44:37+00:00
85839abb9a0ce722f03dc37b15f1b9dff562893bjohan.mattsson.m@gmail.com

Tab specific key bindings

Changed files (10)

Diff

diff --git a/libbirdfont/BackgroundTools.vala b/libbirdfont/BackgroundTools.valaindex 4b64567..e064af0 100644--- a/libbirdfont/BackgroundTools.vala+++ b/libbirdfont/BackgroundTools.vala@@ -278,6 +278,12 @@ public class BackgroundTools : ToolCollection  { 		font.add_background_image (image); 	} 	+	public override Gee.ArrayList<string> get_displays () {+		Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+		d.add ("Backgrounds");+		return d;+	}+	 	class BackgroundSelectionLabel : LabelTool { 		public BackgroundImage img; 		public bool deleted;diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 1a1c7ad..cd3b12e 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -1314,6 +1314,12 @@ public class DrawingTools : ToolCollection  { 	private void add_expander (Expander e) { 		expanders.add (e); 	}++	public override Gee.ArrayList<string> get_displays () {+		Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+		d.add ("Glyph");+		return d;+	} }  }diff --git a/libbirdfont/ForesightTool.vala b/libbirdfont/ForesightTool.valaindex 79a6156..cd6e6df 100644--- a/libbirdfont/ForesightTool.vala+++ b/libbirdfont/ForesightTool.vala@@ -200,8 +200,8 @@ public class ForesightTool : Tool { 					 					if (last.point.get_right_handle ().is_line () || last.point.get_left_handle ().is_line ()) { 						last.point.convert_to_curve ();-						last.point.get_right_handle ().length = 0.01;-						last.point.get_left_handle ().length = 0.01;+						last.point.get_right_handle ().length = 0.1;+						last.point.get_left_handle ().length = 0.1; 					} 				} 				@@ -228,8 +228,8 @@ public class ForesightTool : Tool { 					 					last.point.convert_to_curve (); 					last.point.set_reflective_handles (true);-					last.point.get_right_handle ().length = 0.01;-					last.point.get_left_handle ().length = 0.01;+					last.point.get_right_handle ().length = 0.1;+					last.point.get_left_handle ().length = 0.1; 				} 				 				if (previous_point == 0) {@@ -242,8 +242,8 @@ public class ForesightTool : Tool { 				 				if (h.is_line ()) { 					last.point.convert_to_curve ();-					last.point.get_right_handle ().length = 0.01;-					last.point.get_left_handle ().length = 0.01;+					last.point.get_right_handle ().length = 0.1;+					last.point.get_left_handle ().length = 0.1; 				} 				 				p.move_action (p, x, y);diff --git a/libbirdfont/KerningTools.vala b/libbirdfont/KerningTools.valaindex c43d1c0..9667064 100644--- a/libbirdfont/KerningTools.vala+++ b/libbirdfont/KerningTools.vala@@ -253,6 +253,12 @@ public class KerningTools : ToolCollection  { 			kr.update_spacing_class (); 		} 	}++	public override Gee.ArrayList<string> get_displays () {+		Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+		d.add ("Kerning");+		return d;+	} }  }diff --git a/libbirdfont/Menu.vala b/libbirdfont/Menu.valaindex a157179..c1828a2 100644--- a/libbirdfont/Menu.vala+++ b/libbirdfont/Menu.vala@@ -166,21 +166,21 @@ public class Menu : GLib.Object { 		}); 		edit_menu.items.add (paste); -		MenuItem paste_in_place = add_menu_item (t_("Paste In Place"), "paste in place");+		MenuItem paste_in_place = add_menu_item (t_("Paste In Place"), "paste in place", "Glyph"); 		paste_in_place.action.connect (() => { 			ClipTool.paste_in_place (); 			show_menu = false; 		}); 		edit_menu.items.add (paste_in_place); 		-		MenuItem select_all_paths = add_menu_item (t_("Select All Paths"), "select all paths");+		MenuItem select_all_paths = add_menu_item (t_("Select All Paths"), "select all paths", "Glyph"); 		select_all_paths.action.connect (() => { 			MainWindow.select_all_paths (); 			show_menu = false; 		}); 		edit_menu.items.add (select_all_paths); -		MenuItem move_to_baseline = add_menu_item (t_("Move To Baseline"), "move to baseline");+		MenuItem move_to_baseline = add_menu_item (t_("Move To Baseline"), "move to baseline", "Glyph"); 		move_to_baseline.action.connect (() => { 			MenuTab.move_to_baseline (); 			show_menu = false;@@ -194,14 +194,14 @@ public class Menu : GLib.Object { 		}); 		edit_menu.items.add (search); -		MenuItem export_glyph = add_menu_item (t_("Export Glyph as SVG"), "export glyph as svg");+		MenuItem export_glyph = add_menu_item (t_("Export Glyph as SVG"), "export glyph as svg", "Glyph"); 		export_glyph.action.connect (() => { 			ExportTool.export_current_glyph (); 			show_menu = false; 		}); 		edit_menu.items.add (export_glyph); -		MenuItem import_svg = add_menu_item (t_("Import SVG file"), "import svg file");+		MenuItem import_svg = add_menu_item (t_("Import SVG file"), "import svg file", "Glyph"); 		import_svg.action.connect (() => { 			SvgParser.import (); 			show_menu = false;@@ -215,14 +215,14 @@ public class Menu : GLib.Object { 		}); 		edit_menu.items.add (import_background_image); -		MenuItem simplify_path = add_menu_item (t_("Simplify Path"), "simplify path");+		MenuItem simplify_path = add_menu_item (t_("Simplify Path"), "simplify path", "Glyph"); 		simplify_path.action.connect (() => { 			MenuTab.simplify_path (); 			show_menu = false; 		}); 		edit_menu.items.add (simplify_path); -		MenuItem close_path = add_menu_item (t_("Close Path"), "close path");+		MenuItem close_path = add_menu_item (t_("Close Path"), "close path", "Glyph"); 		close_path.action.connect (() => { 			PenTool.close_all_paths (); 			show_menu = false;@@ -236,14 +236,14 @@ public class Menu : GLib.Object { 		}); 		edit_menu.items.add (glyph_sequence); -		MenuItem set_background_glyph = add_menu_item (t_("Set Background Glyph"), "set background glyph");+		MenuItem set_background_glyph = add_menu_item (t_("Set Background Glyph"), "set background glyph", "Glyph"); 		set_background_glyph.action.connect (() => { 			MenuTab.use_current_glyph_as_background (); 			show_menu = false; 		}); 		edit_menu.items.add (set_background_glyph); -		MenuItem remove_background_glyph = add_menu_item (t_("Remove Background Glyph"), "remove background glyph");+		MenuItem remove_background_glyph = add_menu_item (t_("Remove Background Glyph"), "remove background glyph", "Glyph"); 		remove_background_glyph.action.connect (() => { 			MenuTab.reset_glyph_background (); 			show_menu = false;@@ -264,36 +264,32 @@ public class Menu : GLib.Object { 		}); 		edit_menu.items.add (show_guide_guide); 		-		MenuItem select_point_above = add_menu_item (t_("Select Point Above"), "select point above");+		MenuItem select_point_above = add_menu_item (t_("Select Point Above"), "select point above", "Glyph"); 		select_point_above.action.connect (() => { 			PenTool.select_point_up (); 			show_menu = false; 		});-		select_point_above.display = "Glyph"; 		edit_menu.items.add (select_point_above); -		MenuItem select_next_point = add_menu_item (t_("Select Next Point"), "select next point");+		MenuItem select_next_point = add_menu_item (t_("Select Next Point"), "select next point", "Glyph"); 		select_next_point.action.connect (() => { 			PenTool.select_point_right (); 			show_menu = false; 		});-		select_next_point.display = "Glyph"; 		edit_menu.items.add (select_next_point); 		-		MenuItem select_previous_point = add_menu_item (t_("Select Previous Point"), "select previous point");+		MenuItem select_previous_point = add_menu_item (t_("Select Previous Point"), "select previous point", "Glyph"); 		select_previous_point.action.connect (() => { 			PenTool.select_point_left (); 			show_menu = false; 		});-		select_previous_point.display = "Glyph"; 		edit_menu.items.add (select_previous_point); -		MenuItem select_point_below = add_menu_item (t_("Select Point Below"), "select point below");+		MenuItem select_point_below = add_menu_item (t_("Select Point Below"), "select point below", "Glyph"); 		select_point_below.action.connect (() => { 			PenTool.select_point_down (); 			show_menu = false; 		});-		select_point_below.display = "Glyph"; 		edit_menu.items.add (select_point_below);  		// tab menu@@ -371,7 +367,8 @@ public class Menu : GLib.Object { 			KerningDisplay.next_pair (); 			show_menu = false; 		});-		next_kerning_pair.display = "Kerning";+		next_kerning_pair.add_display("Kerning");+		next_kerning_pair.add_display("Spacing"); 		kerning_menu.items.add (next_kerning_pair);  		MenuItem previous_kerning_pair = add_menu_item (t_("Select Previous Kerning Pair"), "select previous kerning pair");@@ -379,7 +376,8 @@ public class Menu : GLib.Object { 			KerningDisplay.previous_pair (); 			show_menu = false; 		});-		previous_kerning_pair.display = "Kerning";+		previous_kerning_pair.add_display("Kerning");+		previous_kerning_pair.add_display("Spacing"); 		kerning_menu.items.add (previous_kerning_pair);  		MenuItem load_kerning_strings = add_menu_item (t_("Load Kerning Strings"), "load kerning strings");@@ -473,27 +471,35 @@ public class Menu : GLib.Object { 		foreach (MenuItem item in sorted_menu_items) {		 			if (item.key == (unichar) keyval && item.modifiers == KeyBindings.modifier) { 				-				if (current_display is Glyph && item.display == "Glyph") {+				if (current_display is Glyph && item.in_display ("Glyph")) { 					item.action (); 				} 				 				display = current_display.get_name (); +				if (current_display is Glyph) {+					display = "Glyph";+				}+ 				if (!current_display.needs_modifier () || item.modifiers != NONE) { 					if (!SettingsDisplay.update_key_bindings -						&& (item.display == "" || item.display == display)) {+						&& item.in_display (display)+						&& !(item is ToolItem)) { 						item.action (); 					} 					 					if (item is ToolItem) { 						tm  = (ToolItem) item; 						-						if (!tm.tool.is_tool_modifier) {-							MainWindow.get_toolbox ().set_current_tool (tm.tool);-							return;-						} else {-							tm.tool.select_action (tm.tool);-							return;+						if (tm.in_display (display)) {+							if (tm.tool.editor_events) {+								MainWindow.get_toolbox ().set_current_tool (tm.tool);+								tm.tool.select_action (tm.tool);+								return;+							} else {+								tm.tool.select_action (tm.tool);+								return;+							} 						} 					} 				}@@ -576,13 +582,17 @@ public class Menu : GLib.Object { 		} 	} 	-	MenuItem add_menu_item (string label, string description = "") {+	MenuItem add_menu_item (string label, string description = "", string display = "") { 		MenuItem i = new MenuItem (label, description); 		 		if (description != "") { 			menu_items.set (description, i); 			sorted_menu_items.add (i); 		}+		+		if (display != "") {+			i.add_display (display);+		} 								 		return i; 	}@@ -618,6 +628,10 @@ public class Menu : GLib.Object { 						menu_items.set (tool_item.identifier, tool_item); 						sorted_menu_items.add (tool_item); 					}+					+					foreach (string d in tool_set.get_displays ()) {+						tool_item.add_display (d);+					} 				} 			} 		}diff --git a/libbirdfont/MenuItem.vala b/libbirdfont/MenuItem.valaindex 29b87eb..06e8dff 100644--- a/libbirdfont/MenuItem.vala+++ b/libbirdfont/MenuItem.vala@@ -25,7 +25,8 @@ public class MenuItem : GLib.Object { 	// key bindings 	public uint modifiers = NONE; 	public unichar key = '\0';-	public string display = "";	+	+	public Gee.ArrayList<string> displays = new Gee.ArrayList<string> ();	 	 	public MenuItem (string label, string identifier = "") { 		this.label = new Text ();@@ -34,6 +35,25 @@ public class MenuItem : GLib.Object { 		y = 0; 	} +	public void add_display (string d) {+		displays.add (d);+	}++	/** @return true if a key binding can be used in @param display. */+	public bool in_display (string display) {+		if (displays.size == 0) {+			return true;+		}++		foreach (string d in displays) {+			if (d == display) {+				return true;+			}+		}+		+		return false;+	}+ 	public string get_key_bindings () { 		string key_binding = ""; 		@@ -50,6 +70,7 @@ public class MenuItem : GLib.Object { 			 			if ((modifiers & LOGO) > 0) { 				key_binding += "Command+";+	 			} 			 			if ((modifiers & SHIFT) > 0) {diff --git a/libbirdfont/OverviewTools.vala b/libbirdfont/OverviewTools.valaindex 6d52c49..4dc0cf3 100644--- a/libbirdfont/OverviewTools.vala+++ b/libbirdfont/OverviewTools.vala@@ -158,7 +158,12 @@ public class OverviewTools : ToolCollection  { 	public override Gee.ArrayList<Expander> get_expanders () { 		return expanders; 	}-	++	public override Gee.ArrayList<string> get_displays () {+		Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+		d.add ("Overview");+		return d;+	} }  }diff --git a/libbirdfont/PreviewTools.vala b/libbirdfont/PreviewTools.valaindex 75b4148..c069858 100644--- a/libbirdfont/PreviewTools.vala+++ b/libbirdfont/PreviewTools.vala@@ -77,6 +77,12 @@ public class PreviewTools : ToolCollection  { 	public override Gee.ArrayList<Expander> get_expanders () { 		return expanders; 	}++	public override Gee.ArrayList<string> get_displays () {+		Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+		d.add ("Preview");+		return d;+	} }  }diff --git a/libbirdfont/SpacingTools.vala b/libbirdfont/SpacingTools.valaindex b5786c9..ef5001e 100644--- a/libbirdfont/SpacingTools.vala+++ b/libbirdfont/SpacingTools.vala@@ -50,6 +50,12 @@ public class SpacingTools : ToolCollection  { 		expanders.add (zoom_expander); 		expanders.add (spacing_tools_expander); 	}++	public override Gee.ArrayList<string> get_displays () {+		Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+		d.add ("Spacing");+		return d;+	} 	 	public override Gee.ArrayList<Expander> get_expanders () { 		return expanders;diff --git a/libbirdfont/ToolCollection.vala b/libbirdfont/ToolCollection.valaindex 9861b93..29cb98a 100644--- a/libbirdfont/ToolCollection.vala+++ b/libbirdfont/ToolCollection.vala@@ -20,7 +20,12 @@ namespace BirdFont { public abstract class ToolCollection : GLib.Object  { 	public double scroll = 0; 	public double content_height = 0;+	 	public abstract Gee.ArrayList<Expander> get_expanders ();++	public virtual Gee.ArrayList<string> get_displays () {+		return new Gee.ArrayList<string> ();+	} }  }

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112