Clone in a terminal:
Commit 0e55d11
Johan Mattsson - 2015-12-23T16:24:06+00:00
0e55d118e6b88857c78f56692a8f06b2b916f9adjohan.mattsson.m@gmail.com

Fix selection in overview

Changed files (2)

Diff

diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex c1d8cb2..197f1f3 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -559,6 +559,11 @@ public class OverView : FontDisplay { 				item.generate_graphics (); 				item.x = x; 				item.y = y;+				+				if (glyphs != null) {+					item.selected = (selected_items.index_of ((!) glyphs) != -1);+				}+				 				visible_items.add (item); 				index++; 			}@@ -590,6 +595,10 @@ public class OverView : FontDisplay { 				item = visible_items.get (i); 				glyphs = f.get_glyph_collection_by_name ((!) item.character.to_string ()); 				item.set_glyphs (glyphs);+				+				if (glyphs != null) {+					item.selected = (selected_items.index_of ((!) glyphs) != -1);+				} 			}  			for (int i = 0; i < visible_size; i++) {@@ -602,25 +611,17 @@ public class OverView : FontDisplay { 		y = OverViewItem.margin; 		 		visible_size = visible_items.size;-		int selected_index;-		bool selected_item; 		double full_width = OverViewItem.full_width (); 		 		for (int i = 0; i < visible_size; i++) { 			item = visible_items.get (i); -			selected_item = false;-			-			if (glyphs != null) {-				selected_index = selected_items.index_of ((!) glyphs);-				selected_item = (selected_index != -1);+			if (item.glyphs == null) {+				item.selected |= (i == selected); 			} 			 			item.adjust_scale (); 			-			selected_item |= (i == selected);-			item.selected = selected_item;-			 			item.x = x + view_offset_x; 			item.y = y + view_offset_y; 			@@ -1292,7 +1293,6 @@ public class OverView : FontDisplay { 				 				if (KeyBindings.has_shift ()) { 					if (selected_item.glyphs != null) {-						 						selected_index = selected_items.index_of ((!) selected_item.glyphs); 						if (selected_index == -1) { 							selected_items.add ((!) selected_item.glyphs);@@ -1303,6 +1303,8 @@ public class OverView : FontDisplay { 							selected_item = get_selected_item (); 						} 					}+					+					update = true; 				} else { 					selected_items.clear (); 					if (selected_item.glyphs != null) {@@ -1311,7 +1313,7 @@ public class OverView : FontDisplay { 				} 				 				if (is_null(i.version_menu)) {-					update = false;+					update = true; 				} else { 					update = !i.version_menu.menu_visible; 				}diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex 36db439..dce58c4 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -25,7 +25,11 @@ public class OverViewItem : GLib.Object { 	public GlyphCollection? glyphs; 	public double x; 	public double y;-	public bool selected = false;+	+	public bool selected {+		get; set;+	}+	 	public CharacterInfo info; 		 	public static double DEFAULT_WIDTH = 100;@@ -219,10 +223,6 @@ public class OverViewItem : GLib.Object { 		return s.str; 	} 	-	public void set_selected (bool s) {-		selected = s;-	}-	 	public static double full_width () { 		return width + margin; 	}@@ -426,6 +426,10 @@ public class OverViewItem : GLib.Object { 		return glyphs != null; 	} 	+	public void clear_cache () {+		cache = null;+	}+	 	public void draw_label_background (Context cr) { 		Surface cache; 		bool icon;

Contact

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