timeline_width/viewport_width/viewport_x
This commit is contained in:
parent
48dad951a5
commit
7107f77c82
11 changed files with 188 additions and 37 deletions
|
@ -3,29 +3,39 @@ use crate::*;
|
|||
pub fn signal_to_timeline(
|
||||
signal: &wellen::Signal,
|
||||
time_table: &[wellen::Time],
|
||||
screen_width: u32,
|
||||
mut timeline_width: u32,
|
||||
timeline_viewport_width: u32,
|
||||
timeline_viewport_x: u32,
|
||||
block_height: u32,
|
||||
var_format: VarFormat,
|
||||
) -> Timeline {
|
||||
println!("timeline_width: {timeline_width}");
|
||||
println!("timeline_viewport_width: {timeline_viewport_width}");
|
||||
println!("timeline_viewport_x: {timeline_viewport_x}");
|
||||
println!("_____");
|
||||
const MIN_BLOCK_WIDTH: u32 = 3;
|
||||
// Courier New, 16px, sync with `label_style` in `pixi_canvas.rs`
|
||||
const LETTER_WIDTH: f64 = 9.61;
|
||||
const LETTER_HEIGHT: u32 = 18;
|
||||
const LABEL_X_PADDING: u32 = 10;
|
||||
|
||||
if timeline_width == 0 {
|
||||
timeline_width = timeline_viewport_width;
|
||||
}
|
||||
|
||||
let Some(last_time) = time_table.last().copied() else {
|
||||
return Timeline::default();
|
||||
};
|
||||
|
||||
let last_time = last_time as f64;
|
||||
let screen_width = screen_width as f64;
|
||||
let timeline_width = timeline_width as f64;
|
||||
|
||||
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 * screen_width;
|
||||
let x = time / last_time * timeline_width;
|
||||
(x, value)
|
||||
})
|
||||
.peekable();
|
||||
|
@ -36,7 +46,7 @@ pub fn signal_to_timeline(
|
|||
let next_block_x = if let Some((next_block_x, _)) = x_value_pairs.peek() {
|
||||
*next_block_x
|
||||
} else {
|
||||
screen_width
|
||||
timeline_width
|
||||
};
|
||||
|
||||
let block_width = (next_block_x - block_x) as u32;
|
||||
|
|
Reference in a new issue