mirror of
https://github.com/Febbweiss/mopidy-touchscreen.git
synced 2026-03-04 22:25:39 +00:00
Background transition
This commit is contained in:
@@ -12,13 +12,23 @@ class DynamicBackground:
|
|||||||
self.surface = pygame.Surface(self.size).convert()
|
self.surface = pygame.Surface(self.size).convert()
|
||||||
self.surface.fill((145, 16, 16))
|
self.surface.fill((145, 16, 16))
|
||||||
self.surface_image = pygame.Surface(self.size).convert()
|
self.surface_image = pygame.Surface(self.size).convert()
|
||||||
|
self.surface_image.fill((145, 16, 16))
|
||||||
|
self.surface_image_last = pygame.Surface(self.size).convert()
|
||||||
self.update = True
|
self.update = True
|
||||||
|
self.screen_change_percent = 100
|
||||||
|
|
||||||
def draw_background(self):
|
def draw_background(self):
|
||||||
if self.image_loaded:
|
if self.image_loaded:
|
||||||
return self.surface_image.copy()
|
if self.screen_change_percent < 255:
|
||||||
else:
|
self.surface.fill((0, 0, 0))
|
||||||
return self.surface.copy()
|
self.surface_image_last.set_alpha(
|
||||||
|
255 - self.screen_change_percent)
|
||||||
|
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.update = True
|
||||||
|
return self.surface.copy()
|
||||||
|
|
||||||
def should_update(self):
|
def should_update(self):
|
||||||
if self.update:
|
if self.update:
|
||||||
@@ -31,14 +41,13 @@ class DynamicBackground:
|
|||||||
if image is not None:
|
if image is not None:
|
||||||
image_size = get_aspect_scale_size(image, self.size)
|
image_size = get_aspect_scale_size(image, self.size)
|
||||||
target = pygame.transform.smoothscale(image, image_size)
|
target = pygame.transform.smoothscale(image, image_size)
|
||||||
self.surface_image.fill((0, 0, 0))
|
self.surface_image_last = self.surface_image.copy()
|
||||||
pos = (int((self.size[0] - image_size[0])/2),
|
pos = (int((self.size[0] - image_size[0])/2),
|
||||||
(int(self.size[1] - image_size[1])/2))
|
(int(self.size[1] - image_size[1])/2))
|
||||||
self.surface_image.blit(blur_surf_times(
|
self.surface_image.blit(blur_surf_times(
|
||||||
target, self.size[0]/40, 10), pos)
|
target, self.size[0]/40, 10), pos)
|
||||||
|
self.screen_change_percent = 0
|
||||||
self.image_loaded = True
|
self.image_loaded = True
|
||||||
else:
|
|
||||||
self.image_loaded = False
|
|
||||||
self.update = True
|
self.update = True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,15 +85,28 @@ class MainScreen(BaseScreen):
|
|||||||
def update(self, screen, update_type, rects):
|
def update(self, screen, update_type, rects):
|
||||||
if update_type == BaseScreen.update_all:
|
if update_type == BaseScreen.update_all:
|
||||||
screen.blit(self.top_bar, (0, 0))
|
screen.blit(self.top_bar, (0, 0))
|
||||||
|
self.update_progress(screen, rects)
|
||||||
self.touch_text_manager.render(screen)
|
self.touch_text_manager.render(screen)
|
||||||
if self.image is not None:
|
if self.image is not None:
|
||||||
screen.blit(self.image, (
|
screen.blit(self.image, (
|
||||||
self.base_size / 2, self.base_size +
|
self.base_size / 2, self.base_size +
|
||||||
self.base_size / 2))
|
self.base_size / 2))
|
||||||
|
|
||||||
elif update_type == BaseScreen.update_partial \
|
if update_type == BaseScreen.update_partial \
|
||||||
and self.track is not None:
|
and self.track is not None:
|
||||||
if self.progress_show:
|
|
||||||
|
progress = self.update_progress(screen, rects)
|
||||||
|
if progress is not None:
|
||||||
|
progress.render(screen)
|
||||||
|
rects.append(progress.rect_in_pos)
|
||||||
|
for key in self.update_keys:
|
||||||
|
object = self.touch_text_manager.get_object(key)
|
||||||
|
object.update()
|
||||||
|
object.render(screen)
|
||||||
|
rects.append(object.rect_in_pos)
|
||||||
|
|
||||||
|
def update_progress(self, screen, rects):
|
||||||
|
if self.progress_show:
|
||||||
track_pos_millis = self.core.playback.time_position.get()
|
track_pos_millis = self.core.playback.time_position.get()
|
||||||
new_track_pos = track_pos_millis / 1000
|
new_track_pos = track_pos_millis / 1000
|
||||||
|
|
||||||
@@ -106,13 +119,8 @@ class MainScreen(BaseScreen):
|
|||||||
time.strftime('%M:%S', time.gmtime(
|
time.strftime('%M:%S', time.gmtime(
|
||||||
self.current_track_pos)) +
|
self.current_track_pos)) +
|
||||||
"/" + self.track_duration)
|
"/" + self.track_duration)
|
||||||
progress.render(screen)
|
return progress
|
||||||
rects.append(progress.rect_in_pos)
|
return None
|
||||||
for key in self.update_keys:
|
|
||||||
object = self.touch_text_manager.get_object(key)
|
|
||||||
object.update()
|
|
||||||
object.render(screen)
|
|
||||||
rects.append(object.rect_in_pos)
|
|
||||||
|
|
||||||
def track_started(self, track):
|
def track_started(self, track):
|
||||||
self.update_keys = []
|
self.update_keys = []
|
||||||
|
|||||||
Reference in New Issue
Block a user