"""
MIDI Player visual tokens and player-scoped stylesheets.
Chrome comes from AppEditorStyle; this module adds timeline / mute / step helpers.
Red (ACCENT) is reserved for active/selected/playhead — not idle chrome.
"""
from __future__ import annotations
from typing import Optional
from PySide6.QtGui import QColor
from jdxi_editor.ui.style.editor_style import AppEditorStyle
[docs]
class MidiPlayerStyle(AppEditorStyle):
"""MIDI Player extensions on shared restrained editor chrome."""
[docs]
TRACK_HEIGHT = 48 # two lines of 20 px controls
[docs]
TRACK_LABEL_WIDTH = 110
[docs]
TRACK_NUMBER_WIDTH = 18
[docs]
TRACK_CHANNEL_WIDTH = 52
# Muted timeline channel colours (RGBA)
[docs]
CHANNEL_COLORS = {
0: (180, 70, 70, 130), # Digital 1 — muted red
1: (200, 140, 60, 130), # Digital 2 — amber
2: (50, 140, 150, 130), # Analog — teal
3: (70, 150, 110, 120),
4: (90, 130, 160, 120),
5: (100, 120, 180, 120),
6: (90, 100, 170, 120),
7: (130, 90, 170, 120),
8: (150, 90, 150, 120),
9: (120, 80, 160, 140), # Drums — muted purple
10: (110, 110, 110, 120),
11: (60, 120, 80, 120),
12: (130, 100, 70, 120),
13: (160, 90, 120, 120),
14: (80, 120, 150, 120),
15: (140, 110, 80, 120),
}
@classmethod
@classmethod
[docs]
def spin_box_stylesheet(cls) -> str:
"""Channel spin: grey idle top border; accent when focused."""
return f"""
QSpinBox {{
background-color: {cls.SURFACE_ALT};
border: none;
border-top: 2px solid {cls.BORDER};
border-radius: 0;
padding: 1px;
color: {cls.TEXT};
font-size: {cls.FONT_CONTROL};
}}
QSpinBox:focus {{
border-top: 2px solid {cls.ACCENT};
}}
"""
@classmethod
[docs]
def track_name_stylesheet(cls, text: str = None) -> str:
""":param text: the name's colour; the player's own text colour if None"""
return f"""
QLineEdit {{
background-color: transparent;
border: none;
color: {text or cls.TEXT};
font-size: {cls.FONT_TRACK_NAME};
font-weight: 600;
}}
"""
[docs]
SOLO = "#C88C3C" # amber: soloed track
@classmethod
[docs]
def channel_mute_stylesheet(cls) -> str:
"""
Channel mute squares: grey when playing, red when muted; channels the
file does not use (property unused=true) are dimmed.
"""
return f"""
QPushButton {{
background-color: {cls.SURFACE_ALT};
border: 1px solid {cls.BORDER};
border-radius: 3px;
color: {cls.TEXT};
padding: 0;
}}
QPushButton[unused="true"] {{
background-color: {cls.BACKGROUND};
color: {cls.BORDER_HOVER};
}}
QPushButton[part="true"] {{
border: 1px solid {cls.BORDER_HOVER};
font-weight: bold;
}}
QPushButton:hover {{
border-color: {cls.BORDER_HOVER};
}}
QPushButton:checked {{
background-color: {cls.ACCENT};
border-color: {cls.ACCENT};
color: {cls.TEXT};
}}
QPushButton[silenced="true"] {{
border: 1px solid {cls.ACCENT};
color: {cls.ACCENT};
}}
"""
@classmethod
[docs]
def channel_solo_stylesheet(cls) -> str:
"""Channel solo squares: like the mute ones, amber (SOLO) when on."""
return cls.channel_mute_stylesheet().replace(cls.ACCENT, cls.SOLO)
@classmethod
[docs]
def track_toggle_stylesheet(cls, checked_color: str) -> str:
"""Track mute/solo: quiet when off, filled with *checked_color* when on."""
return f"""
QPushButton {{
background-color: transparent;
border: 1px solid {cls.BORDER};
border-radius: 3px;
}}
QPushButton:hover {{
border-color: {cls.BORDER_HOVER};
}}
QPushButton:checked {{
background-color: {checked_color};
border-color: {checked_color};
}}
"""
@classmethod
[docs]
def track_secondary_stylesheet(cls, text: str = None) -> str:
""":param text: the caption's colour; the player's own if None"""
return f"""
QLabel {{
color: {text or cls.TEXT_SECONDARY};
font-size: {cls.FONT_TRACK_SECONDARY};
}}
"""
# Pattern step cells — muted on-state; accent only for playhead / selection
[docs]
STEP_ON_HOVER = "#C85A5A"
[docs]
STEP_OFF = AppEditorStyle.SURFACE_ALT
[docs]
STEP_OFF_HOVER = AppEditorStyle.SURFACE
[docs]
PLAYHEAD = "#F2F2F2" # light outline on the playing step
# Pattern rows 0-3: Digital 1, Digital 2, Analog, Drums
[docs]
PART_COLORS = {0: "#B44646", 1: "#C88C3C", 2: "#3296A0", 3: "#7850A0"}
@classmethod
[docs]
class PatternEditorStyle(MidiPlayerStyle):
"""Pattern Editor chrome — same tokens as Midi Player."""