diff --git a/mopidy_touchscreen/.idea/workspace.xml b/mopidy_touchscreen/.idea/workspace.xml
index 0215701..ddbc175 100644
--- a/mopidy_touchscreen/.idea/workspace.xml
+++ b/mopidy_touchscreen/.idea/workspace.xml
@@ -23,41 +23,31 @@
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
@@ -65,11 +55,21 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -86,17 +86,17 @@
@@ -324,7 +324,7 @@
-
+
@@ -338,11 +338,11 @@
-
+
-
+
@@ -697,20 +697,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -722,7 +708,6 @@
-
@@ -734,40 +719,56 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mopidy_touchscreen/list_view.py b/mopidy_touchscreen/list_view.py
index 5fa0a2a..b4c1751 100644
--- a/mopidy_touchscreen/list_view.py
+++ b/mopidy_touchscreen/list_view.py
@@ -22,6 +22,7 @@ class ListView():
self.list = []
self.scrollbar = False
self.set_list([])
+ self.selected = []
def set_list(self, item_list):
self.list = item_list
@@ -65,6 +66,11 @@ class ListView():
direction = self.screen_objects.get_touch_object(key).touch(touch_event.current_pos)
if direction != 0:
self.move_to(direction)
+ elif touch_event.type == TouchManager.swipe:
+ if touch_event.direction == TouchManager.up:
+ self.move_to(-1)
+ elif touch_event.direction == TouchManager.down:
+ self.move_to(1)
def move_to(self, direction):
if direction == 1:
@@ -78,4 +84,18 @@ class ListView():
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)
\ No newline at end of file
+ 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:
+ try:
+ self.screen_objects.get_touch_object(str(number)).set_active(False)
+ except KeyError:
+ pass
+ for number in selected:
+ try:
+ self.screen_objects.get_touch_object(str(number)).set_active(True)
+ except KeyError:
+ pass
+ self.selected = selected
\ No newline at end of file
diff --git a/mopidy_touchscreen/screen_manager.py b/mopidy_touchscreen/screen_manager.py
index c1937bd..e727a54 100644
--- a/mopidy_touchscreen/screen_manager.py
+++ b/mopidy_touchscreen/screen_manager.py
@@ -90,6 +90,7 @@ class ScreenManager():
def track_started(self, track):
self.track = track
self.screens[0].track_started(track.track)
+ self.screens[1].track_started(track)
def event(self, event):
touch_event = self.touch_manager.event(event)
diff --git a/mopidy_touchscreen/touch_manager.py b/mopidy_touchscreen/touch_manager.py
index fd27757..c531e8a 100644
--- a/mopidy_touchscreen/touch_manager.py
+++ b/mopidy_touchscreen/touch_manager.py
@@ -23,7 +23,16 @@ class TouchManager():
def event(self, event):
if event.type == pygame.MOUSEBUTTONUP:
- return self.mouse_up(event)
+ if event.button == 4:
+ touch_event = TouchEvent(TouchManager.swipe, self.down_pos, self.up_pos, True)
+ touch_event.direction = TouchManager.up
+ return touch_event
+ elif event.button == 5:
+ touch_event = TouchEvent(TouchManager.swipe, self.down_pos, self.up_pos, True)
+ touch_event.direction = TouchManager.down
+ return touch_event
+ else:
+ return self.mouse_up(event)
elif event.type == pygame.MOUSEBUTTONDOWN:
self.mouse_down(event)
return None
@@ -31,7 +40,7 @@ class TouchManager():
def mouse_down(self, event):
self.down_pos = event.pos
- def mouse_up(self,event):
+ def mouse_up(self, event):
self.up_pos = event.pos
if abs(self.down_pos[0] - self.up_pos[0]) < self.max_move_margin:
if abs(self.down_pos[1] - self.up_pos[1]) < self.max_move_margin:
diff --git a/mopidy_touchscreen/tracklist.py b/mopidy_touchscreen/tracklist.py
index a204cb9..d7e7ba4 100644
--- a/mopidy_touchscreen/tracklist.py
+++ b/mopidy_touchscreen/tracklist.py
@@ -25,4 +25,7 @@ class Tracklist():
self.list_view.set_list(self.tracks_strings)
def touch_event(self, touch_event):
- self.list_view.touch_event(touch_event)
\ No newline at end of file
+ self.list_view.touch_event(touch_event)
+
+ def track_started(self, track):
+ self.list_view.set_selected([self.manager.core.tracklist.index(track).get()])
\ No newline at end of file