hide invisible blocks

This commit is contained in:
Martin Kavík 2024-06-14 01:50:45 +02:00
parent 7a43a9ae4f
commit f324b57f71
3 changed files with 18 additions and 13 deletions

View file

@ -35219,14 +35219,14 @@ var PixiController = class {
}
async zoom_or_pan(wheel_delta_y, shift_key, offset_x) {
if (shift_key) {
this.timeline_viewport_x -= Math.sign(wheel_delta_y) * 20;
this.timeline_viewport_x += Math.sign(wheel_delta_y) * 20;
} else {
const offset_x_ratio = offset_x / this.timeline_viewport_width;
const old_timeline_width = this.timeline_viewport_width * this.timeline_zoom;
this.timeline_zoom -= Math.sign(wheel_delta_y) * 0.1;
this.timeline_zoom -= Math.sign(wheel_delta_y) * this.timeline_zoom * 0.5;
const new_timeline_width = this.timeline_viewport_width * this.timeline_zoom;
const timeline_width_difference = new_timeline_width - old_timeline_width;
this.timeline_viewport_x -= timeline_width_difference * offset_x_ratio;
this.timeline_viewport_x += timeline_width_difference * offset_x_ratio;
}
this.redraw_all_rows();
}
@ -35304,7 +35304,7 @@ var VarSignalRow = class {
this.draw();
}
draw() {
if (this.app.screen === null) {
if (this.app === null || this.app.screen === null) {
return;
}
this.row_container_background.width = this.app.screen.width;

View file

@ -149,15 +149,15 @@ export class PixiController {
async zoom_or_pan(wheel_delta_y: number, shift_key: boolean, offset_x: number) {
if (shift_key) {
this.timeline_viewport_x -= Math.sign(wheel_delta_y) * 20;
this.timeline_viewport_x += Math.sign(wheel_delta_y) * 20;
} else {
// @TODO fix, bounds
// @TODO bounds
const offset_x_ratio = offset_x / this.timeline_viewport_width;
const old_timeline_width = this.timeline_viewport_width * this.timeline_zoom;
this.timeline_zoom -= Math.sign(wheel_delta_y) * 0.1;
this.timeline_zoom -= Math.sign(wheel_delta_y) * this.timeline_zoom * 0.5;
const new_timeline_width = this.timeline_viewport_width * this.timeline_zoom;
const timeline_width_difference = new_timeline_width - old_timeline_width;
this.timeline_viewport_x -= timeline_width_difference * offset_x_ratio;
this.timeline_viewport_x += timeline_width_difference * offset_x_ratio;
}
this.redraw_all_rows();
}
@ -265,7 +265,7 @@ class VarSignalRow {
draw() {
// Screen can be null when we are, for instance, switching between miller columns and tree layout
// and then the canvas has to be recreated
if (this.app.screen === null) {
if (this.app === null || this.app.screen === null) {
return;
}

View file

@ -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);