Clone in a terminal:
Commit 96f925c
Johan Mattsson - 2015-03-05T15:38:28+00:00
96f925c4bc30a894b2507039a2cf45a24615d46ajohan.mattsson.m@gmail.com

Key bindings for zoom in and zoom out Ctrl++ Zoom in Ctrl+- Zoom out

Changed files (8)

Diff

diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex df56d90..6d38037 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -39,7 +39,7 @@ public class DrawingTools : ToolCollection  {  	ForesightTool foresight_tool; 	PointTool point_tool;-	static ZoomTool zoom_tool;+	public static ZoomTool zoom_tool; 	public static ResizeTool resize_tool; 	StrokeTool stroke_tool; 	public static TrackTool track_tool;@@ -867,22 +867,6 @@ public class DrawingTools : ToolCollection  { 			GlyphCanvas.redraw (); 		}); 		zoombar_tool.add_tool (zoom_bar);-		-		Tool zoom_in = new Tool ("zoom_in", "Zoom In");-		zoom_in.select_action.connect ((self) => {-			zoom_tool.store_current_view ();-			glyph_canvas.get_current_display ().zoom_in ();-		});-		view_tools.add_tool (zoom_in);-		zoom_in.set_tool_visibility (false);--		Tool zoom_out = new Tool ("zoom_out", "Zoom Out");-		zoom_out.select_action.connect ((self) => {-			zoom_tool.store_current_view ();-			glyph_canvas.get_current_display ().zoom_out ();-		});-		view_tools.add_tool (zoom_out);-		zoom_out.set_tool_visibility (false);  		Tool reset_zoom = new Tool ("zoom_1_1", t_("Zoom Out More")); 		reset_zoom.select_action.connect ((self) => {diff --git a/libbirdfont/HiddenTools.vala b/libbirdfont/HiddenTools.valanew file mode 100644index 0000000..e98daf3--- /dev/null+++ b/libbirdfont/HiddenTools.vala@@ -0,0 +1,50 @@+/*+    Copyright (C) 2015 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 +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library is distributed in the hope that it will be useful, but +    WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +    Lesser General Public License for more details.+*/++using Cairo;+using Math;++namespace BirdFont {++public class HiddenTools : ToolCollection  {++	public Gee.ArrayList<Expander> expanders;++	public HiddenTools () {+		Expander hidden_expander = new Expander ();+		expanders = new Gee.ArrayList<Expander> ();+		+		Tool zoom_in = new Tool ("zoom_in", t_("Zoom In"));+		zoom_in.select_action.connect ((self) => {+			DrawingTools.zoom_tool.store_current_view ();+			GlyphCanvas.current_display.zoom_in ();+		});+		hidden_expander.add_tool (zoom_in);+		+		Tool zoom_out = new Tool ("zoom_out", t_("Zoom out"));+		zoom_out.select_action.connect ((self) => {+			DrawingTools.zoom_tool.store_current_view ();+			GlyphCanvas.current_display.zoom_out ();+		});+		hidden_expander.add_tool (zoom_out);+		+		expanders.add (hidden_expander);+	}++	public override Gee.ArrayList<Expander> get_expanders () {+		return expanders;+	}+}++}diff --git a/libbirdfont/KerningDisplay.vala b/libbirdfont/KerningDisplay.valaindex 2b95cb5..c5f1ff9 100644--- a/libbirdfont/KerningDisplay.vala+++ b/libbirdfont/KerningDisplay.vala@@ -956,6 +956,28 @@ public class KerningDisplay : FontDisplay { 		 		return redo_state; 	}++	public override void zoom_in () {+		KerningTools.font_size += 0.1;+		+		if (KerningTools.font_size > 3) {+			KerningTools.font_size = 3;+		}++		KerningTools.zoom_bar.set_zoom (KerningTools.font_size / 3);+		GlyphCanvas.redraw ();+	}++	public override void zoom_out () {+		KerningTools.font_size -= 0.1;+		+		if (KerningTools.font_size < 0.3) {+			KerningTools.font_size = 0.3;+		}+		+		KerningTools.zoom_bar.set_zoom (KerningTools.font_size / 3);+		GlyphCanvas.redraw ();+	} 	 	public class UndoItem : GLib.Object { 		public string first;diff --git a/libbirdfont/KerningTools.vala b/libbirdfont/KerningTools.valaindex fdf2a54..9bce03b 100644--- a/libbirdfont/KerningTools.vala+++ b/libbirdfont/KerningTools.vala@@ -24,6 +24,7 @@ public class KerningTools : ToolCollection  { 	public static bool adjust_side_bearings = false; 	 	public static double font_size = 1;+	public static ZoomBar zoom_bar; 	 	public KerningTools () { 		init ();@@ -40,7 +41,7 @@ public class KerningTools : ToolCollection  {  		Expander zoom_expander = new Expander (t_("Font Size")); -		ZoomBar zoom_bar = new ZoomBar ();+		zoom_bar = new ZoomBar (); 		zoom_bar.new_zoom.connect ((z) => { 			font_size = 3 * z; 			diff --git a/libbirdfont/Menu.vala b/libbirdfont/Menu.valaindex f78e446..cbdd801 100644--- a/libbirdfont/Menu.vala+++ b/libbirdfont/Menu.vala@@ -433,7 +433,9 @@ public class Menu : GLib.Object { 		string display; 		FontDisplay current_display = MainWindow.get_current_display (); 		-		foreach (MenuItem item in sorted_menu_items) {+		unichar c = (unichar) keyval;++		foreach (MenuItem item in sorted_menu_items) {		 			if (item.key == (unichar) keyval && item.modifiers == KeyBindings.modifier) { 				 				if (current_display is Glyph && item.display == "Glyph") {diff --git a/libbirdfont/SettingsDisplay.vala b/libbirdfont/SettingsDisplay.valaindex 96ac9f5..61e7989 100644--- a/libbirdfont/SettingsDisplay.vala+++ b/libbirdfont/SettingsDisplay.vala@@ -345,7 +345,6 @@ public class SettingsDisplay : FontDisplay { 			} 		} 		-		// TODO: ignore scrolling if event is consumed 		if (consumed) { 			GlyphCanvas.redraw (); 		}diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex 67d0a94..2af856e 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -25,6 +25,7 @@ public class Toolbox : GLib.Object  { 	public static PreviewTools preview_tools; 	public static OverviewTools overview_tools; 	public static BackgroundTools background_tools;+	public static HiddenTools hidden_tools; 	 	Tool current_tool; 	@@ -53,12 +54,14 @@ public class Toolbox : GLib.Object  { 		preview_tools = new PreviewTools (); 		overview_tools = new OverviewTools (); 		background_tools = new BackgroundTools ();+		hidden_tools = new HiddenTools (); 		 		tool_sets.append (drawing_tools); 		tool_sets.append (kerning_tools); 		tool_sets.append (preview_tools); 		tool_sets.append (overview_tools); 		tool_sets.append (background_tools);+		tool_sets.append (hidden_tools); // tools without a button 		 		current_set = drawing_tools; 		diff --git a/resources/key_bindings.xml b/resources/key_bindings.xmlindex 716f0c3..4342fef 100644--- a/resources/key_bindings.xml+++ b/resources/key_bindings.xml@@ -1,13 +1,12 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <bindings>-	<action key="n" ctrl="true" alt="false" command="false" shift="false" action="new" />+	<action key="ο" ctrl="false" alt="true" command="false" shift="false" action="new" /> 	<action key="o" ctrl="true" alt="false" command="false" shift="false" action="open" /> 	<action key="r" ctrl="true" alt="false" command="false" shift="false" action="recent files" /> 	<action key="s" ctrl="true" alt="false" command="false" shift="false" action="save" /> 	<action key="S" ctrl="true" alt="false" command="false" shift="true" action="save as" /> 	<action key="e" ctrl="true" alt="false" command="false" shift="false" action="export" /> 	<action key="p" ctrl="true" alt="false" command="false" shift="false" action="preview" />-	<action key="" ctrl="false" alt="false" command="false" shift="false" action="name and description" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="select character set" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="quit" /> 	<action key="z" ctrl="true" alt="false" command="false" shift="false" action="undo" />@@ -41,7 +40,9 @@ 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="select previous kerning pair" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="show ligature tab" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="add ligature" />+	<action key="" ctrl="false" alt="false" command="false" shift="false" action="save as .bfp" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="settings" />+	<action key="d" ctrl="true" alt="false" command="false" shift="false" action="name and description" /> 	<action key="b" ctrl="false" alt="false" command="false" shift="false" action="foresight" /> 	<action key="n" ctrl="false" alt="false" command="false" shift="false" action="pen_tool" /> 	<action key="m" ctrl="false" alt="false" command="false" shift="false" action="point_tool" />@@ -61,6 +62,7 @@ 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="skew" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="width" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="height" />+	<action key="" ctrl="false" alt="false" command="false" shift="false" action="object_stroke" /> 	<action key="w" ctrl="false" alt="false" command="false" shift="false" action="tie_point" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="symmetric" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="create_line" />@@ -82,8 +84,6 @@ 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="show_xheight_helplines" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="background_help_lines" /> 	<action key="g" ctrl="false" alt="false" command="false" shift="false" action="show_grid" />-	<action key="" ctrl="false" alt="false" command="false" shift="false" action="zoom_in" />-	<action key="" ctrl="false" alt="false" command="false" shift="false" action="zoom_out" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="zoom_1_1" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="full_glyph" /> 	<action key="v" ctrl="false" alt="false" command="false" shift="false" action="zoom_boundaries" />@@ -103,4 +103,6 @@ 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="export_fonts" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="generate_html_document" /> 	<action key="" ctrl="false" alt="false" command="false" shift="false" action="select_background" />+	<action key="+" ctrl="true" alt="false" command="false" shift="false" action="zoom_in" />+	<action key="-" ctrl="true" alt="false" command="false" shift="false" action="zoom_out" /> </bindings>

Contact

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