Source code for jdxi_editor.ui.widgets.pattern.sequencer_button
"""
Sequencer step button with row, column, and note data.
Note data is canonical in note_spec (NoteButtonSpec); note, note_duration,
note_velocity are properties that read/write through it.
"""
from typing import Optional
from PySide6.QtWidgets import QPushButton, QWidget
from jdxi_editor.ui.style import JDXiUIDimensions
from picomidi.ui.widget.button.note import NoteButtonEvent
[docs]
class SequencerButton(QPushButton):
"""A checkable step button for the pattern sequencer with row, column, and note state."""
def __init__(
self,
row: int,
column: int,
parent: Optional[QWidget] = None,
):
super().__init__(parent)
self.setCheckable(True)
self.setFixedSize(
JDXiUIDimensions.SEQUENCER.LARGE_SQUARE_SIZE,
JDXiUIDimensions.SEQUENCER.LARGE_SQUARE_SIZE,
)
@property
@note.setter
def note(self, value: Optional[int]) -> None:
self.note_spec.note = value
@property
[docs]
def note_duration(self) -> Optional[float]:
if not self.note_spec.is_active or self.note_spec.duration_ms is None:
return None
return float(self.note_spec.duration_ms)
@note_duration.setter
def note_duration(self, value: Optional[float]) -> None:
self.note_spec.duration_ms = int(value) if value is not None else 120
@property
[docs]
def note_velocity(self) -> Optional[int]:
return self.note_spec.velocity if self.note_spec.is_active else None
@note_velocity.setter
def note_velocity(self, value: Optional[int]) -> None:
self.note_spec.velocity = value if value is not None else 100
# Aliases for manager compatibility (duration/velocity/duration_ms)
@property
@duration.setter
def duration(self, value: Optional[float]) -> None:
self.note_duration = value
@property
[docs]
def duration_ms(self) -> Optional[float]:
"""Alias for note_duration (ms) for pattern/manager compatibility."""
return self.note_duration
@duration_ms.setter
def duration_ms(self, value: Optional[float]) -> None:
self.note_duration = value
@property
@velocity.setter
def velocity(self, value: Optional[int]) -> None:
self.note_velocity = value