The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix selection in overview

These changes was commited to the Birdfont repository Wed, 23 Dec 2015 16:24:06 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Wed, 23 Dec 2015 16:24:06 +0000]

Updated Files

libbirdfont/OverView.vala
libbirdfont/OverViewItem.vala
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -559,6 +559,11 @@ 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 @@ 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,24 +611,16 @@ 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 @@ 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 @@ selected_item = get_selected_item (); } } + + update = true; } else { selected_items.clear (); if (selected_item.glyphs != null) { @@ -1311,7 +1313,7 @@ } if (is_null(i.version_menu)) { - update = false; + update = true; } else { update = !i.version_menu.menu_visible; }
--- a/libbirdfont/OverViewItem.vala +++ b/libbirdfont/OverViewItem.vala @@ -25,7 +25,11 @@ 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; @@ -217,10 +221,6 @@ s.append_unichar (character); return s.str; - } - - public void set_selected (bool s) { - selected = s; } public static double full_width () { @@ -424,6 +424,10 @@ bool has_menu () { return glyphs != null; + } + + public void clear_cache () { + cache = null; } public void draw_label_background (Context cr) {