The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

List and remove guides

These changes was commited to the Birdfont repository Sun, 08 Mar 2015 17:57:18 +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>
Sun, 08 Mar 2015 17:57:18 +0000 (18:57 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 08 Mar 2015 17:57:18 +0000 (18:57 +0100)
commit 2a6798fbbaa06fb3b619730ff3f80d7ad1628a0b
tree 6f497e697db1141827e93d077b7c33f502df6826
parent 1e58841ef0ee672365dde34e3c2ef17960e693e9
List and remove guides

libbirdfont/GuideTab.vala [new ]
libbirdfont/Menu.vala
libbirdfont/MenuTab.vala
diff --git libbirdfont/GuideTab.vala(new)
--- /dev/null +++ b/libbirdfont/GuideTab.vala @@ -1,1 +1,65 @@ + /* + 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 GuideTab : Table { + + Gee.ArrayList<Row> rows = new Gee.ArrayList<Row> (); + + public GuideTab () { + } + + public override Gee.ArrayList<Row> get_rows () { + return rows; + } + + public override void selected_row (Row row, int column, bool delete_button) { + Font font = BirdFont.get_current_font (); + int index = row.get_index (); + + if (delete_button) { + return_if_fail (0 <= index < BirdFont.get_current_font ().custom_guides.size); + BirdFont.get_current_font ().custom_guides.remove_at (index); + update_rows (); + } + } + + public override void update_rows () { + int i = 0; + SpacingData spacing = BirdFont.get_current_font ().get_spacing (); + + rows.clear (); + + foreach (Line guide in BirdFont.get_current_font ().custom_guides) { + rows.add (new Row.columns_1 (guide.label, i)); + i++; + } + + GlyphCanvas.redraw (); + } + + public override string get_label () { + return t_("Guides"); + } + + public override string get_name () { + return "Guides"; + } + } + + }
--- a/libbirdfont/Menu.vala +++ b/libbirdfont/Menu.vala @@ -257,6 +257,13 @@ }); edit_menu.items.add (create_guide); + MenuItem show_guide_guide = add_menu_item (t_("List Guides"), "show guide tab"); + show_guide_guide.action.connect (() => { + MenuTab.show_guide_tab (); + show_menu = false; + }); + edit_menu.items.add (show_guide_guide); + MenuItem select_point_above = add_menu_item (t_("Select Point Above"), "select point above"); select_point_above.action.connect (() => { PenTool.select_point_up ();
--- a/libbirdfont/MenuTab.vala +++ b/libbirdfont/MenuTab.vala @@ -601,7 +601,11 @@ public static void show_settings_tab () { MainWindow.get_tab_bar ().add_unique_tab (new SettingsDisplay ()); } + + public static void show_guide_tab () { + MainWindow.get_tab_bar ().add_unique_tab (new GuideTab ()); + } } }