diff --git a/mopidy_touchscreen/graphic_utils/background_manager.py b/mopidy_touchscreen/graphic_utils/background_manager.py index 9836bba..f71d75d 100644 --- a/mopidy_touchscreen/graphic_utils/background_manager.py +++ b/mopidy_touchscreen/graphic_utils/background_manager.py @@ -17,7 +17,7 @@ class DynamicBackground: self.update = True self.screen_change_percent = 100 - def draw_background(self): + def draw_background(self, rects=None): if self.image_loaded: if self.screen_change_percent < 255: self.surface.fill((0, 0, 0)) @@ -26,7 +26,7 @@ class DynamicBackground: self.surface_image.set_alpha(self.screen_change_percent) self.surface.blit(self.surface_image_last, (0, 0)) self.surface.blit(self.surface_image, (0, 0)) - self.screen_change_percent += 5 + self.screen_change_percent += 50 self.update = True return self.surface.copy() diff --git a/mopidy_touchscreen/graphic_utils/screen_objects.py b/mopidy_touchscreen/graphic_utils/screen_objects.py index 98f9ce0..fac4191 100644 --- a/mopidy_touchscreen/graphic_utils/screen_objects.py +++ b/mopidy_touchscreen/graphic_utils/screen_objects.py @@ -21,15 +21,15 @@ class ScreenObjectsManager: def set_object(self, key, add_object): self.text_objects[key] = add_object - def get_update_rects(self): + def get_update_rects(self, all): update_rects = [] for key in self.text_objects: object = self.text_objects[key] - if hasattr(object, "fit_horizontal") and not object.fit_horizontal: + if all or (hasattr(object, "fit_horizontal") and not object.fit_horizontal): update_rects.append(object.rect_in_pos) for key in self.touch_objects: object = self.touch_objects[key] - if hasattr(object, "fit_horizontal") and not object.fit_horizontal: + if all or (hasattr(object, "fit_horizontal") and not object.fit_horizontal): update_rects.append(object.rect_in_pos) return update_rects diff --git a/mopidy_touchscreen/graphic_utils/view_pager.py b/mopidy_touchscreen/graphic_utils/view_pager.py index 196b7f3..354eb14 100644 --- a/mopidy_touchscreen/graphic_utils/view_pager.py +++ b/mopidy_touchscreen/graphic_utils/view_pager.py @@ -31,13 +31,21 @@ class ViewPager: self.update = True def should_update(self): - if self.update: - return BaseScreen.update_all + if self.update or len(self.update_rects) > 0: + return BaseScreen.update_partial else: - if len(self.update_rects)>0: - return BaseScreen.update_partial - else: - return BaseScreen.no_update + return BaseScreen.no_update + + def set_update_rects(self, rects): + if self.update or self.direction != 0: + rects += self.objets_manager[0].get_update_rects(True) + rects += self.objets_manager[1].get_update_rects(True) + rects += self.objets_manager[2].get_update_rects(True) + self.shift() + rects += self.objets_manager[0].get_update_rects(True) + rects += self.objets_manager[1].get_update_rects(True) + rects += self.objets_manager[2].get_update_rects(True) + rects += self.update_rects def shift(self): if self.direction == 1: @@ -77,8 +85,6 @@ class ViewPager: self.objets_manager[0].render(screen) else: self.update = False - self.update_rects = self.objets_manager[1].get_update_rects() - #if update_type == BaseScreen.update_partial: - #rects += self.update_rects + self.update_rects = self.objets_manager[1].get_update_rects(False) self.objets_manager[1].render(screen) \ No newline at end of file diff --git a/mopidy_touchscreen/screen_manager.py b/mopidy_touchscreen/screen_manager.py index 50bc92f..76b5a62 100644 --- a/mopidy_touchscreen/screen_manager.py +++ b/mopidy_touchscreen/screen_manager.py @@ -152,23 +152,21 @@ class ScreenManager(): def update(self, screen): update_type = self.get_update_type() if update_type != BaseScreen.no_update: - rects = [] if self.keyboard: surface = self.background.draw_background() self.keyboard.update(surface) else: + surface = self.background.draw_background() if update_type == BaseScreen.update_partial: + rects = [] self.screens[self.current_screen].set_update_rects(rects) - surface = self.background.draw_background() - else: - surface = self.background.draw_background() self.screens[self.current_screen].\ update(surface, update_type) if update_type == BaseScreen.update_all: surface.blit(self.down_bar, (0, self.size[1] - self.base_size)) self.down_bar_objects.render(surface) - if update_type == BaseScreen.update_all or len(rects) < 1: + if update_type == BaseScreen.update_all: screen.blit(surface, (0, 0)) pygame.display.flip() else: diff --git a/mopidy_touchscreen/screens/main_screen.py b/mopidy_touchscreen/screens/main_screen.py index 7319606..d6225a3 100644 --- a/mopidy_touchscreen/screens/main_screen.py +++ b/mopidy_touchscreen/screens/main_screen.py @@ -73,7 +73,7 @@ class MainScreen(BaseScreen): self.progress_show = False - def should_update(self, rects): + def should_update(self): update = self.view_pager.should_update() if update is not BaseScreen.no_update: return update @@ -93,8 +93,9 @@ class MainScreen(BaseScreen): def set_update_rects(self, rects): progress = self.update_progress() if progress is not None: - self.update_keys.append("time_progress") + self.update_keys = [("time_progress")] rects.append(progress.rect_in_pos) + self.view_pager.set_update_rects(rects) def update(self, screen, update_type): if update_type == BaseScreen.update_all: @@ -106,7 +107,7 @@ class MainScreen(BaseScreen): if update_type == BaseScreen.update_partial \ and self.track is not None: for key in self.update_keys: - object = self.touch_text_manager.get_object(key) + object = self.touch_text_manager.get_touch_object(key) object.update() object.render(screen) self.view_pager.render(screen, update_type) @@ -186,12 +187,10 @@ class MainScreen(BaseScreen): def track_started(self, track): self.next_track = track - self.update_keys = [] self.image = None self.view_pager.notify_changed() if self.previous_track is not None and track.uri == self.previous_track.uri: - logger.error("sartu naiz") self.view_pager.change_to_page(-1) image_view = self.view_pager.objets_manager[0].get_object("cover_image") else: diff --git a/mopidy_touchscreen/screens/playlist_screen.py b/mopidy_touchscreen/screens/playlist_screen.py index ac2dd79..0a717d8 100644 --- a/mopidy_touchscreen/screens/playlist_screen.py +++ b/mopidy_touchscreen/screens/playlist_screen.py @@ -28,7 +28,7 @@ class PlaylistScreen(BaseScreen): def update(self, screen, update_type): update_all = (update_type == BaseScreen.update_all) - self.list.render(screen, update_all) + self.list_view.render(screen, update_all) def playlists_loaded(self): self.selected_playlist = None