2025-08-03 19:25:18 +02:00
|
|
|
from .item_selection import ItemSelection
|
2025-08-03 20:09:55 +02:00
|
|
|
import pygame
|
|
|
|
|
from .colors import *
|
2025-08-03 19:25:18 +02:00
|
|
|
|
|
|
|
|
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,
|
2025-08-03 20:09:55 +02:00
|
|
|
(self.screen.get_height() - self.clip_selection.surface.get_height())/2))
|
|
|
|
|
else:
|
|
|
|
|
if self.track_selection.selected_item_srf is not None:
|
|
|
|
|
self.screen.blit(self.track_selection.selected_item_srf,
|
|
|
|
|
((self.screen.get_width()/4+10), self.screen.get_height() - 45))
|
|
|
|
|
pygame.draw.rect(self.screen, color_primary_light,
|
|
|
|
|
(self.screen.get_width()/4, self.screen.get_height() - 50, self.max_name_width+20, 40), 2)
|
|
|
|
|
if self.clip_selection.selected_item_srf is not None:
|
|
|
|
|
self.screen.blit(self.clip_selection.selected_item_srf,
|
|
|
|
|
((self.screen.get_width()/4 + self.max_name_width) + 110, self.screen.get_height() - 45))
|
|
|
|
|
pygame.draw.rect(self.screen, color_primary_light,
|
|
|
|
|
((self.screen.get_width()/4 + self.max_name_width) + 100, self.screen.get_height() - 50,
|
|
|
|
|
self.max_name_width+20, 40), 2)
|