mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
wip: replacing Rect with [u16;4] in mixer and sequencer
This commit is contained in:
parent
fa739a49b2
commit
06f8bd1116
14 changed files with 106 additions and 106 deletions
|
|
@ -49,8 +49,8 @@ const STYLE_VALUE: Option<Style> = Some(Style {
|
|||
struct SequenceName<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Render<Tui> for SequenceName<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let Rect { x, y, .. } = to.area();
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
let frame = Rect { x, y, width: 10, height: 4 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
|
||||
to.blit(&"Name:", x + 1, y + 1, STYLE_LABEL)?;
|
||||
|
|
@ -62,8 +62,8 @@ impl<'a> Render<Tui> for SequenceName<'a> {
|
|||
struct SequenceRange;
|
||||
|
||||
impl<'a> Render<Tui> for SequenceRange {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let Rect { x, y, .. } = to.area();
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
let frame = Rect { x, y, width: 10, height: 6 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
|
||||
to.blit(&"Start: ", x + 1, y + 1, STYLE_LABEL)?;
|
||||
|
|
@ -77,8 +77,8 @@ impl<'a> Render<Tui> for SequenceRange {
|
|||
struct SequenceLoopRange;
|
||||
|
||||
impl<'a> Render<Tui> for SequenceLoopRange {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let Rect { x, y, .. } = to.area();
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
let range = Rect { x, y, width: 10, height: 7 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
|
||||
to.blit(&"Loop [ ]", x + 1, y + 1, STYLE_LABEL)?;
|
||||
|
|
@ -93,8 +93,8 @@ impl<'a> Render<Tui> for SequenceLoopRange {
|
|||
struct SequenceNoteRange;
|
||||
|
||||
impl<'a> Render<Tui> for SequenceNoteRange {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let Rect { x, y, .. } = to.area();
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let [x, y, ..] = to.area();
|
||||
let range = Rect { x, y, width: 10, height: 9 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
|
||||
to.blit(&"Notes: ", x + 1, y + 1, STYLE_LABEL)?;
|
||||
|
|
@ -111,7 +111,7 @@ impl<'a> Render<Tui> for SequenceNoteRange {
|
|||
struct SequenceKeys<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Render<Tui> for SequenceKeys<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
if area.height < 2 {
|
||||
return Ok(Some(area))
|
||||
|
|
@ -135,7 +135,7 @@ impl<'a> Render<Tui> for SequenceKeys<'a> {
|
|||
struct SequenceNotes<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Render<Tui> for SequenceNotes<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
if area.height < 2 {
|
||||
return Ok(Some(area))
|
||||
|
|
@ -164,7 +164,7 @@ impl<'a> Render<Tui> for SequenceNotes<'a> {
|
|||
struct SequenceCursor<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Render<Tui> for SequenceCursor<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
if let (Some(time), Some(note)) = (self.0.time_axis.point, self.0.note_axis.point) {
|
||||
let x = area.x + Sequencer::H_KEYS_OFFSET as u16 + time as u16;
|
||||
|
|
@ -180,7 +180,7 @@ impl<'a> Render<Tui> for SequenceCursor<'a> {
|
|||
struct SequenceZoom<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Render<Tui> for SequenceZoom<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
let quant = ppq_to_name(self.0.time_axis.scale);
|
||||
let quant_x = area.x + area.width - 1 - quant.len() as u16;
|
||||
|
|
@ -192,13 +192,13 @@ impl<'a> Render<Tui> for SequenceZoom<'a> {
|
|||
struct SequenceTimer<'a>(&'a Sequencer, Arc<RwLock<Phrase>>);
|
||||
|
||||
impl<'a> Render<Tui> for SequenceTimer<'a> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let area = to.area();
|
||||
let phrase = self.1.read().unwrap();
|
||||
let (time0, time_z, now) = (
|
||||
self.0.time_axis.start, self.0.time_axis.scale, self.0.now % phrase.length
|
||||
);
|
||||
let Rect { x, width, .. } = area;
|
||||
let [x, _, width, _] = area;
|
||||
let x2 = x as usize + Sequencer::H_KEYS_OFFSET;
|
||||
let x3 = x as usize + width as usize;
|
||||
for x in x2..x3 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue