Files
SantoscopeUI/beatplayer.py

40 lines
1.9 KiB
Python

from .item_selection import ItemSelection
import pygame
from .colors import *
from .fonts import *
class BeatPlayer:
def __init__(self, screen):
self.screen = screen
self.max_name_width = 200
self.clip_selection = ItemSelection(self.max_name_width)
self.track_selection = ItemSelection(self.max_name_width)
self.show_selection = False
def set_clip_names(self, clips):
self.clip_selection.set_items(clips)
def set_track_names(self, tracks):
self.track_selection.set_items(tracks)
def update(self):
if self.show_selection:
self.track_selection.update()
self.clip_selection.update()
self.screen.blit(self.track_selection.surface, ((self.screen.get_width()/4),
(self.screen.get_height() - self.track_selection.surface.get_height())/2))
self.screen.blit(self.clip_selection.surface, ((self.screen.get_width()/4 + self.max_name_width) + 100,
(self.screen.get_height() - self.clip_selection.surface.get_height())/2))
else:
selected_track = self.track_selection.get_selected_item()
selected_clip = self.clip_selection.get_selected_item()
if len(selected_track) > 15: selected_track = selected_track[0:13] + '...'
if len(selected_clip) > 30: selected_clip = selected_clip[0:28] + '...'
track_surface = font_helvetica16.render(f"{selected_track}",
False, color_primary_dark)
clip_surface = font_helvetica16.render(f"/ {selected_clip}",
False, color_primary_dark)
self.screen.blit(clip_surface, (self.screen.get_width()/2, 15))
self.screen.blit(track_surface, (self.screen.get_width()/2-track_surface.get_width()-10, 15))