Commit 96f925c
Key bindings for zoom in and zoom out Ctrl++ Zoom in Ctrl+- Zoom out
Changed files (8)
modifiedlibbirdfont/DrawingTools.valaaddedlibbirdfont/HiddenTools.valamodifiedlibbirdfont/KerningDisplay.valamodifiedlibbirdfont/KerningTools.valamodifiedlibbirdfont/Menu.valamodifiedlibbirdfont/SettingsDisplay.valamodifiedlibbirdfont/Toolbox.valamodifiedresources/key_bindings.xml
Diff
@@ -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) => {new file mode 100644@@ -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;+ }+}++}@@ -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;@@ -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; @@ -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") {@@ -345,7 +345,6 @@ public class SettingsDisplay : FontDisplay { } } - // TODO: ignore scrolling if event is consumed if (consumed) { GlyphCanvas.redraw (); }@@ -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; @@ -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>