mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
remove vec allocation from plugin callback
This commit is contained in:
parent
828436745c
commit
672d81f353
5 changed files with 150 additions and 116 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::core::*;
|
use crate::core::*;
|
||||||
use atomic_float::AtomicF64;
|
use atomic_float::AtomicF64;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
/// Keeps track of global time units.
|
||||||
pub struct Timebase {
|
pub struct Timebase {
|
||||||
/// Frames per second
|
/// Frames per second
|
||||||
rate: AtomicF64,
|
rate: AtomicF64,
|
||||||
|
|
@ -98,14 +99,17 @@ impl Timebase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Defines frames per tick.
|
||||||
pub struct Ticks(pub f64);
|
pub struct Ticks(pub f64);
|
||||||
|
|
||||||
impl Ticks {
|
impl Ticks {
|
||||||
|
/// Iterate over ticks between start and end.
|
||||||
pub fn between_frames (&self, start: usize, end: usize) -> TicksIterator {
|
pub fn between_frames (&self, start: usize, end: usize) -> TicksIterator {
|
||||||
TicksIterator(self.0, start, start, end)
|
TicksIterator(self.0, start, start, end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Iterator that emits subsequent ticks within a range.
|
||||||
pub struct TicksIterator(f64, usize, usize, usize);
|
pub struct TicksIterator(f64, usize, usize, usize);
|
||||||
|
|
||||||
impl Iterator for TicksIterator {
|
impl Iterator for TicksIterator {
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,14 @@ impl Plugin {
|
||||||
}
|
}
|
||||||
pub fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
pub fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||||
match self.plugin.as_mut() {
|
match self.plugin.as_mut() {
|
||||||
Some(PluginKind::LV2(LV2Plugin { features, ref mut instance, .. })) => {
|
Some(PluginKind::LV2(LV2Plugin {
|
||||||
|
features,
|
||||||
|
ref mut instance,
|
||||||
|
ref mut input_buffer,
|
||||||
|
..
|
||||||
|
})) => {
|
||||||
let urid = features.midi_urid();
|
let urid = features.midi_urid();
|
||||||
let mut inputs = vec![];
|
input_buffer.clear();
|
||||||
for port in self.ports.midi_ins.values() {
|
for port in self.ports.midi_ins.values() {
|
||||||
let mut atom = ::livi::event::LV2AtomSequence::new(
|
let mut atom = ::livi::event::LV2AtomSequence::new(
|
||||||
&features,
|
&features,
|
||||||
|
|
@ -58,7 +63,7 @@ impl Plugin {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputs.push(atom);
|
input_buffer.push(atom);
|
||||||
}
|
}
|
||||||
let mut outputs = vec![];
|
let mut outputs = vec![];
|
||||||
for _ in self.ports.midi_outs.iter() {
|
for _ in self.ports.midi_outs.iter() {
|
||||||
|
|
@ -69,7 +74,7 @@ impl Plugin {
|
||||||
}
|
}
|
||||||
let ports = ::livi::EmptyPortConnections::new()
|
let ports = ::livi::EmptyPortConnections::new()
|
||||||
.with_atom_sequence_inputs(
|
.with_atom_sequence_inputs(
|
||||||
inputs.iter()
|
input_buffer.iter()
|
||||||
)
|
)
|
||||||
.with_atom_sequence_outputs(
|
.with_atom_sequence_outputs(
|
||||||
outputs.iter_mut()
|
outputs.iter_mut()
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,29 @@
|
||||||
use crate::core::*;
|
use crate::core::*;
|
||||||
|
|
||||||
|
use ::livi::{
|
||||||
|
World,
|
||||||
|
Instance,
|
||||||
|
Plugin,
|
||||||
|
Features,
|
||||||
|
FeaturesBuilder,
|
||||||
|
Port,
|
||||||
|
event::LV2AtomSequence,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct LV2Plugin {
|
pub struct LV2Plugin {
|
||||||
pub world: ::livi::World,
|
pub world: World,
|
||||||
pub instance: ::livi::Instance,
|
pub instance: Instance,
|
||||||
pub plugin: ::livi::Plugin,
|
pub plugin: Plugin,
|
||||||
pub features: Arc<::livi::Features>,
|
pub features: Arc<Features>,
|
||||||
pub port_list: Vec<::livi::Port>,
|
pub port_list: Vec<Port>,
|
||||||
|
pub input_buffer: Vec<LV2AtomSequence>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LV2Plugin {
|
impl LV2Plugin {
|
||||||
pub fn new (uri: &str) -> Usually<Self> {
|
pub fn new (uri: &str) -> Usually<Self> {
|
||||||
// Get 1st plugin at URI
|
// Get 1st plugin at URI
|
||||||
let world = ::livi::World::with_load_bundle(&uri);
|
let world = World::with_load_bundle(&uri);
|
||||||
let features = ::livi::FeaturesBuilder { min_block_length: 1, max_block_length: 65536 };
|
let features = FeaturesBuilder { min_block_length: 1, max_block_length: 65536 };
|
||||||
let features = world.build_features(features);
|
let features = world.build_features(features);
|
||||||
let mut plugin = None;
|
let mut plugin = None;
|
||||||
for p in world.iter_plugins() {
|
for p in world.iter_plugins() {
|
||||||
|
|
@ -39,6 +50,7 @@ impl LV2Plugin {
|
||||||
},
|
},
|
||||||
plugin,
|
plugin,
|
||||||
features,
|
features,
|
||||||
|
input_buffer: Vec::with_capacity(1024)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
src/view.rs
20
src/view.rs
|
|
@ -9,7 +9,7 @@ pub mod plugin;
|
||||||
|
|
||||||
pub use self::layout::*;
|
pub use self::layout::*;
|
||||||
pub use self::transport::TransportView;
|
pub use self::transport::TransportView;
|
||||||
pub use self::grid::SceneGridView;
|
pub use self::grid::*;
|
||||||
pub use self::chain::ChainView;
|
pub use self::chain::ChainView;
|
||||||
pub use self::sequencer::SequencerView;
|
pub use self::sequencer::SequencerView;
|
||||||
|
|
||||||
|
|
@ -17,7 +17,6 @@ use crate::{render, App, core::*};
|
||||||
|
|
||||||
render!(App |self, buf, area| {
|
render!(App |self, buf, area| {
|
||||||
let Rect { x, mut y, width, height } = area;
|
let Rect { x, mut y, width, height } = area;
|
||||||
return Ok(area);
|
|
||||||
|
|
||||||
y = y + TransportView {
|
y = y + TransportView {
|
||||||
timebase: &self.timebase,
|
timebase: &self.timebase,
|
||||||
|
|
@ -29,16 +28,25 @@ render!(App |self, buf, area| {
|
||||||
quant: self.quant,
|
quant: self.quant,
|
||||||
}.render(buf, area)?.height;
|
}.render(buf, area)?.height;
|
||||||
|
|
||||||
y = y + SceneGridView {
|
y = y + if self.grid_mode {
|
||||||
|
SceneGridViewHorizontal {
|
||||||
buf,
|
buf,
|
||||||
area: Rect { x, y, width, height: height / 3 },
|
area: Rect { x, y, width, height: height / 3 },
|
||||||
name: "",
|
|
||||||
mode: self.grid_mode,
|
|
||||||
focused: self.section == 0,
|
focused: self.section == 0,
|
||||||
scenes: &self.scenes,
|
scenes: &self.scenes,
|
||||||
tracks: &self.tracks,
|
tracks: &self.tracks,
|
||||||
cursor: &(self.track_cursor, self.scene_cursor),
|
cursor: &(self.track_cursor, self.scene_cursor),
|
||||||
}.draw()?.height;
|
}.draw()?
|
||||||
|
} else {
|
||||||
|
SceneGridViewVertical {
|
||||||
|
buf,
|
||||||
|
area: Rect { x, y, width, height: height / 3 },
|
||||||
|
focused: self.section == 0,
|
||||||
|
scenes: &self.scenes,
|
||||||
|
tracks: &self.tracks,
|
||||||
|
cursor: &(self.track_cursor, self.scene_cursor),
|
||||||
|
}.draw()?
|
||||||
|
}.height;
|
||||||
|
|
||||||
if self.track_cursor > 0 {
|
if self.track_cursor > 0 {
|
||||||
|
|
||||||
|
|
|
||||||
169
src/view/grid.rs
169
src/view/grid.rs
|
|
@ -1,25 +1,22 @@
|
||||||
use crate::core::*;
|
use crate::core::*;
|
||||||
use crate::model::*;
|
use crate::model::*;
|
||||||
use crate::view::*;
|
use crate::view::*;
|
||||||
pub struct SceneGridView<'a> {
|
pub struct SceneGridViewHorizontal<'a> {
|
||||||
pub buf: &'a mut Buffer,
|
pub buf: &'a mut Buffer,
|
||||||
pub area: Rect,
|
pub area: Rect,
|
||||||
pub name: &'a str,
|
|
||||||
pub focused: bool,
|
|
||||||
pub scenes: &'a[Scene],
|
pub scenes: &'a[Scene],
|
||||||
pub tracks: &'a[Track],
|
pub tracks: &'a[Track],
|
||||||
pub cursor: &'a(usize, usize),
|
pub cursor: &'a(usize, usize),
|
||||||
pub mode: bool,
|
pub focused: bool
|
||||||
}
|
}
|
||||||
impl<'a> SceneGridView<'a> {
|
impl<'a> SceneGridViewHorizontal<'a> {
|
||||||
fn longest_scene_name (&self) -> u16 {
|
pub fn size (&self) -> (u16, u16) {
|
||||||
let mut w = 3u16;
|
let (mut w, mut h) = (4, 2);
|
||||||
for scene in self.scenes.iter() {
|
w = w + self.longest_track_name();
|
||||||
w = w.max(scene.name.len() as u16);
|
w = w + self.scenes.len() as u16 * 10;
|
||||||
|
h = h + self.tracks.len();
|
||||||
|
(w as u16, h as u16)
|
||||||
}
|
}
|
||||||
w
|
|
||||||
}
|
|
||||||
|
|
||||||
fn longest_track_name (&self) -> u16 {
|
fn longest_track_name (&self) -> u16 {
|
||||||
let mut w = 3u16;
|
let mut w = 3u16;
|
||||||
for track in self.tracks.iter() {
|
for track in self.tracks.iter() {
|
||||||
|
|
@ -27,75 +24,72 @@ impl<'a> SceneGridView<'a> {
|
||||||
}
|
}
|
||||||
w
|
w
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size_horizontal (&mut self) -> (u16, u16) {
|
|
||||||
let (mut w, mut h) = (4, 2);
|
|
||||||
w = w + self.longest_track_name();
|
|
||||||
w = w + self.scenes.len() as u16 * 10;
|
|
||||||
h = h + self.tracks.len();
|
|
||||||
(w as u16, h as u16)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw (&mut self) -> Usually<Rect> {
|
pub fn draw (&mut self) -> Usually<Rect> {
|
||||||
match self.mode {
|
|
||||||
true => self.draw_horizontal(),
|
|
||||||
false => self.draw_vertical(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_horizontal (&mut self) -> Usually<Rect> {
|
|
||||||
//let (w, h) = self.size_horizontal();
|
//let (w, h) = self.size_horizontal();
|
||||||
//self.area.x = self.area.x + self.area.width.saturating_sub(w) / 2;
|
//self.area.x = self.area.x + self.area.width.saturating_sub(w) / 2;
|
||||||
self.area.height = self.tracks.len() as u16 + 2;
|
self.area.height = self.tracks.len() as u16 + 2;
|
||||||
//self.area.width = w;
|
//self.area.width = w;
|
||||||
let style = Some(Style::default().green().dim());
|
let style = Some(Style::default().green().dim());
|
||||||
if self.focused {
|
|
||||||
let Rect { x, y, width, height } = self.area;
|
let Rect { x, y, width, height } = self.area;
|
||||||
|
if self.focused {
|
||||||
lozenge_left(self.buf, x, y, height, style);
|
lozenge_left(self.buf, x, y, height, style);
|
||||||
lozenge_right(self.buf, x + width - 1, y, height, style);
|
lozenge_right(self.buf, x + width - 1, y, height, style);
|
||||||
}
|
}
|
||||||
" Mix ".blit(self.buf,self.area.x+1,self.area.y,Some(Style::default().bold().not_dim().white()));
|
let style = Some(Style::default().bold().not_dim().white());
|
||||||
|
"Mix".blit(self.buf, x + 1, y, style);
|
||||||
let mut x2 = 0;
|
let mut x2 = 0;
|
||||||
|
let style = Some(Style::default().bold());
|
||||||
for (i, track) in self.tracks.iter().enumerate() {
|
for (i, track) in self.tracks.iter().enumerate() {
|
||||||
let label = format!(" {} ", &track.name);
|
let label = format!(" {:8} [R] [D] [M] ", &track.name);
|
||||||
label.blit(self.buf, self.area.x+1, self.area.y+1+i as u16, Some(Style::default().bold()));
|
label.blit(self.buf, x + 1, y + 1 + i as u16, style);
|
||||||
x2 = x2.max(label.len() as u16 + 1);
|
x2 = x2.max(label.len() as u16 + 1);
|
||||||
}
|
}
|
||||||
"╷".blit(self.buf, self.area.x + x2, self.area.y, style);
|
"╷".blit(self.buf, x + x2, y, style);
|
||||||
for y in self.area.y+1..self.area.y+self.area.height-1 {
|
for y in y+1..y+height-1 {
|
||||||
"│".blit(self.buf, self.area.x + x2, y, style);
|
"│".blit(self.buf, x + x2, y, style);
|
||||||
}
|
}
|
||||||
//"╵".blit(self.buf, self.area.x + x2, self.area.y+self.area.height-1, style);
|
//"╵".blit(self.buf, x + x2, y+height-1, style);
|
||||||
x2 = x2 + 1;
|
x2 = x2 + 1;
|
||||||
for scene in self.scenes.iter() {
|
for scene in self.scenes.iter() {
|
||||||
let label = format!("{}", &scene.name);
|
let mut x3 = 10.max(scene.name.len() as u16);
|
||||||
let mut x3 = label.len() as u16;
|
scene.name.blit(self.buf, x + x2, y, Some(Style::default().bold()));
|
||||||
label.blit(self.buf, self.area.x + x2, self.area.y, Some(Style::default().bold()));
|
|
||||||
for (i, clip) in scene.clips.iter().enumerate() {
|
for (i, clip) in scene.clips.iter().enumerate() {
|
||||||
if let Some(clip) = clip {
|
if let Some(clip) = clip {
|
||||||
if let Some(phrase) = self.tracks[i].phrases.get(*clip) {
|
if let Some(phrase) = self.tracks[i].phrases.get(*clip) {
|
||||||
let label = format!("{}", &phrase.name);
|
let label = format!("{}", &phrase.name);
|
||||||
label.blit(self.buf, self.area.x + x2, self.area.y + 1 + i as u16, None);
|
label.blit(self.buf, x + x2, y + 1 + i as u16, None);
|
||||||
x3 = x3.max(label.len() as u16)
|
x3 = x3.max(label.len() as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x2 = x2 + x3;
|
x2 = x2 + x3;
|
||||||
|
|
||||||
"╷".blit(self.buf, self.area.x + x2, self.area.y, style);
|
"╷".blit(self.buf, x + x2, y, style);
|
||||||
for y in self.area.y+1..self.area.y+self.area.height-1 {
|
for y in y+1..y+height-1 {
|
||||||
"┊".blit(self.buf, self.area.x + x2, y, style);
|
"┊".blit(self.buf, x + x2, y, style);
|
||||||
}
|
}
|
||||||
//"╵".blit(self.buf, self.area.x + x2, self.area.y+self.area.height-1, style);
|
//"╵".blit(self.buf, x + x2, y+height-1, style);
|
||||||
x2 = x2 + 1;
|
x2 = x2 + 1;
|
||||||
}
|
}
|
||||||
if self.focused {
|
if self.focused {
|
||||||
HELP.blit(self.buf, self.area.x + 2, self.area.y + self.area.height - 1, Some(Style::default().dim()));
|
HELP.blit(self.buf, x + 2, y + height - 1, Some(Style::default().dim()));
|
||||||
}
|
}
|
||||||
Ok(self.area)
|
Ok(self.area)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pub fn draw_vertical (&mut self) -> Usually<Rect> {
|
pub struct SceneGridViewVertical<'a> {
|
||||||
|
pub buf: &'a mut Buffer,
|
||||||
|
pub area: Rect,
|
||||||
|
pub scenes: &'a[Scene],
|
||||||
|
pub tracks: &'a[Track],
|
||||||
|
pub cursor: &'a(usize, usize),
|
||||||
|
pub focused: bool
|
||||||
|
}
|
||||||
|
impl<'a> SceneGridViewVertical<'a> {
|
||||||
|
pub fn size (&self) -> (u16, u16) {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
pub fn draw (&mut self) -> Usually<Rect> {
|
||||||
let width = self.area.width.min(4 + HELP.len() as u16);
|
let width = self.area.width.min(4 + HELP.len() as u16);
|
||||||
self.area.height = self.scenes.len() as u16 + 2;
|
self.area.height = self.scenes.len() as u16 + 2;
|
||||||
//self.area.x = self.area.x + self.area.width.saturating_sub(width) / 2;
|
//self.area.x = self.area.x + self.area.width.saturating_sub(width) / 2;
|
||||||
|
|
@ -120,9 +114,8 @@ impl<'a> SceneGridView<'a> {
|
||||||
if x >= self.area.x + self.area.width {
|
if x >= self.area.x + self.area.width {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
title.blit(
|
let style = Some(highlight(self.focused, i == self.cursor.0).bold());
|
||||||
self.buf, x+1, y, Some(self.highlight(i == self.cursor.0).bold())
|
title.blit(self.buf, x+1, y, style);
|
||||||
);
|
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
self.scenes(x+1, y + 1);
|
self.scenes(x+1, y + 1);
|
||||||
} else if i < columns.len() {
|
} else if i < columns.len() {
|
||||||
|
|
@ -136,7 +129,6 @@ impl<'a> SceneGridView<'a> {
|
||||||
}
|
}
|
||||||
Ok(self.area)
|
Ok(self.area)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn track_names (&self) -> Vec<&'a str> {
|
fn track_names (&self) -> Vec<&'a str> {
|
||||||
let mut track_names = vec!["Mix"];
|
let mut track_names = vec!["Mix"];
|
||||||
for track in self.tracks.iter() {
|
for track in self.tracks.iter() {
|
||||||
|
|
@ -146,7 +138,10 @@ impl<'a> SceneGridView<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn track_widths (&self) -> Vec<u16> {
|
fn track_widths (&self) -> Vec<u16> {
|
||||||
self.track_names().iter().map(|name|(name.len() as u16).max(10) + 3).collect()
|
self.track_names()
|
||||||
|
.iter()
|
||||||
|
.map(|name|(name.len() as u16).max(10) + 3)
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scenes (&mut self, x: u16, y: u16) -> u16 {
|
fn scenes (&mut self, x: u16, y: u16) -> u16 {
|
||||||
|
|
@ -158,18 +153,23 @@ impl<'a> SceneGridView<'a> {
|
||||||
if y + index as u16 >= self.area.height {
|
if y + index as u16 >= self.area.height {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if let Some(scene) = self.scenes.get(index) {
|
self.scene(x, y + index as u16, index);
|
||||||
let style = Some(self.highlight(
|
|
||||||
(0 == self.cursor.0) && (index + 1 == self.cursor.1)
|
|
||||||
).bold());
|
|
||||||
"⯈".blit(self.buf, x, y + index as u16, style);
|
|
||||||
scene.name.blit(self.buf, x+1, y + index as u16, style);
|
|
||||||
}
|
|
||||||
index = index + 1;
|
index = index + 1;
|
||||||
}
|
}
|
||||||
index as u16
|
index as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn scene (&mut self, x: u16, y: u16, index: usize) {
|
||||||
|
if let Some(scene) = self.scenes.get(index) {
|
||||||
|
let style = Some(highlight(
|
||||||
|
self.focused,
|
||||||
|
(0 == self.cursor.0) && (index + 1 == self.cursor.1)
|
||||||
|
).bold());
|
||||||
|
"⯈".blit(self.buf, x, y, style);
|
||||||
|
scene.name.blit(self.buf, x + 1, y, style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn clips (&mut self, x: u16, y: u16, track: usize) -> u16 {
|
fn clips (&mut self, x: u16, y: u16, track: usize) -> u16 {
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -179,10 +179,17 @@ impl<'a> SceneGridView<'a> {
|
||||||
if y + index as u16 >= self.area.height {
|
if y + index as u16 >= self.area.height {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
self.clip(x, y, track, index);
|
||||||
|
index = index + 1;
|
||||||
|
}
|
||||||
|
index as u16
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clip (&mut self, x: u16, y: u16, track: usize, index: usize) {
|
||||||
if let Some(scene) = self.scenes.get(index) {
|
if let Some(scene) = self.scenes.get(index) {
|
||||||
let hi = (track + 1 == self.cursor.0) &&
|
let hi = (track + 1 == self.cursor.0) &&
|
||||||
(index + 1 == self.cursor.1);
|
(index + 1 == self.cursor.1);
|
||||||
let style = Some(self.highlight(hi));
|
let style = Some(highlight(self.focused, hi));
|
||||||
let clip = scene.clips.get(track);
|
let clip = scene.clips.get(track);
|
||||||
let index = index as u16;
|
let index = index as u16;
|
||||||
let label = if let Some(Some(clip)) = clip {
|
let label = if let Some(Some(clip)) = clip {
|
||||||
|
|
@ -196,21 +203,29 @@ impl<'a> SceneGridView<'a> {
|
||||||
};
|
};
|
||||||
label.blit(self.buf, x, y + index, style);
|
label.blit(self.buf, x, y + index, style);
|
||||||
}
|
}
|
||||||
index = index + 1;
|
|
||||||
}
|
|
||||||
//let hi = (track + 1 == self.cursor.0) &&
|
|
||||||
//(self.scenes.len() + 1 == self.cursor.1);
|
|
||||||
//"[Add clip…]".blit(self.buf, x, y + index as u16, Some(if hi {
|
|
||||||
//self.highlight(true)
|
|
||||||
//} else {
|
|
||||||
//Style::default().dim()
|
|
||||||
//}));
|
|
||||||
index as u16
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn highlight (&self, highlight: bool) -> Style {
|
fn separator_v (&mut self, x: u16, hi: bool) {
|
||||||
|
let style = Some(highlight(self.focused, hi));
|
||||||
|
for y in self.area.y+1..self.area.y+self.area.height-1 {
|
||||||
|
"┊".blit(self.buf, x, y, style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn longest_scene_name (&self) -> u16 {
|
||||||
|
let mut w = 3u16;
|
||||||
|
for scene in self.scenes.iter() {
|
||||||
|
w = w.max(scene.name.len() as u16);
|
||||||
|
}
|
||||||
|
w
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const HELP: &'static str = "[C-t] Add track [C-a] Add scene [v] Show/hide track";
|
||||||
|
|
||||||
|
fn highlight (focused: bool, highlight: bool) -> Style {
|
||||||
if highlight {
|
if highlight {
|
||||||
if self.focused {
|
if focused {
|
||||||
Style::default().green().not_dim()
|
Style::default().green().not_dim()
|
||||||
} else {
|
} else {
|
||||||
Style::default().green().dim()
|
Style::default().green().dim()
|
||||||
|
|
@ -218,14 +233,4 @@ impl<'a> SceneGridView<'a> {
|
||||||
} else {
|
} else {
|
||||||
Style::default()
|
Style::default()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn separator_v (&mut self, x: u16, highlight: bool) {
|
|
||||||
let style = Some(self.highlight(highlight));
|
|
||||||
for y in self.area.y+1..self.area.y+self.area.height-1 {
|
|
||||||
"┊".blit(self.buf, x, y, style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const HELP: &'static str = "[C-t] Add track [C-a] Add scene [v] Show/hide track";
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue