The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix scroll in overview on Mac OS

These changes was commited to the Birdfont repository Fri, 30 Oct 2015 11:00:32 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Fri, 30 Oct 2015 11:00:32 +0000]

Updated Files

libbirdfont/AbstractMenu.vala
libbirdfont/OverView.vala
--- a/libbirdfont/AbstractMenu.vala +++ b/libbirdfont/AbstractMenu.vala @@ -77,18 +77,19 @@ ToolItem tm; unichar lower_keyval = ((unichar) keyval).tolower (); + display = current_display.get_name (); + + if (current_display is Glyph) { + display = "Glyph"; + } + foreach (MenuItem item in sorted_menu_items) { - if (item.key.tolower () == lower_keyval && item.modifiers == KeyBindings.modifier) { + if (item.key.tolower () == lower_keyval + && item.modifiers == KeyBindings.modifier + && item.in_display (display)) { - display = current_display.get_name (); - - if (current_display is Glyph) { - display = "Glyph"; - } - if (!current_display.needs_modifier () || item.modifiers != NONE) { if (!SettingsDisplay.update_key_bindings - && item.in_display (display) && !(item is ToolItem)) { item.action (); return;
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -304,23 +304,36 @@ return true; } + public bool all_characters_in_view () { + double length; + Font f; + + if (all_available) { + f = BirdFont.get_current_font (); + length = f.length (); + } else { + length = glyph_range.length (); + } + + return length < items_per_row * rows; + } + public void move_up () { first_visible -= items_per_row; selected += items_per_row; if (first_visible < 0) { + selected -= items_per_row; first_visible = 0; view_offset_y = 0; - - while (selected < 0) { - selected += items_per_row; - } - } + } } public void move_down () { - first_visible += items_per_row; - selected -= items_per_row; + if (!at_bottom ()) { + first_visible += items_per_row; + selected -= items_per_row; + } } public override void scroll_wheel (double x, double y, double dx, double dy) { @@ -335,18 +348,22 @@ } } else { if (at_bottom ()) { - if (view_offset_y > -2 * OverViewItem.height) { + if (view_offset_y > -2 * OverViewItem.height && !all_characters_in_view ()) { view_offset_y += pixel_delta; } } else { view_offset_y += pixel_delta; while (view_offset_y < -OverViewItem.height) { - view_offset_y += OverViewItem.height; - move_down (); + view_offset_y += OverViewItem.height; + move_down (); } } } - + + if (view_offset_y < -2 * OverViewItem.height) { + view_offset_y = -2 * OverViewItem.height; + } + update_item_list (); update_scrollbar (); hide_menu (); @@ -450,6 +467,7 @@ public void display_all_available_glyphs () { all_available = true; + view_offset_y = 0; first_visible = 0; selected = 0; @@ -699,7 +717,8 @@ public void scroll_top () { selected = 0; first_visible = 0; - + view_offset_y = 0; + update_item_list (); if (visible_items.size != 0) {