from dataclasses import dataclass, field
from enum import Enum, auto
from typing import Optional
from jdxi_editor.ui.widgets.spec import ComboBoxSpec, SliderSpec, SwitchSpec
[docs]
class OscillatorFeature(Enum):
"""Oscillator capability flags; defined here to avoid circular import (layout.spec must not import from digital)."""
[docs]
class FilterFeature(Enum):
"""Oscillator capability flags; defined here to avoid circular import (layout.spec must not import from digital)."""
[docs]
FILTER_RESONANCE = auto()
[docs]
FILTER_CUTOFF_KEYFOLLOW = auto()
[docs]
FILTER_DEPTH_VELOCITY_SENS = auto()
@dataclass
[docs]
class LayoutSpec:
"""Layout of Widgets"""
[docs]
controls: Optional[list[SwitchSpec | SliderSpec | ComboBoxSpec]] = None
[docs]
combos: Optional[list[ComboBoxSpec | None]] = None
[docs]
adsr: Optional[dict] = None
[docs]
sliders: Optional[list[SliderSpec | None]] = None
[docs]
switches: Optional[list[SwitchSpec | None]] = None
[docs]
misc: Optional[list[SwitchSpec | SliderSpec | ComboBoxSpec]] = None
[docs]
features: set[OscillatorFeature] = field(default_factory=set)
[docs]
feature_tabs: set[OscillatorFeature] = field(default_factory=set)
[docs]
def get(self, item, fallback=None):
"""Dict-like access: return the attribute named `item`, else `fallback`."""
if hasattr(self, item):
return getattr(self, item)
return fallback