Commit 3bf69b2
Merge branch '2.14' of github.com:johanmattssonm/birdfont into 2.14
Changed files (6)
modifiedlibbirdfont/AbstractMenu.valamodifiedlibbirdfont/BackgroundSelectionTool.valamodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/MainWindow.valamodifiedlibbirdfont/OverView.valamodifiedlibbirdfont/StrokeTool.vala
Diff
@@ -36,11 +36,15 @@ public class AbstractMenu : GLib.Object { if (tab_name == "Preview") { MenuTab.select_overview (); }+ + MainWindow.hide_scrollbar ();+ } else {+ MainWindow.show_scrollbar (); } } } - public bool menu_visibility = false;+ private bool menu_visibility = false; public SubMenu top_menu; SubMenu current_menu;@@ -219,7 +223,7 @@ public class AbstractMenu : GLib.Object { y += height; } - menu_visibility = false;+ show_menu = false; current_menu = (!) top_menu; GlyphCanvas.redraw (); }@@ -28,6 +28,7 @@ public class BackgroundSelectionTool : CutBackgroundTool { new_image.connect (add_new_image); select_action.connect ((t) => {+ DrawingTools.move_canvas.set_selected (false); GlyphCanvas.redraw (); }); @@ -148,7 +148,7 @@ public class ExportTool : GLib.Object { public static void export_current_glyph () { FileChooser fc = new FileChooser ();- fc.file_selected.connect ((f) => {+ fc.file_selected.connect ((selected_file) => { Glyph glyph = MainWindow.get_current_glyph (); FontDisplay fd = MainWindow.get_current_display (); string glyph_svg;@@ -159,19 +159,34 @@ public class ExportTool : GLib.Object { string fn; int i; - name = glyph.get_name ();- - if (f == null) {+ if (fd is Glyph) {+ glyph = MainWindow.get_current_glyph ();+ } else if (fd is OverView) {+ OverView overview = MainWindow.get_overview ();+ Glyph? g = overview.get_selected_glyph ();+ + if (g == null) {+ warning("No glyhp selected in overview.");+ return;+ }+ + glyph = (!) g;+ } else { return; } - svg_file = (!) f;-- if (!(fd is Glyph)) {+ name = glyph.get_name ();+ + if (selected_file == null) { return; } + svg_file = (!) selected_file;+ try {+#if MAC+ file = File.new_for_path (svg_file);+#else i = 1; fn = svg_file.replace (".svg", ""); file = File.new_for_path (fn + ".svg");@@ -179,8 +194,8 @@ public class ExportTool : GLib.Object { file = File.new_for_path (fn + @"$i.svg"); i++; }- - glyph_svg = export_current_glyph_to_string ();+#endif + glyph_svg = export_to_string (glyph, false); os = new DataOutputStream (file.create(FileCreateFlags.REPLACE_DESTINATION)); os.put_string (glyph_svg); @@ -36,6 +36,8 @@ public class MainWindow : GLib.Object { /** Number of pixels per mm */ public static double units = 1; + private static double scrollbar_size = -1; + public MainWindow () { singleton = this; @@ -131,10 +133,10 @@ public class MainWindow : GLib.Object { public static void init () { singleton = new MainWindow (); } -- public static RecentFiles get_recent_files_tab () {- return file_tab;- }+ + public static RecentFiles get_recent_files_tab () { + return file_tab; + } public static void open_recent_files_tab () { // FIXME: do not idle @@ -250,8 +252,21 @@ public class MainWindow : GLib.Object { MainWindow.native_window.file_chooser (title, fc, flags); } + public static void hide_scrollbar () { + if (!is_null (MainWindow.native_window)) { + MainWindow.native_window.set_scrollbar_size (-1); + } + } + + public static void show_scrollbar () { + if (!is_null (MainWindow.native_window)) { + MainWindow.native_window.set_scrollbar_size (scrollbar_size); + } + } + public static void set_scrollbar_size (double size) { if (!is_null (MainWindow.native_window)) { + scrollbar_size = size; MainWindow.native_window.set_scrollbar_size (size); } } @@ -290,43 +305,43 @@ public class MainWindow : GLib.Object { public static LigatureList get_ligature_display () { return ligature_display; } -- public static void next_tab () {- TabBar tb = MainWindow.get_tab_bar ();- int n = tb.get_selected () + 1;- - if (!(0 <= n < tb.get_length ())) {- return;- }- - tb.select_tab (n);- }-- public static void previous_tab () {- TabBar tb = MainWindow.get_tab_bar ();- int n = tb.get_selected () - 1;-- if (!(0 <= n < tb.get_length ())) {- return;- }- - tb.select_tab (n);- }-- public static void close_tab () {- TabBar tb = MainWindow.get_tab_bar ();- int n = tb.get_selected ();-- if (!(0 <= n < tb.get_length ())) {- return;- }- - tb.close_tab (n);+ + public static void next_tab () { + TabBar tb = MainWindow.get_tab_bar (); + int n = tb.get_selected () + 1; + + if (!(0 <= n < tb.get_length ())) { + return; + } + + tb.select_tab (n); + } + + public static void previous_tab () { + TabBar tb = MainWindow.get_tab_bar (); + int n = tb.get_selected () - 1; + + if (!(0 <= n < tb.get_length ())) { + return; + } + + tb.select_tab (n); + } + + public static void close_tab () { + TabBar tb = MainWindow.get_tab_bar (); + int n = tb.get_selected (); + + if (!(0 <= n < tb.get_length ())) { + return; + } + + tb.close_tab (n); } public static void set_toolbox (Toolbox tb) { tools = tb; - }+ } } } @@ -129,6 +129,14 @@ public class OverView : FontDisplay { update_scrollbar (); reset_zoom (); }++ public Glyph? get_selected_glyph () {+ if (selected_items.size == 0) {+ return null;+ }+ + return selected_items.get (0).get_current ();+ } public void select_all_glyphs () { Font f;@@ -535,10 +535,8 @@ public class StrokeTool : GLib.Object { next = lep.get_next (); hidden = new EditPoint (0, 0, PointType.QUADRATIC); - px = next.get_right_handle ().x - + (next.get_left_handle ().x - prev.get_right_handle ().x) / 2.0;- py = next.get_right_handle ().y - + (next.get_left_handle ().y - prev.get_right_handle ().y) / 2.0;+ px = (next.get_left_handle ().x + prev.get_right_handle ().x) / 2.0;+ py = (next.get_left_handle ().y + prev.get_right_handle ().y) / 2.0; hidden.independent_x = px; hidden.independent_y = py;