Clone in a terminal:
Commit 413c747
Johan Mattsson - 2016-06-11T09:59:46+00:00
413c747e3a451992aeb7cc387bc26d0c8e25be9ajohan.mattsson.m@gmail.com

Update glyph tab when glyphs are changed in overview

Changed files (10)

Diff

diff --git a/libbirdfont/AbstractMenu.vala b/libbirdfont/AbstractMenu.valaindex 19c8e3d..39ee6ee 100644--- a/libbirdfont/AbstractMenu.vala+++ b/libbirdfont/AbstractMenu.vala@@ -83,7 +83,7 @@ public class AbstractMenu : GLib.Object { 		 		display = current_display.get_name (); -		if (current_display is Glyph) {+		if (current_display is GlyphTab) { 			display = "Glyph"; 		} 		diff --git a/libbirdfont/ClipTool.vala b/libbirdfont/ClipTool.valaindex a2b425d..e0a5744 100644--- a/libbirdfont/ClipTool.vala+++ b/libbirdfont/ClipTool.vala@@ -32,7 +32,7 @@ public class ClipTool : Tool { 		string bf_data; 		string data; 		-		if (fd is Glyph) {+		if (fd is GlyphTab) { 			svg_data = ExportTool.export_selected_paths_to_svg (); 			 			bf_data = export_selected_paths_to_birdfont_clipboard ();@@ -87,7 +87,7 @@ public class ClipTool : Tool { 		double x, y, w, h; 		double dx, dy; 		-		if (fd is Glyph) {+		if (fd is GlyphTab) { 			paste_paths (false); 			 			g.selection_boundaries (out x, out y, out w, out h);@@ -115,7 +115,7 @@ public class ClipTool : Tool { 		// Determine if clipboard contains data in birdfont format. 		is_bf_clipboard = clipboard_data.index_of ("BirdFontClipboard") > -1;  -		if (fd is Glyph) {+		if (fd is GlyphTab) { 			paste_to_glyph (is_bf_clipboard, paste_guide_lines); 		} 		@@ -132,7 +132,7 @@ public class ClipTool : Tool { 		FontDisplay fd = MainWindow.get_current_display (); 		Glyph? destination = null; 		string data;-		return_if_fail (fd is Glyph);+		return_if_fail (fd is GlyphTab); 		 		destination = (Glyph) fd; 		((!)destination).store_undo_state ();diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 771f81c..861f197 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -679,7 +679,7 @@ public class DrawingTools : ToolCollection  { 		});	 		 		bg_selection.select_action.connect((self) => {-			if (MainWindow.get_current_display () is Glyph) {+			if (MainWindow.get_current_display () is GlyphTab) { 				BackgroundTool.import_background_image (); 			} 		});@@ -1236,9 +1236,11 @@ public class DrawingTools : ToolCollection  { 		// update selelction when the user switches tab 		MainWindow.get_tab_bar ().signal_tab_selected.connect((tab) => { 			Glyph glyph;+			GlyphTab glyph_tab; 			-			if (tab.get_display () is Glyph) {-				glyph = (Glyph) tab.get_display ();+			if (tab.get_display () is GlyphTab) {+				glyph_tab = (GlyphTab) tab.get_display ();+				glyph = glyph_tab.glyphs.get_current (); 				show_bg.set_selected (glyph.get_background_visible ()); 				update_line_selection (glyph); 			}diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 2764e6c..bbc923f 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -120,7 +120,7 @@ public class Glyph : FontDisplay { 	Line left_line; 	Line right_line; -	/** Cache for Cairo rendering */+	/** Cache for Cairo surface rendering */ 	HashMap<string, Surface> glyph_cache = new HashMap<string, Surface> ();  	public const double CANVAS_MIN = -10000;diff --git a/libbirdfont/GlyphTab.vala b/libbirdfont/GlyphTab.valanew file mode 100644index 0000000..ca8972b--- /dev/null+++ b/libbirdfont/GlyphTab.vala@@ -0,0 +1,155 @@+/*+	Copyright (C) 2016 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 GlyphTab : FontDisplay {++	public GlyphCollection glyphs;++	public GlyphTab (GlyphCollection glyphs) {+		this.glyphs = glyphs;+	}++	public override string get_name () {+		return glyphs.get_current ().get_name ();+	}++	public override string get_label () {+		return glyphs.get_current ().get_label ();+	}++	public override void close () {+		glyphs.get_current ().close ();+	}++	public override bool has_scrollbar () {+		return glyphs.get_current ().has_scrollbar ();+	}++	public override void update_scrollbar () {+		glyphs.get_current ().update_scrollbar ();+	}++	public override void scroll_to (double percent) {+		glyphs.get_current ().scroll_to (percent);+	}++	public override void draw (WidgetAllocation allocation, Context cr) {+		glyphs.get_current ().draw (allocation, cr);+	}++	public override void selected_canvas () {+		glyphs.get_current ().selected_canvas ();+	}++	public override void key_press (uint keyval) {+		glyphs.get_current ().key_press (keyval);+	}++	public override void key_release (uint keyval) {+		glyphs.get_current ().key_release (keyval);+	}++	public override void motion_notify (double x, double y) {+		glyphs.get_current ().motion_notify (x, y);+	}++	public override void button_release (int button, double x, double y) {+		glyphs.get_current ().button_release (button, x, y);+	}++	public override void button_press (uint button, double x, double y) {+		glyphs.get_current ().button_press (button, x, y);+	}++	public override void double_click (uint button, double ex, double ey) {+		glyphs.get_current ().double_click (button, ex, ey);	+	}++	public override void magnify (double magnification) {+		glyphs.get_current ().magnify (magnification);+	}++	public override void tap_down (int finger, int x, int y) {+		glyphs.get_current ().tap_down (finger, x, y);+	}++	public override void tap_up (int finger, int x, int y) {+		glyphs.get_current ().tap_up (finger, x, y);+	}++	public override void tap_move (int finger, int x, int y) {+		glyphs.get_current ().tap_move (finger, x, y);+	}++	public override void zoom_in () {+		glyphs.get_current ().zoom_in ();+	}++	public override void zoom_out () {+		glyphs.get_current ().zoom_out ();+	}++	public override void zoom_max () {+		glyphs.get_current ().zoom_max ();+	}++	public override void zoom_min () {+		glyphs.get_current ().zoom_min ();+	}++	public override void move_view (double x, double y) {+		glyphs.get_current ().move_view (x, y);	+	}++	public override void reset_zoom () {+		glyphs.get_current ().reset_zoom ();+	}++	public override void store_current_view () {+		glyphs.get_current ().store_current_view ();+	}++	public override void restore_last_view () {+		glyphs.get_current ().restore_last_view ();+	}++	public override void next_view () {+		glyphs.get_current ().next_view ();+	}++	public override void scroll_wheel (double x, double y,+		double pixeldelta_x,  double pixeldelta_y) {+			glyphs.get_current ().scroll_wheel (x, y, pixeldelta_x, pixeldelta_y);+	}++	public override void undo () {+		glyphs.get_current ().undo ();+	}++	public override void redo () {+		glyphs.get_current ().redo ();+	}++	/** returns false if bindings to a single key works in the display. */+	public override bool needs_modifier () {+		return glyphs.get_current ().needs_modifier ();+	}+}++}diff --git a/libbirdfont/MainWindow.vala b/libbirdfont/MainWindow.valaindex 7b851a3..a4dc3d9 100644--- a/libbirdfont/MainWindow.vala+++ b/libbirdfont/MainWindow.vala@@ -278,10 +278,12 @@ public class MainWindow : GLib.Object { 
 	/** Reaload all paths and help lines from disk. */
 	public static void clear_glyph_cache () {
-		Glyph g;
+		Glyph g;+		GlyphTab tab;
 		foreach (Tab t in get_tab_bar ().tabs) {
-			if (t.get_display () is Glyph) {
-				g = (Glyph) t.get_display ();
+			if (t.get_display () is GlyphTab) {+				tab = (GlyphTab) t.get_display ();
+				g = tab.glyphs.get_current ();
 				g.add_help_lines ();
 			}
 		}
diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex 6f99f49..1c9ba82 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -95,10 +95,12 @@ public class OverView : FontDisplay { 				bool selected = tabs.select_char (n); 				GlyphCanvas canvas; 				Glyph g = glyph_collection.get_current (); +				GlyphTab glyph_tab;				 				 				if (!selected) {+					glyph_tab = new GlyphTab (glyph_collection); 					canvas = MainWindow.get_glyph_canvas ();-					tabs.add_tab (g, true, glyph_collection);+					tabs.add_tab (glyph_tab, true, glyph_collection); 					canvas.set_current_glyph_collection (glyph_collection); 					set_initial_zoom (); 					PenTool.update_orientation ();@@ -176,6 +178,7 @@ public class OverView : FontDisplay { 		Glyph glyph; 		GlyphCollection glyph_collection; 		GlyphCanvas canvas;+		GlyphTab glyph_tab;  		 		glyph_collection = MainWindow.get_current_glyph_collection (); 		name.append_unichar (character);@@ -183,10 +186,10 @@ public class OverView : FontDisplay { 				 		if (!selected) { 			glyph_collection = add_character_to_font (character);-			+			glyph_tab = new GlyphTab (glyph_collection); 			glyph = glyph_collection.get_current (); 			glyph.layers.add_layer (new Layer ());-			tabs.add_tab (glyph, true, glyph_collection);+			tabs.add_tab (glyph_tab, true, glyph_collection); 			 			selected_items.add (glyph_collection); 			diff --git a/libbirdfont/TabContent.vala b/libbirdfont/TabContent.valaindex 4a1aa59..8ec8b3b 100644--- a/libbirdfont/TabContent.vala+++ b/libbirdfont/TabContent.vala@@ -427,7 +427,7 @@ public class TabContent : GLib.Object { 		TabContent.key_release (Key.LOGO_LEFT); 		TabContent.key_release (Key.LOGO_RIGHT); -		if (MainWindow.get_current_display () is Glyph) {+		if (MainWindow.get_current_display () is GlyphTab) { 			TabContent.key_release ((uint) ' '); 		} 	}diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex 0084a50..bbe7538 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -125,7 +125,7 @@ public class Toolbox : GLib.Object  { 			current_set = (ToolCollection) background_tools; 		} else if (tab_name == "Themes") { 			current_set = (ToolCollection) theme_tools;-		} else if (t != null && ((!) t).get_display () is Glyph) {+		} else if (t != null && ((!) t).get_display () is GlyphTab) { 			current_set = (ToolCollection) drawing_tools; 		} else { 			current_set = (ToolCollection) file_tools;diff --git a/libbirdfont/VersionList.vala b/libbirdfont/VersionList.valaindex 926d64e..14779cf 100644--- a/libbirdfont/VersionList.vala+++ b/libbirdfont/VersionList.vala@@ -234,7 +234,7 @@ public class VersionList : GLib.Object {  			tab = (!) tn; -			if (! (tab.get_display () is Glyph)) {+			if (! (tab.get_display () is GlyphTab)) { 				continue;  			} 			

Contact

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