mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
refactor control and sequencer rendering
This commit is contained in:
parent
20b7267225
commit
14d9116c7c
10 changed files with 370 additions and 405 deletions
20
src/view.rs
20
src/view.rs
|
|
@ -16,7 +16,7 @@ pub use self::focus::*;
|
|||
pub use self::chain::ChainView;
|
||||
pub use self::sequencer::SequencerView;
|
||||
|
||||
use crate::{render, App, core::*};
|
||||
use crate::{render, App, AppSection, core::*};
|
||||
|
||||
render!(App |self, buf, area| {
|
||||
let Rect { x, y, width, height } = area;
|
||||
|
|
@ -31,7 +31,7 @@ render!(App |self, buf, area| {
|
|||
x, y, width, height: height / 3
|
||||
})?
|
||||
};
|
||||
if self.section == 0 {
|
||||
if self.section == AppSection::Grid {
|
||||
QuarterV(if self.entered {
|
||||
Style::default().green()
|
||||
} else {
|
||||
|
|
@ -43,7 +43,7 @@ render!(App |self, buf, area| {
|
|||
let chain = self.draw_chain(buf, Rect {
|
||||
x, y: y + height - height / 3 - 1, width, height: height / 3
|
||||
})?;
|
||||
if self.section == 1 {
|
||||
if self.section == AppSection::Chain {
|
||||
QuarterV(if self.entered {
|
||||
Style::default().green()
|
||||
} else {
|
||||
|
|
@ -53,7 +53,7 @@ render!(App |self, buf, area| {
|
|||
let phrase = self.draw_phrase(buf, Rect {
|
||||
x, y, width, height: height - height / 3
|
||||
})?;
|
||||
if self.section == 2 {
|
||||
if self.section == AppSection::Sequencer {
|
||||
QuarterV(if self.entered {
|
||||
Style::default().green()
|
||||
} else {
|
||||
|
|
@ -78,7 +78,7 @@ impl App {
|
|||
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,
|
||||
focused: self.section == AppSection::Chain,
|
||||
track: Some(track),
|
||||
vertical: true,
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ impl App {
|
|||
SceneGridViewHorizontal {
|
||||
buf,
|
||||
area,
|
||||
focused: self.section == 0,
|
||||
focused: self.section == AppSection::Grid,
|
||||
entered: self.entered,
|
||||
scenes: &self.scenes,
|
||||
tracks: &self.tracks,
|
||||
|
|
@ -116,7 +116,7 @@ impl App {
|
|||
SceneGridViewVertical {
|
||||
buf,
|
||||
area,
|
||||
focused: self.section == 0,
|
||||
focused: self.section == AppSection::Grid,
|
||||
entered: self.entered,
|
||||
scenes: &self.scenes,
|
||||
tracks: &self.tracks,
|
||||
|
|
@ -125,7 +125,7 @@ impl App {
|
|||
}
|
||||
fn draw_chain (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
ChainView {
|
||||
focused: self.section == 1,
|
||||
focused: self.section == AppSection::Chain,
|
||||
track: self.tracks.get(self.track_cursor - 1),
|
||||
vertical: false,
|
||||
}.render(buf, area)
|
||||
|
|
@ -134,7 +134,7 @@ impl App {
|
|||
let phrase = self.phrase();
|
||||
let seq_area = SequencerView {
|
||||
phrase,
|
||||
focused: self.section == 2,
|
||||
focused: self.section == AppSection::Sequencer,
|
||||
ppq: self.timebase.ppq() as usize,
|
||||
now: self.timebase.frame_to_pulse(self.playhead as f64) as usize,
|
||||
time_cursor: self.time_cursor,
|
||||
|
|
@ -144,7 +144,7 @@ impl App {
|
|||
note_start: self.note_start,
|
||||
}.render(buf, area)?;
|
||||
let track = self.tracks.get(self.track_cursor - 1).unwrap();
|
||||
if phrase.is_none() && self.section == 2 {
|
||||
if phrase.is_none() && self.section == AppSection::Sequencer {
|
||||
let label = format!("[ENTER] Create new clip: {}", track.name);
|
||||
let x = area.x + seq_area.width / 2 - (label.len() / 2) as u16;
|
||||
let y = area.y + seq_area.height / 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue