mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
ui thrashing
This commit is contained in:
parent
acb952736e
commit
20b7267225
18 changed files with 695 additions and 233 deletions
177
src/view.rs
177
src/view.rs
|
|
@ -1,71 +1,137 @@
|
|||
pub mod chain;
|
||||
pub mod grid;
|
||||
pub mod layout;
|
||||
pub mod mixer;
|
||||
pub mod sampler;
|
||||
pub mod sequencer;
|
||||
pub mod transport;
|
||||
pub mod plugin;
|
||||
pub mod focus;
|
||||
pub mod border;
|
||||
|
||||
pub use self::border::*;
|
||||
pub use self::layout::*;
|
||||
pub use self::transport::TransportView;
|
||||
pub use self::grid::*;
|
||||
pub use self::focus::*;
|
||||
pub use self::chain::ChainView;
|
||||
pub use self::sequencer::SequencerView;
|
||||
|
||||
use crate::{render, App, core::*};
|
||||
|
||||
render!(App |self, buf, area| {
|
||||
let Rect { x, mut y, width, height } = area;
|
||||
let Rect { x, y, width, height } = area;
|
||||
let transport = self.draw_transport(buf, area)?;
|
||||
let y = y + transport.height;
|
||||
let grid = if self.grid_mode {
|
||||
self.draw_grid_horizontal(buf, Rect {
|
||||
x, y, width, height: height / 3
|
||||
})?
|
||||
} else {
|
||||
self.draw_grid_vertical(buf, Rect {
|
||||
x, y, width, height: height / 3
|
||||
})?
|
||||
};
|
||||
if self.section == 0 {
|
||||
QuarterV(if self.entered {
|
||||
Style::default().green()
|
||||
} else {
|
||||
Style::default().green().dim()
|
||||
}).draw(buf, grid)
|
||||
}
|
||||
let y = y + grid.height;
|
||||
if self.track_cursor > 0 {
|
||||
let chain = self.draw_chain(buf, Rect {
|
||||
x, y: y + height - height / 3 - 1, width, height: height / 3
|
||||
})?;
|
||||
if self.section == 1 {
|
||||
QuarterV(if self.entered {
|
||||
Style::default().green()
|
||||
} else {
|
||||
Style::default().green().dim()
|
||||
}).draw(buf, Rect { x, y, width, height: chain.height })
|
||||
}
|
||||
let phrase = self.draw_phrase(buf, Rect {
|
||||
x, y, width, height: height - height / 3
|
||||
})?;
|
||||
if self.section == 2 {
|
||||
QuarterV(if self.entered {
|
||||
Style::default().green()
|
||||
} else {
|
||||
Style::default().green().dim()
|
||||
}).draw(buf, phrase)
|
||||
}
|
||||
chain
|
||||
} else {
|
||||
self.draw_mixer(buf, Rect {
|
||||
x, y, width, height
|
||||
})?
|
||||
};
|
||||
if let Some(ref modal) = self.modal {
|
||||
modal.render(buf, area)?;
|
||||
}
|
||||
Ok(area)
|
||||
});
|
||||
|
||||
y = y + TransportView {
|
||||
timebase: &self.timebase,
|
||||
playing: *self.playing.as_ref().unwrap_or(&TransportState::Stopped),
|
||||
monitor: self.track().map(|t|t.1.monitoring).unwrap_or(false),
|
||||
record: self.track().map(|t|t.1.recording).unwrap_or(false),
|
||||
overdub: self.track().map(|t|t.1.overdub).unwrap_or(false),
|
||||
frame: self.playhead,
|
||||
quant: self.quant,
|
||||
}.render(buf, area)?.height;
|
||||
|
||||
y = y + if self.grid_mode {
|
||||
impl App {
|
||||
fn draw_mixer (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let mut x = area.x;
|
||||
for track in self.tracks.iter() {
|
||||
track.name.blit(buf, x + 1, area.y, Some(Style::default().white().bold()));
|
||||
x = x + ChainView {
|
||||
focused: self.section == 1,
|
||||
track: Some(track),
|
||||
vertical: true,
|
||||
}
|
||||
.render(buf, Rect {
|
||||
x, y: area.y + 1, width: area.width, height: area.height - area.y - 1
|
||||
})?
|
||||
.width
|
||||
.max(track.name.len() as u16);
|
||||
}
|
||||
Ok(area)
|
||||
}
|
||||
fn draw_transport (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
TransportView {
|
||||
timebase: &self.timebase,
|
||||
playing: *self.playing.as_ref().unwrap_or(&TransportState::Stopped),
|
||||
monitor: self.track().map(|t|t.1.monitoring).unwrap_or(false),
|
||||
record: self.track().map(|t|t.1.recording).unwrap_or(false),
|
||||
overdub: self.track().map(|t|t.1.overdub).unwrap_or(false),
|
||||
frame: self.playhead,
|
||||
quant: self.quant,
|
||||
}.render(buf, area)
|
||||
}
|
||||
fn draw_grid_horizontal (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
SceneGridViewHorizontal {
|
||||
buf,
|
||||
area: Rect { x, y, width, height: height / 3 },
|
||||
area,
|
||||
focused: self.section == 0,
|
||||
entered: self.entered,
|
||||
scenes: &self.scenes,
|
||||
tracks: &self.tracks,
|
||||
cursor: &(self.track_cursor, self.scene_cursor),
|
||||
}.draw()?
|
||||
} else {
|
||||
}.draw()
|
||||
}
|
||||
fn draw_grid_vertical (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
SceneGridViewVertical {
|
||||
buf,
|
||||
area: Rect { x, y, width, height: height / 3 },
|
||||
area,
|
||||
focused: self.section == 0,
|
||||
entered: self.entered,
|
||||
scenes: &self.scenes,
|
||||
tracks: &self.tracks,
|
||||
cursor: &(self.track_cursor, self.scene_cursor),
|
||||
}.draw()?
|
||||
}.height;
|
||||
|
||||
if self.track_cursor > 0 {
|
||||
|
||||
let track = self.tracks
|
||||
.get(self.track_cursor - 1)
|
||||
.unwrap();
|
||||
|
||||
let chain_area = Rect { x, y: y + height - height / 3 - 1, width, height: height / 3 };
|
||||
}.draw()
|
||||
}
|
||||
fn draw_chain (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
ChainView {
|
||||
focused: self.section == 1,
|
||||
track: Some(track),
|
||||
track: self.tracks.get(self.track_cursor - 1),
|
||||
vertical: false,
|
||||
}
|
||||
.render(buf, chain_area)?;
|
||||
|
||||
}.render(buf, area)
|
||||
}
|
||||
fn draw_phrase (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let phrase = self.phrase();
|
||||
|
||||
let seq_area = SequencerView {
|
||||
phrase,
|
||||
focused: self.section == 2,
|
||||
|
|
@ -76,51 +142,14 @@ render!(App |self, buf, area| {
|
|||
time_zoom: self.time_zoom,
|
||||
note_cursor: self.note_cursor,
|
||||
note_start: self.note_start,
|
||||
}.render(buf, Rect { x, y, width, height: height - height / 3 })?;
|
||||
|
||||
}.render(buf, area)?;
|
||||
let track = self.tracks.get(self.track_cursor - 1).unwrap();
|
||||
if phrase.is_none() && self.section == 2 {
|
||||
let label = format!("[ENTER] Create new clip: {}", track.name);
|
||||
let x = x + seq_area.width / 2 - (label.len() / 2) as u16;
|
||||
let y = y + seq_area.height / 2;
|
||||
let x = area.x + seq_area.width / 2 - (label.len() / 2) as u16;
|
||||
let y = area.y + seq_area.height / 2;
|
||||
label.blit(buf, x, y, Some(Style::default().white()));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
let mut x = x;
|
||||
|
||||
for track in self.tracks.iter() {
|
||||
track.name.blit(buf, x + 1, y, Some(Style::default().white().bold()));
|
||||
x = x + ChainView {
|
||||
focused: self.section == 1,
|
||||
track: Some(track),
|
||||
vertical: true,
|
||||
}
|
||||
.render(buf, Rect { x, y: y + 1, width, height: height - y - 1 })?
|
||||
.width
|
||||
.max(track.name.len() as u16);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if let Some(ref modal) = self.modal {
|
||||
modal.render(buf, area)?;
|
||||
}
|
||||
|
||||
Ok(area)
|
||||
});
|
||||
|
||||
pub fn fill_bg (buf: &mut Buffer, area: Rect, color: Color) {
|
||||
let Rect { x, y, width, height } = area;
|
||||
for y in y..y+height {
|
||||
if y >= buf.area.height {
|
||||
break
|
||||
}
|
||||
for x in x..x+width {
|
||||
if x >= buf.area.width {
|
||||
break
|
||||
}
|
||||
buf.get_mut(x, y).set_bg(color);
|
||||
}
|
||||
Ok(seq_area)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue