From 5c6aa015eb63bdd9b48417f943eff6b926e47e5d Mon Sep 17 00:00:00 2001 From: 9and3r <9and3r@gmail.com> Date: Fri, 1 Aug 2014 12:41:54 +0200 Subject: [PATCH] .gitignore update --- .gitignore | 1 + mopidy_touchscreen/.idea/workspace.xml | 187 +++++++++++-------------- mopidy_touchscreen/library_screen.py | 16 ++- mopidy_touchscreen/main_screen.py | 30 +++- mopidy_touchscreen/screen_manager.py | 3 + mopidy_touchscreen/screen_objects.py | 1 + mopidy_touchscreen/touch_manager.py | 1 - mopidy_touchscreen/touch_screen.py | 3 + 8 files changed, 128 insertions(+), 114 deletions(-) diff --git a/.gitignore b/.gitignore index 79e0d34..799bff1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ MANIFEST build/ dist/ +mopidy_touchscreen/.idea/ diff --git a/mopidy_touchscreen/.idea/workspace.xml b/mopidy_touchscreen/.idea/workspace.xml index 263f599..727b922 100644 --- a/mopidy_touchscreen/.idea/workspace.xml +++ b/mopidy_touchscreen/.idea/workspace.xml @@ -22,32 +22,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -57,15 +32,15 @@ @@ -101,7 +76,6 @@ - @@ -122,6 +96,7 @@ + @@ -271,13 +246,13 @@ - + - + @@ -285,11 +260,11 @@ - + - + @@ -312,13 +287,29 @@ + + + + + + + + + + + + + + + + + + - - - + @@ -441,13 +432,6 @@ - - - - - - - @@ -455,78 +439,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mopidy_touchscreen/library_screen.py b/mopidy_touchscreen/library_screen.py index 212d037..c37d55d 100644 --- a/mopidy_touchscreen/library_screen.py +++ b/mopidy_touchscreen/library_screen.py @@ -50,25 +50,29 @@ class LibraryScreen(): if clicked == 0: self.go_up_directory() else: - self.play_uri(self.library[clicked-1].uri) + self.play_uri(self.library[clicked-1].uri, False) else: - self.play_uri(self.library[clicked].uri) + self.play_uri(self.library[clicked].uri, False) else: if self.current_directory is not None: if clicked == 0: self.go_up_directory() else: if self.library[clicked-1].type == mopidy.models.Ref.TRACK: - self.play_uri(self.library[clicked-1].uri) + self.play_uri(self.library[clicked-1].uri, True) else: self.go_inside_directory(self.library[clicked-1].uri) else: if self.library[clicked].type == mopidy.models.Track: - self.play_uri(self.library[clicked].uri) + self.play_uri(self.library[clicked].uri, True) else: self.go_inside_directory(self.library[clicked].uri) - def play_uri(self, uri): + def play_uri(self, uri, track): self.manager.core.tracklist.clear() - self.manager.core.tracklist.add(uri=uri) + if track: + self.manager.core.tracklist.add(uri=uri) + else: + logger.error(uri) + self.manager.core.tracklist.add(tracks=self.manager.core.library.search(query={'any':'*'}, uris=[uri]).get()[0].tracks) self.manager.core.playback.play() diff --git a/mopidy_touchscreen/main_screen.py b/mopidy_touchscreen/main_screen.py index eed3c69..a81719c 100644 --- a/mopidy_touchscreen/main_screen.py +++ b/mopidy_touchscreen/main_screen.py @@ -24,6 +24,11 @@ class MainScreen(): self.image = None self.artists = None self.touch_text_manager = ScreenObjectsManager() + current_track = self.core.playback.current_track.get() + if current_track is None: + self.track_playback_ended(None, None) + else: + self.track_started(current_track) def update(self, screen): if self.track is not None: @@ -125,17 +130,36 @@ class MainScreen(): width = self.size[0] - self.base_size current = TextItem(self.fonts['base'], MainScreen.get_track_name(self.track), (self.base_size / 2, self.base_size * 2), - (width, self.base_size)) + (width, -1)) self.touch_text_manager.set_object("track_name", current) current = TextItem(self.fonts['base'], MainScreen.get_track_album_name(self.track), (self.base_size / 2, self.base_size * 3), - (width, self.base_size)) + (width, -1)) self.touch_text_manager.set_object("album_name", current) current = TextItem(self.fonts['base'], self.get_artist_string(), (self.base_size / 2, self.base_size * 4), - (width, self.base_size)) + (width, -1)) self.touch_text_manager.set_object("artist_name", current) + def track_playback_ended(self, tl_track, time_position): + + self.image = None + + # There is no cover so it will use all the screen size for the text + width = self.size[0] - self.base_size + + current = TextItem(self.fonts['base'], "Stopped", (self.base_size / 2, self.base_size * 2), + (width, -1)) + self.touch_text_manager.set_object("track_name", current) + + current = TextItem(self.fonts['base'], "", (self.base_size / 2, self.base_size * 3), + (width, -1)) + self.touch_text_manager.set_object("album_name", current) + + current = TextItem(self.fonts['base'], "", (self.base_size / 2, self.base_size * 4), + (width, -1)) + self.touch_text_manager.set_object("artist_name", current) + def load_image(self): size = self.base_size * 4 self.image = pygame.transform.scale( diff --git a/mopidy_touchscreen/screen_manager.py b/mopidy_touchscreen/screen_manager.py index 395d547..7273c59 100644 --- a/mopidy_touchscreen/screen_manager.py +++ b/mopidy_touchscreen/screen_manager.py @@ -131,6 +131,9 @@ class ScreenManager(): self.screens[0].track_started(track.track) self.screens[1].track_started(track) + def track_playback_ended(self, tl_track, time_position): + self.screens[0].track_playback_ended(tl_track, time_position) + def event(self, event): touch_event = self.touch_manager.event(event) if touch_event is not None: diff --git a/mopidy_touchscreen/screen_objects.py b/mopidy_touchscreen/screen_objects.py index bd8364e..bd81c88 100644 --- a/mopidy_touchscreen/screen_objects.py +++ b/mopidy_touchscreen/screen_objects.py @@ -162,6 +162,7 @@ class TouchAndTextItem(TouchObject, TextItem): else: self.box = self.font.render(self.text, True, self.color) if self.active: + #Area h*2 to render letters like g, j, y... surface.blit(self.active_box, self.pos, area=self.rect) else: surface.blit(self.box, self.pos, area=self.rect) diff --git a/mopidy_touchscreen/touch_manager.py b/mopidy_touchscreen/touch_manager.py index 61a5b6b..b65b11c 100644 --- a/mopidy_touchscreen/touch_manager.py +++ b/mopidy_touchscreen/touch_manager.py @@ -30,7 +30,6 @@ class TouchManager(): def event(self, event): if event.type == pygame.MOUSEBUTTONUP: - logger.error(event.button) if event.button == 4: touch_event = TouchEvent(TouchManager.swipe, self.down_pos, self.up_pos, True) touch_event.direction = TouchManager.up diff --git a/mopidy_touchscreen/touch_screen.py b/mopidy_touchscreen/touch_screen.py index b17494f..b945266 100644 --- a/mopidy_touchscreen/touch_screen.py +++ b/mopidy_touchscreen/touch_screen.py @@ -74,6 +74,9 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener): except: traceback.print_exc() + def track_playback_ended(self, tl_track, time_position): + self.screen_manager.track_playback_ended(tl_track, time_position) + def options_changed(self): try: self.screen_manager.options_changed()