hide invisible blocks
This commit is contained in:
parent
e934ac031d
commit
257b83b582
3 changed files with 18 additions and 13 deletions
|
@ -23,14 +23,12 @@ pub fn signal_to_timeline(
|
|||
let timeline_viewport_x = timeline_viewport_x as f64;
|
||||
let timeline_width = timeline_viewport_width as f64 * timeline_zoom;
|
||||
|
||||
// @TODO hide blocks not visible in the viewport
|
||||
|
||||
let mut x_value_pairs = signal
|
||||
.iter_changes()
|
||||
.map(|(index, value)| {
|
||||
let index = index as usize;
|
||||
let time = time_table[index] as f64;
|
||||
let x = time / last_time * timeline_width + timeline_viewport_x;
|
||||
let x = time / last_time * timeline_width - timeline_viewport_x;
|
||||
(x, value)
|
||||
})
|
||||
.peekable();
|
||||
|
@ -38,16 +36,23 @@ pub fn signal_to_timeline(
|
|||
// @TODO parallelize?
|
||||
let mut blocks = Vec::new();
|
||||
while let Some((block_x, value)) = x_value_pairs.next() {
|
||||
if block_x >= (timeline_viewport_width as f64) {
|
||||
break;
|
||||
}
|
||||
|
||||
let next_block_x = if let Some((next_block_x, _)) = x_value_pairs.peek() {
|
||||
*next_block_x
|
||||
} else {
|
||||
timeline_width + timeline_viewport_x
|
||||
timeline_width - timeline_viewport_x
|
||||
};
|
||||
|
||||
let block_width = (next_block_x - block_x) as u32;
|
||||
if block_width < MIN_BLOCK_WIDTH {
|
||||
continue;
|
||||
}
|
||||
if block_x + (block_width as f64) <= 0. {
|
||||
continue;
|
||||
}
|
||||
|
||||
// @TODO cache?
|
||||
let value = var_format.format(value);
|
||||
|
|
Reference in a new issue