The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Hide resize handle when objects are moved and merge birdfont-2.x

These changes was commited to the Birdfont repository Tue, 14 Jun 2016 13:44:13 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 14 Jun 2016 13:44:13 +0000 (15:44 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 14 Jun 2016 13:44:13 +0000 (15:44 +0200)
commit 684fde4a803662ebacd724f8ef3693256a3a95bb
tree 207d6b546774389069642a661ab2bbb0d8d453fb
parent 872a7ac172cd55efbaae7f1a479305c38753814a
parent cf58fd5cb41c9ee0485580fe1883bf28fcbc230f
Hide resize handle when objects are moved and merge birdfont-2.x

libbirdfont/AbstractMenu.vala
libbirdfont/AlternateSets.vala
libbirdfont/Glyph.vala
libbirdfont/OpenFontFormat/AlternateFeature.vala
libbirdfont/OtfFeatureTable.vala
libbirdfont/OverView.vala
libbirdfont/ResizeTool.vala
libbirdfont/TabContent.vala
libbirdfont/ZoomTool.vala
scripts/version.py
--- a/libbirdfont/AbstractMenu.vala +++ b/libbirdfont/AbstractMenu.vala @@ -75,7 +75,8 @@ return null; } - public void process_key_binding_events (uint keyval) { + /** @return true if the keybindings consumes the event. */ + public bool process_key_binding_events (uint keyval) { string display; FontDisplay current_display = MainWindow.get_current_display (); ToolItem tm; @@ -96,7 +97,7 @@ if (!SettingsDisplay.update_key_bindings && !(item is ToolItem)) { item.action (); - return; + return true; } if (item is ToolItem) { @@ -106,16 +107,18 @@ if (tm.tool.editor_events) { MainWindow.get_toolbox ().set_current_tool (tm.tool); tm.tool.select_action (tm.tool); - return; + return true; } else { tm.tool.select_action (tm.tool); - return; + return true; } } } } } } + + return false; } public void load_key_bindings () {
--- a/libbirdfont/AlternateSets.vala +++ b/libbirdfont/AlternateSets.vala @@ -51,7 +51,30 @@ return alt; } - + + public Gee.ArrayList<Alternate> get_alt_with_glyph (string tag, Font font) { + Gee.ArrayList<Alternate> alt; + alt = new Gee.ArrayList<Alternate> (); + + foreach (Alternate a in alternates) { + Alternate available = new Alternate (a.glyph_name, a.tag); + + foreach (string substitution in a.alternates) { + if (font.has_glyph (substitution)) { + available.alternates.add (substitution); + } + } + + if (available.tag == tag && available.alternates.size > 0) { + if (font.has_glyph (available.glyph_name)) { + alt.add (available); + } + } + } + + return alt; + } + public void remove_empty_sets () { int i = 0; foreach (Alternate a in alternates) {
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1142,19 +1142,9 @@ } public void show_zoom_area (int sx, int sy, int nx, int ny) { - double x, y, w, h; - set_zoom_area (sx, sy, nx, ny); - zoom_area_is_visible = true; - - x = Math.fmin (zoom_x1, zoom_x2) - 50; - y = Math.fmin (zoom_y1, zoom_y2) - 50; - - w = Math.fabs (zoom_x1 - zoom_x2) + 100; - h = Math.fabs (zoom_y1 - zoom_y2) + 100; - - redraw_area ((int)x, (int)y, (int)w, (int)h); + GlyphCanvas.redraw (); } public void set_zoom_area (int sx, int sy, int nx, int ny) {
--- a/libbirdfont/OpenFontFormat/AlternateFeature.vala +++ b/libbirdfont/OpenFontFormat/AlternateFeature.vala @@ -24,7 +24,7 @@ this.tag = tag; this.glyf_table = glyf_table; - alternates = font.alternates.get_alt (tag); + alternates = font.alternates.get_alt_with_glyph (tag, font); alternates.sort ((a, b) => { Alternate alt1 = (Alternate) a;
--- a/libbirdfont/OtfFeatureTable.vala +++ b/libbirdfont/OtfFeatureTable.vala @@ -53,7 +53,8 @@ GlyphSelection gs = new GlyphSelection (); gs.selected_glyph.connect ((gc) => { - glyph_collection = gc; + glyph_collection = gc; + replacement_glyph = null; MainWindow.get_tab_bar ().select_tab_name (get_name ()); });
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -94,15 +94,13 @@ TabBar tabs = MainWindow.get_tab_bar (); string n = glyph_collection.get_current ().name; bool selected = tabs.select_char (n); - GlyphCanvas canvas; + GlyphTab glyph_tab; if (!selected) { glyph_tab = new GlyphTab (glyph_collection); - canvas = MainWindow.get_glyph_canvas (); tabs.add_tab (glyph_tab, true, glyph_collection); - canvas.set_current_glyph_collection (glyph_collection); - set_initial_zoom (); + set_glyph_zoom (glyph_collection); PenTool.update_orientation (); } @@ -203,7 +201,7 @@ canvas = MainWindow.get_glyph_canvas (); canvas.set_current_glyph_collection (glyph_collection); - set_initial_zoom (); + set_glyph_zoom (glyph_collection); } else { warning ("Glyph is already open"); } @@ -291,15 +289,18 @@ return null; } - public void set_initial_zoom () { + public void set_glyph_zoom (GlyphCollection glyphs) { + GlyphCanvas canvas; + canvas = MainWindow.get_glyph_canvas (); + canvas.set_current_glyph_collection (glyphs); Toolbox tools = MainWindow.get_toolbox (); ZoomTool z = (ZoomTool) tools.get_tool ("zoom_tool"); z.store_current_view (); - MainWindow.get_current_glyph ().default_zoom (); + glyphs.get_current ().default_zoom (); z.store_current_view (); OverViewItem.reset_label (); } - + public double get_height () { double l; Font f; @@ -1071,6 +1072,16 @@ if (g.length () > 0) { font.add_glyph_collection (g); + } + + TabBar tabs = MainWindow.get_tab_bar (); + Tab? tab = tabs.get_tab (g.get_name ()); + + if (tab != null) { + Tab t = (!) tab; + set_glyph_zoom (g); + t.set_glyph_collection (g); + t.set_display (new GlyphTab (g)); } } @@ -1096,6 +1107,16 @@ foreach (GlyphCollection g in previous_collection.glyphs) { font.delete_glyph (g); font.add_glyph_collection (g); + + TabBar tabs = MainWindow.get_tab_bar (); + Tab? tab = tabs.get_tab (g.get_name ()); + + if (tab != null) { + Tab t = (!) tab; + set_glyph_zoom (g); + t.set_glyph_collection (g); + t.set_display (new GlyphTab (g)); + } } font.alternates = previous_collection.alternate_sets.copy ();
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -165,36 +165,38 @@ Text handle; Glyph g = MainWindow.get_current_glyph (); - if (!rotate_path) { - if (!resize_width) { - handle = proportional_handle; - get_resize_handle_position (out handle.widget_x, out handle.widget_y); + if (!move_paths) { + if (!rotate_path) { + if (!resize_width) { + handle = proportional_handle; + get_resize_handle_position (out handle.widget_x, out handle.widget_y); + + handle.widget_x -= handle.get_sidebearing_extent () / 2; + handle.widget_y -= handle.get_height () / 2; + + handle.draw (cr); + } - handle.widget_x -= handle.get_sidebearing_extent () / 2; - handle.widget_y -= handle.get_height () / 2; + if (!resize_path_proportional) { + handle = horizontal_handle; + + get_horizontal_reseize_handle_position (out handle.widget_x, + out handle.widget_y); + + handle.widget_x -= handle.get_sidebearing_extent () / 2; + handle.widget_y -= handle.get_height () / 2; + + handle.draw (cr); + } + } + + if (!resize_path_proportional && !resize_width + && g.active_paths.size > 0) { - handle.draw (cr); - } - - if (!resize_path_proportional) { - handle = horizontal_handle; - - get_horizontal_reseize_handle_position (out handle.widget_x, - out handle.widget_y); - - handle.widget_x -= handle.get_sidebearing_extent () / 2; - handle.widget_y -= handle.get_height () / 2; - - handle.draw (cr); + draw_rotate_handle (cr); } } - - if (!resize_path_proportional && !resize_width - && g.active_paths.size > 0) { - - draw_rotate_handle (cr); - } - + MoveTool.draw_actions (cr); });
--- a/libbirdfont/TabContent.vala +++ b/libbirdfont/TabContent.vala @@ -150,8 +150,12 @@ KeyBindings.add_modifier_from_keyval (keyval); if (!text_input_visible) { - MainWindow.get_menu ().process_key_binding_events (keyval); - GlyphCanvas.current_display.key_press (keyval); + AbstractMenu menu = MainWindow.get_menu (); + bool consumed = menu.process_key_binding_events (keyval); + + if (!consumed) { + GlyphCanvas.current_display.key_press (keyval); + } } else { text_input.key_press (keyval); }
--- a/libbirdfont/ZoomTool.vala +++ b/libbirdfont/ZoomTool.vala @@ -36,17 +36,18 @@ }); press_action.connect((self, b, x, y) => { - if (b == 1 && KeyBindings.modifier != CTRL) { + if (b == 1 && !KeyBindings.has_ctrl () && !KeyBindings.has_shift ()) { zoom_area_begin_x = x; zoom_area_begin_y = y; + Glyph g = MainWindow.get_current_glyph (); + g.zoom_area_is_visible = true; } }); move_action.connect((self, x, y) => { - Glyph g; + Glyph g = MainWindow.get_current_glyph (); - if (zoom_area_begin_x > 0) { - g = MainWindow.get_current_glyph (); + if (g.zoom_area_is_visible) { g.show_zoom_area (zoom_area_begin_x, zoom_area_begin_y, x, y); } }); @@ -54,7 +55,7 @@ release_action.connect((self, b, x, y) => { Glyph g; - if (b == 1 && KeyBindings.modifier != CTRL) { + if (b == 1 && !KeyBindings.has_ctrl () && !KeyBindings.has_shift ()) { store_current_view (); g = MainWindow.get_current_glyph (); @@ -65,6 +66,7 @@ g.set_zoom_from_area (); } + g.zoom_area_is_visible = false; zoom_area_begin_x = -1; zoom_area_begin_y = -1; }
--- a/scripts/version.py +++ b/scripts/version.py @@ -13,7 +13,7 @@ Lesser General Public License for more details. """ - VERSION = '2.16.0' + VERSION = '2.16.1' SO_VERSION_MAJOR = '36' SO_VERSION_MINOR = '0' SO_VERSION = SO_VERSION_MAJOR + '.' + SO_VERSION_MINOR