making channel controls interactable

This commit is contained in:
2026-01-14 14:43:57 +11:00
parent d757b839d7
commit 7ca336c321
11 changed files with 69 additions and 18 deletions

View File

@@ -4,6 +4,8 @@ from textual.widgets import Checkbox, Input, Static
from textual_slider import Slider
from textual import on, events
class Channel(VerticalGroup):
DEFAULT_CSS = """
@@ -44,23 +46,39 @@ class Channel(VerticalGroup):
}
"""
def __init__(self, channel_name: str = "", muted: bool = False, solo: bool = False, pan: float = 0, volume: float = 0):
def __init__(self, channel_index: int, channel_name: str = "", muted: bool = False, solo: bool = False, pan: float = 0, volume: float = 0):
super().__init__()
self.channel_index = channel_index
self.channel_name = channel_name
self.muted = muted
self.solo = solo
self.pan = pan
self.volume = volume
def on_slider_changed(self, event: Slider.Changed):
if event.slider.id == "volume":
self.volume = round(event.value, 2)
self.query_one("#volume-text").update(f"Volume ({self.volume}Db):")
elif event.slider.id == "pan":
self.pan = round(event.value)
pan_text = self.query_one("#pan-text")
if self.pan == 0:
pan_text.update("Pan (center):")
elif self.pan < 0:
pan_text.update(f"Pan ({-self.pan}% left):")
elif self.pan > 0:
pan_text.update(f"Pan ({self.pan}% right):")
def compose(self) -> ComposeResult:
yield Input(placeholder="Channel Name", compact=True, id="name", value=self.channel_name)
with Horizontal(classes="channel-slider"):
yield Static("Pan (center):")
yield Slider(-100, 100, step=1, value=self.pan)
yield Static("Pan (center):", id="pan-text")
yield Slider(-100, 100, step=1, value=self.pan, id="pan")
with Horizontal(classes="channel-slider"):
yield Static("Volume (+ 0Db):")
yield Slider(-15, 15, step=0.1, value=self.volume)
yield Static("Volume (0Db):", id="volume-text")
yield Slider(-15, 15, step=0.1, value=self.volume, id="volume")
with Horizontal(id="channel-buttons"):
yield Checkbox("Mute", compact=True, id="mute", tooltip="Mute this track", value=self.muted)

View File

@@ -10,9 +10,10 @@ class Sidebar(Vertical):
Sidebar {
dock: left;
background: $surface;
width: 40;
width: 43;
border-right: tall $surface-lighten-1;
padding: 1;
margin-top: 1;
#add-channel {
min-width: 100%;
@@ -23,8 +24,9 @@ class Sidebar(Vertical):
def compose(self) -> ComposeResult:
with VerticalScroll(id="channels"):
for channel in self.app.project.channels:
for i, channel in enumerate(self.app.project.channels):
yield Channel(
i,
channel.name,
channel.mute,
channel.solo,

View File

@@ -95,8 +95,6 @@ class Timeline(Vertical):
for channel in self.app.project.channels:
self.notify(str(channel))
with TimelineRow():
for chunk in channel.chunks:
if chunk.chunk_type == ChunkType.CHUNK:

View File

@@ -0,0 +1 @@
from textual.widgets import Tabs, Tab