mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: draw phrase pool
This commit is contained in:
parent
a6b08a3249
commit
5b0feddbcb
4 changed files with 71 additions and 11 deletions
|
|
@ -98,6 +98,10 @@ pub trait Area<N: Number>: Copy {
|
||||||
[self.x(), self.y(), self.w(), a],
|
[self.x(), self.y(), self.w(), a],
|
||||||
[self.x(), self.y() + a, self.w(), self.h() - a],
|
[self.x(), self.y() + a, self.w(), self.h() - a],
|
||||||
),
|
),
|
||||||
|
Direction::Right => (
|
||||||
|
[self.x(), self.y(), a, self.h()],
|
||||||
|
[self.x() + a, self.y(), self.w() - a, self.h()],
|
||||||
|
),
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -228,6 +232,16 @@ pub trait Layout<E: Engine>: Widget<Engine = E> + Sized {
|
||||||
fn debug (self) -> DebugOverlay<E, Self> {
|
fn debug (self) -> DebugOverlay<E, Self> {
|
||||||
DebugOverlay(self)
|
DebugOverlay(self)
|
||||||
}
|
}
|
||||||
|
fn split <W: Widget<Engine = E>> (
|
||||||
|
self, direction: Direction, amount: E::Unit, other: W
|
||||||
|
) -> Split<E, Self, W> {
|
||||||
|
Split::new(direction, amount, self, other)
|
||||||
|
}
|
||||||
|
fn split_reverse <W: Widget<Engine = E>> (
|
||||||
|
self, direction: Direction, amount: E::Unit, other: W
|
||||||
|
) -> Split<E, W, Self> {
|
||||||
|
Split::new(direction, amount, other, self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Engine, W: Widget<Engine = E>> Layout<E> for W {}
|
impl<E: Engine, W: Widget<Engine = E>> Layout<E> for W {}
|
||||||
|
|
@ -324,6 +338,22 @@ impl Direction {
|
||||||
pub fn is_right (&self) -> bool {
|
pub fn is_right (&self) -> bool {
|
||||||
match self { Self::Right => true, _ => false }
|
match self { Self::Right => true, _ => false }
|
||||||
}
|
}
|
||||||
|
pub fn cw (&self) -> Self {
|
||||||
|
match self {
|
||||||
|
Self::Up => Self::Right,
|
||||||
|
Self::Down => Self::Left,
|
||||||
|
Self::Left => Self::Up,
|
||||||
|
Self::Right => Self::Down,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn ccw (&self) -> Self {
|
||||||
|
match self {
|
||||||
|
Self::Up => Self::Left,
|
||||||
|
Self::Down => Self::Right,
|
||||||
|
Self::Left => Self::Down,
|
||||||
|
Self::Right => Self::Up,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Override X and Y coordinates, aligning to corner, side, or center of area
|
/// Override X and Y coordinates, aligning to corner, side, or center of area
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,18 @@ pub struct Arranger<E: Engine> {
|
||||||
pub sequencer_proxy: SequencerProxy<E>,
|
pub sequencer_proxy: SequencerProxy<E>,
|
||||||
/// Slot for modal dialog displayed on top of app.
|
/// Slot for modal dialog displayed on top of app.
|
||||||
pub modal: Option<Box<dyn ContentComponent<E>>>,
|
pub modal: Option<Box<dyn ContentComponent<E>>>,
|
||||||
|
|
||||||
|
|
||||||
|
pub phrases: Arc<RwLock<PhrasePool<E>>>,
|
||||||
|
pub editor: PhraseEditor<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the tracks and scenes of the composition.
|
/// Represents the tracks and scenes of the composition.
|
||||||
pub struct Arrangement<E: Engine> {
|
pub struct Arrangement<E: Engine> {
|
||||||
/// Name of arranger
|
/// Name of arranger
|
||||||
pub name: Arc<RwLock<String>>,
|
pub name: Arc<RwLock<String>>,
|
||||||
|
/// Collection of phrases.
|
||||||
|
pub phrases: Arc<RwLock<PhrasePool<E>>>,
|
||||||
/// Collection of tracks.
|
/// Collection of tracks.
|
||||||
pub tracks: Vec<Sequencer<E>>,
|
pub tracks: Vec<Sequencer<E>>,
|
||||||
/// Collection of scenes.
|
/// Collection of scenes.
|
||||||
|
|
@ -33,11 +39,12 @@ pub struct Arrangement<E: Engine> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Engine> Arrangement<E> {
|
impl<E: Engine> Arrangement<E> {
|
||||||
pub fn new (name: &str) -> Self {
|
pub fn new (name: &str, phrases: &Arc<RwLock<PhrasePool<E>>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: Arc::new(RwLock::new(name.into())),
|
name: Arc::new(RwLock::new(name.into())),
|
||||||
mode: ArrangerViewMode::Vertical(2),
|
mode: ArrangerViewMode::Vertical(2),
|
||||||
selected: ArrangerFocus::Clip(0, 0),
|
selected: ArrangerFocus::Clip(0, 0),
|
||||||
|
phrases: phrases.clone(),
|
||||||
scenes: vec![],
|
scenes: vec![],
|
||||||
tracks: vec![],
|
tracks: vec![],
|
||||||
focused: false
|
focused: false
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,12 @@ impl ArrangerCli {
|
||||||
let jack = JackClient::Inactive(
|
let jack = JackClient::Inactive(
|
||||||
Client::new("tek_arranger", ClientOptions::NO_START_SERVER)?.0
|
Client::new("tek_arranger", ClientOptions::NO_START_SERVER)?.0
|
||||||
);
|
);
|
||||||
let mut arrangement = Arrangement::new("");
|
|
||||||
let jack_transport = jack.transport();
|
let jack_transport = jack.transport();
|
||||||
let mut transport = TransportToolbar::new(Some(jack_transport));
|
let mut transport = TransportToolbar::new(Some(jack_transport));
|
||||||
|
transport.set_focused(true);
|
||||||
|
let transport = Arc::new(RwLock::new(transport));
|
||||||
|
let phrases = Arc::new(RwLock::new(PhrasePool::new()));
|
||||||
|
let mut arrangement = Arrangement::new("", &phrases);
|
||||||
if let Some(name) = self.name.as_ref() {
|
if let Some(name) = self.name.as_ref() {
|
||||||
*arrangement.name.write().unwrap() = name.clone();
|
*arrangement.name.write().unwrap() = name.clone();
|
||||||
}
|
}
|
||||||
|
|
@ -46,8 +49,6 @@ impl ArrangerCli {
|
||||||
//scene.clips[i] = Some(i);
|
//scene.clips[i] = Some(i);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
transport.set_focused(true);
|
|
||||||
let transport = Arc::new(RwLock::new(transport));
|
|
||||||
transport.write().unwrap().jack = Some(
|
transport.write().unwrap().jack = Some(
|
||||||
jack.activate(
|
jack.activate(
|
||||||
&transport.clone(),
|
&transport.clone(),
|
||||||
|
|
@ -57,12 +58,14 @@ impl ArrangerCli {
|
||||||
)?
|
)?
|
||||||
);
|
);
|
||||||
Tui::run(Arc::new(RwLock::new(Arranger {
|
Tui::run(Arc::new(RwLock::new(Arranger {
|
||||||
transport: self.transport.then_some(transport),
|
transport: self.transport.then_some(transport),
|
||||||
show_sequencer: Some(tek_core::Direction::Down),
|
show_sequencer: Some(tek_core::Direction::Down),
|
||||||
arrangement,
|
focus: 0,
|
||||||
focus: 0,
|
|
||||||
sequencer_proxy: SequencerProxy(Default::default(), false),
|
sequencer_proxy: SequencerProxy(Default::default(), false),
|
||||||
modal: None
|
modal: None,
|
||||||
|
editor: PhraseEditor::new(),
|
||||||
|
arrangement,
|
||||||
|
phrases,
|
||||||
})))?;
|
})))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,19 @@ impl Content for Arranger<Tui> {
|
||||||
Layers::new(move|add|{
|
Layers::new(move|add|{
|
||||||
add(&Stack::down(move|add|{
|
add(&Stack::down(move|add|{
|
||||||
add(&self.transport)?;
|
add(&self.transport)?;
|
||||||
|
let arrangement = &self.arrangement as &dyn Widget<Engine = Tui>;
|
||||||
if let (Some(direction), Some(sequencer)) = (
|
if let (Some(direction), Some(sequencer)) = (
|
||||||
self.show_sequencer,
|
self.show_sequencer,
|
||||||
self.arrangement.sequencer(),
|
self.arrangement.sequencer(),
|
||||||
) {
|
) {
|
||||||
let arrangement = &self.arrangement as &dyn Widget<Engine = Tui>;
|
|
||||||
let sequencer = sequencer as &dyn Widget<Engine = Tui>;
|
let sequencer = sequencer as &dyn Widget<Engine = Tui>;
|
||||||
add(&Split::new(direction, 20, arrangement, sequencer.min_y(20)))
|
add(&arrangement.split(
|
||||||
|
direction,
|
||||||
|
20,
|
||||||
|
self.phrases.clone()
|
||||||
|
.split(direction.ccw(), 20, sequencer)
|
||||||
|
.min_y(20)
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
add(&self.arrangement)
|
add(&self.arrangement)
|
||||||
}
|
}
|
||||||
|
|
@ -722,3 +728,17 @@ impl Handle<Tui> for ArrangerRenameModal<Tui> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Content for PhrasePool<Tui> {
|
||||||
|
type Engine = Tui;
|
||||||
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
|
col!(
|
||||||
|
"Phrases:",
|
||||||
|
col!((i, phrase) in self.phrases.iter().enumerate() => format!("{i}"))
|
||||||
|
)
|
||||||
|
.bg(Color::Rgb(28, 35, 25))
|
||||||
|
.border(Lozenge(Style::default()
|
||||||
|
.bg(Color::Rgb(40, 50, 30))
|
||||||
|
.fg(Color::Rgb(70, 80, 50))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue