set_var_format
This commit is contained in:
parent
d654714c0d
commit
1881d62c56
11 changed files with 145 additions and 35 deletions
|
@ -44,6 +44,7 @@ async fn load_signal_and_get_timeline(
|
|||
signal_ref_index: usize,
|
||||
screen_width: u32,
|
||||
block_height: u32,
|
||||
var_format: shared::VarFormat,
|
||||
store: tauri::State<'_, Store>,
|
||||
) -> Result<serde_json::Value, ()> {
|
||||
// @TODO run (all?) in a blocking thread?
|
||||
|
@ -53,7 +54,7 @@ async fn load_signal_and_get_timeline(
|
|||
waveform.load_signals_multi_threaded(&[signal_ref]);
|
||||
let signal = waveform.get_signal(signal_ref).unwrap();
|
||||
let time_table = waveform.time_table();
|
||||
let timeline = signal_to_timeline(signal, time_table, screen_width, block_height);
|
||||
let timeline = signal_to_timeline(signal, time_table, screen_width, block_height, var_format);
|
||||
Ok(serde_json::to_value(timeline).unwrap())
|
||||
}
|
||||
|
||||
|
@ -94,11 +95,12 @@ fn signal_to_timeline(
|
|||
time_table: &[wellen::Time],
|
||||
screen_width: u32,
|
||||
block_height: u32,
|
||||
var_format: shared::VarFormat,
|
||||
) -> shared::Timeline {
|
||||
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 = 21;
|
||||
const LETTER_HEIGHT: u32 = 18;
|
||||
const LABEL_X_PADDING: u32 = 10;
|
||||
|
||||
let Some(last_time) = time_table.last().copied() else {
|
||||
|
@ -133,7 +135,7 @@ fn signal_to_timeline(
|
|||
}
|
||||
|
||||
// @TODO cache?
|
||||
let value = shared::VarFormat::default().format(value);
|
||||
let value = var_format.format(value);
|
||||
|
||||
let value_width = (value.chars().count() as f64 * LETTER_WIDTH) as u32;
|
||||
// @TODO Ellipsis instead of hiding?
|
||||
|
|
Reference in a new issue