From 31b5862c638db8b83a887d988532e61e30eaeebd Mon Sep 17 00:00:00 2001 From: 9and3r <9and3r@gmail.com> Date: Thu, 31 Jul 2014 15:36:54 +0200 Subject: [PATCH] Fixed bug. Scroll when is enough space for all items --- mopidy_touchscreen/list_view.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mopidy_touchscreen/list_view.py b/mopidy_touchscreen/list_view.py index 746fbb8..7065159 100644 --- a/mopidy_touchscreen/list_view.py +++ b/mopidy_touchscreen/list_view.py @@ -74,19 +74,20 @@ class ListView(): self.move_to(1) def move_to(self, direction): - if direction == 1: - self.current_item += self.max_rows - if self.current_item + self.max_rows > self.list_size: - self.current_item = self.list_size - self.max_rows - self.load_new_item_position(self.current_item) - self.screen_objects.get_touch_object("scrollbar").set_item(self.current_item) - elif direction == -1: - self.current_item -= self.max_rows - if self.current_item < 0: - self.current_item = 0 - self.load_new_item_position(self.current_item) - self.screen_objects.get_touch_object("scrollbar").set_item(self.current_item) - self.set_selected(self.selected) + if self.scrollbar: + if direction == 1: + self.current_item += self.max_rows + if self.current_item + self.max_rows > self.list_size: + self.current_item = self.list_size - self.max_rows + self.load_new_item_position(self.current_item) + self.screen_objects.get_touch_object("scrollbar").set_item(self.current_item) + elif direction == -1: + self.current_item -= self.max_rows + if self.current_item < 0: + self.current_item = 0 + self.load_new_item_position(self.current_item) + self.screen_objects.get_touch_object("scrollbar").set_item(self.current_item) + self.set_selected(self.selected) def set_selected(self, selected): for number in self.selected: