mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
sequencer: compact sidebar
This commit is contained in:
parent
a0109bce9b
commit
ea463db139
2 changed files with 64 additions and 16 deletions
|
|
@ -60,6 +60,14 @@ handle!(ArrangerRenameModal |self, e| {
|
|||
KeyCode::Right => {
|
||||
self.cursor = self.value.len().min(self.cursor + 1)
|
||||
},
|
||||
KeyCode::Backspace => {
|
||||
let last = self.value.len().saturating_sub(1);
|
||||
self.value = format!("{}{}",
|
||||
&self.value[0..self.cursor.min(last)],
|
||||
&self.value[self.cursor.min(last)..last]
|
||||
);
|
||||
self.cursor = self.cursor.saturating_sub(1)
|
||||
}
|
||||
KeyCode::Char(c) => {
|
||||
self.value.insert(self.cursor, c);
|
||||
self.cursor = self.value.len().min(self.cursor + 1)
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ impl Sequencer {
|
|||
|
||||
pub(crate) fn horizontal_draw (&self, buf: &mut Buffer, mut area: Rect) -> Usually<()> {
|
||||
Split::down()
|
||||
.add_ref(&SequenceName(&self))
|
||||
.add_ref(&SequenceRange)
|
||||
.add_ref(&SequenceLoopRange)
|
||||
.add_ref(&SequenceNoteRange)
|
||||
.render(buf, Rect { x: area.x, y: area.y, width: 15, height: area.height })?;
|
||||
area.x = area.x + 15;
|
||||
area.width = area.width.saturating_sub(15);
|
||||
.render(buf, Rect { x: area.x, y: area.y, width: 10, height: area.height })?;
|
||||
area.x = area.x + 10;
|
||||
area.width = area.width.saturating_sub(10);
|
||||
area.height = area.height.min(66);
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(buf, area)?;
|
||||
area.x = area.x + 1;
|
||||
area.width = area.width.saturating_sub(1);
|
||||
|
|
@ -27,14 +29,46 @@ impl Sequencer {
|
|||
|
||||
}
|
||||
|
||||
const STYLE_LABEL: Option<Style> = Some(Style {
|
||||
fg: Some(Color::Reset),
|
||||
bg: None,
|
||||
underline_color: None,
|
||||
add_modifier: Modifier::empty(),
|
||||
sub_modifier: Modifier::BOLD,
|
||||
});
|
||||
|
||||
const STYLE_VALUE: Option<Style> = Some(Style {
|
||||
fg: Some(Color::White),
|
||||
bg: None,
|
||||
underline_color: None,
|
||||
add_modifier: Modifier::BOLD,
|
||||
sub_modifier: Modifier::DIM,
|
||||
});
|
||||
|
||||
struct SequenceName<'a>(&'a Sequencer);
|
||||
|
||||
impl<'a> Render for SequenceName<'a> {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, .. } = area;
|
||||
let frame = Rect { x, y, width: 10, height: 4 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(buf, frame)?;
|
||||
"Name:".blit(buf, x + 1, y + 1, STYLE_LABEL)?;
|
||||
self.0.name.blit(buf, x + 1, y + 2, STYLE_VALUE)?;
|
||||
Ok(frame)
|
||||
}
|
||||
}
|
||||
|
||||
struct SequenceRange;
|
||||
|
||||
impl Render for SequenceRange {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let frame = Rect { x: area.x, y: area.y, width: 15, height: 4 };
|
||||
let Rect { x, y, .. } = area;
|
||||
let frame = Rect { x, y, width: 10, height: 6 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(buf, frame)?;
|
||||
"Start 1.1.1".blit(buf, area.x + 1, area.y + 1, None)?;
|
||||
"End 2.1.1".blit(buf, area.x + 1, area.y + 2, None)?;
|
||||
"Start: ".blit(buf, x + 1, y + 1, STYLE_LABEL)?;
|
||||
" 1.1.1".blit(buf, x + 1, y + 2, STYLE_VALUE)?;
|
||||
"End: ".blit(buf, x + 1, y + 3, STYLE_LABEL)?;
|
||||
" 2.1.1".blit(buf, x + 1, y + 4, STYLE_VALUE)?;
|
||||
Ok(frame)
|
||||
}
|
||||
}
|
||||
|
|
@ -43,11 +77,14 @@ struct SequenceLoopRange;
|
|||
|
||||
impl Render for SequenceLoopRange {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let range = Rect { x: area.x, y: area.y, width: 15, height: 5 };
|
||||
let Rect { x, y, .. } = area;
|
||||
let range = Rect { x, y, width: 10, height: 7 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(buf, range)?;
|
||||
"[ Loop off ] ".blit(buf, area.x + 1, area.y + 1, None)?;
|
||||
"Loop 1.1.1".blit(buf, area.x + 1, area.y + 2, None)?;
|
||||
"Length 1.0.0".blit(buf, area.x + 1, area.y + 3, None)?;
|
||||
"Loop [ ]".blit(buf, x + 1, y + 1, STYLE_LABEL)?;
|
||||
"From: ".blit(buf, x + 1, y + 2, STYLE_LABEL)?;
|
||||
" 1.1.1".blit(buf, x + 1, y + 3, STYLE_VALUE)?;
|
||||
"Length: ".blit(buf, x + 1, y + 4, STYLE_LABEL)?;
|
||||
" 1.0.0".blit(buf, x + 1, y + 5, STYLE_VALUE)?;
|
||||
Ok(range)
|
||||
}
|
||||
}
|
||||
|
|
@ -56,13 +93,16 @@ struct SequenceNoteRange;
|
|||
|
||||
impl Render for SequenceNoteRange {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let range = Rect { x: area.x, y: area.y, width: 15, height: 7 };
|
||||
let Rect { x, y, .. } = area;
|
||||
let range = Rect { x, y, width: 10, height: 9 };
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(buf, range)?;
|
||||
"Notes -------".blit(buf, area.x + 1, area.y + 1, None)?;
|
||||
"[ /2 ] [ x2 ]".blit(buf, area.x + 1, area.y + 2, None)?;
|
||||
"[ Reverse ]".blit(buf, area.x + 1, area.y + 3, None)?;
|
||||
"[ Invert ]".blit(buf, area.x + 1, area.y + 4, None)?;
|
||||
"[ Duplicate ]".blit(buf, area.x + 1, area.y + 5, None)?;
|
||||
"Notes: ".blit(buf, x + 1, y + 1, STYLE_LABEL)?;
|
||||
"C#0-C#9 ".blit(buf, x + 1, y + 2, STYLE_VALUE)?;
|
||||
"[ /2 ]".blit(buf, x + 1, y + 3, STYLE_LABEL)?;
|
||||
"[ x2 ]".blit(buf, x + 1, y + 4, STYLE_LABEL)?;
|
||||
"[ Rev ]".blit(buf, x + 1, y + 5, STYLE_LABEL)?;
|
||||
"[ Inv ]".blit(buf, x + 1, y + 6, STYLE_LABEL)?;
|
||||
"[ Dup ]".blit(buf, x + 1, y + 7, STYLE_LABEL)?;
|
||||
Ok(area)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue