from textual.containers import Container


class Chunk(Container):
    """
    base class for creating draggable views in the timeline for MIDI, Audio, etc...
    """
    
    DEFAULT_CSS = """
    Chunk {
        border: tab $surface;
        background: $surface-darken-1;
        dock: left;
    }
    """
    
    def __init__(self, chunk_name: str = "Chunk", bar_pos: float = 0.0):
        super().__init__()
        self.chunk_name = chunk_name
        self.border_title = chunk_name
        self.bar_pos = bar_pos
        self.update_offset()
        
    def update_offset(self, timeline=None):
        if timeline == None:
            timeline = self.app.query_one("#timeline")
        self.offset = (timeline.bar_offset * self.bar_pos * 4, 0)
        
    def calculate_size(self):
        pass