set_var_format

This commit is contained in:
Martin Kavík 2024-06-09 22:53:02 +02:00
parent d654714c0d
commit 1881d62c56
11 changed files with 145 additions and 35 deletions

View file

@ -33,8 +33,9 @@ pub async fn load_signal_and_get_timeline(
signal_ref: wellen::SignalRef, signal_ref: wellen::SignalRef,
screen_width: u32, screen_width: u32,
block_height: u32, block_height: u32,
var_format: shared::VarFormat,
) -> shared::Timeline { ) -> shared::Timeline {
platform::load_signal_and_get_timeline(signal_ref, screen_width, block_height).await platform::load_signal_and_get_timeline(signal_ref, screen_width, block_height, var_format).await
} }
pub async fn unload_signal(signal_ref: wellen::SignalRef) { pub async fn unload_signal(signal_ref: wellen::SignalRef) {

View file

@ -78,13 +78,14 @@ pub(super) async fn load_signal_and_get_timeline(
signal_ref: wellen::SignalRef, signal_ref: wellen::SignalRef,
screen_width: u32, screen_width: u32,
block_height: u32, block_height: u32,
var_format: shared::VarFormat,
) -> shared::Timeline { ) -> shared::Timeline {
let mut waveform_lock = STORE.waveform.lock().unwrap(); let mut waveform_lock = STORE.waveform.lock().unwrap();
let waveform = waveform_lock.as_mut().unwrap(); let waveform = waveform_lock.as_mut().unwrap();
waveform.load_signals_multi_threaded(&[signal_ref]); waveform.load_signals_multi_threaded(&[signal_ref]);
let signal = waveform.get_signal(signal_ref).unwrap(); let signal = waveform.get_signal(signal_ref).unwrap();
let time_table = waveform.time_table(); 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);
timeline timeline
} }
@ -100,11 +101,12 @@ fn signal_to_timeline(
time_table: &[wellen::Time], time_table: &[wellen::Time],
screen_width: u32, screen_width: u32,
block_height: u32, block_height: u32,
var_format: shared::VarFormat,
) -> shared::Timeline { ) -> shared::Timeline {
const MIN_BLOCK_WIDTH: u32 = 3; const MIN_BLOCK_WIDTH: u32 = 3;
// Courier New, 16px, sync with `label_style` in `pixi_canvas.rs` // Courier New, 16px, sync with `label_style` in `pixi_canvas.rs`
const LETTER_WIDTH: f64 = 9.61; const LETTER_WIDTH: f64 = 9.61;
const LETTER_HEIGHT: u32 = 21; const LETTER_HEIGHT: u32 = 18;
const LABEL_X_PADDING: u32 = 10; const LABEL_X_PADDING: u32 = 10;
let Some(last_time) = time_table.last().copied() else { let Some(last_time) = time_table.last().copied() else {
@ -139,7 +141,7 @@ fn signal_to_timeline(
} }
// @TODO cache? // @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; let value_width = (value.chars().count() as f64 * LETTER_WIDTH) as u32;
// @TODO Ellipsis instead of hiding? // @TODO Ellipsis instead of hiding?

View file

@ -21,11 +21,18 @@ pub(super) async fn load_signal_and_get_timeline(
signal_ref: wellen::SignalRef, signal_ref: wellen::SignalRef,
screen_width: u32, screen_width: u32,
block_height: u32, block_height: u32,
var_format: shared::VarFormat,
) -> shared::Timeline { ) -> shared::Timeline {
let var_format = serde_wasm_bindgen::to_value(&var_format).unwrap_throw();
serde_wasm_bindgen::from_value( serde_wasm_bindgen::from_value(
tauri_glue::load_signal_and_get_timeline(signal_ref.index(), screen_width, block_height) tauri_glue::load_signal_and_get_timeline(
.await signal_ref.index(),
.unwrap_throw(), screen_width,
block_height,
var_format,
)
.await
.unwrap_throw(),
) )
.unwrap_throw() .unwrap_throw()
} }
@ -56,6 +63,7 @@ mod tauri_glue {
signal_ref_index: usize, signal_ref_index: usize,
screen_width: u32, screen_width: u32,
block_height: u32, block_height: u32,
var_format: JsValue,
) -> Result<JsValue, JsValue>; ) -> Result<JsValue, JsValue>;
#[wasm_bindgen(catch)] #[wasm_bindgen(catch)]

View file

@ -13,6 +13,7 @@ const ROW_GAP: u32 = 4;
pub struct WaveformPanel { pub struct WaveformPanel {
selected_var_refs: MutableVec<wellen::VarRef>, selected_var_refs: MutableVec<wellen::VarRef>,
hierarchy: Mutable<Option<Rc<wellen::Hierarchy>>>, hierarchy: Mutable<Option<Rc<wellen::Hierarchy>>>,
canvas_controller: Mutable<ReadOnlyMutable<Option<PixiController>>>,
} }
impl WaveformPanel { impl WaveformPanel {
@ -23,6 +24,7 @@ impl WaveformPanel {
Self { Self {
selected_var_refs, selected_var_refs,
hierarchy, hierarchy,
canvas_controller: Mutable::new(Mutable::default().read_only()),
} }
.root() .root()
} }
@ -54,11 +56,13 @@ impl WaveformPanel {
fn canvas(&self, selected_vars_panel_height: ReadOnlyMutable<u32>) -> impl Element { fn canvas(&self, selected_vars_panel_height: ReadOnlyMutable<u32>) -> impl Element {
let selected_var_refs = self.selected_var_refs.clone(); let selected_var_refs = self.selected_var_refs.clone();
let hierarchy = self.hierarchy.clone(); let hierarchy = self.hierarchy.clone();
let canvas_controller = self.canvas_controller.clone();
PixiCanvas::new(ROW_HEIGHT, ROW_GAP) PixiCanvas::new(ROW_HEIGHT, ROW_GAP)
.s(Align::new().top()) .s(Align::new().top())
.s(Width::fill()) .s(Width::fill())
.s(Height::exact_signal(selected_vars_panel_height.signal())) .s(Height::exact_signal(selected_vars_panel_height.signal()))
.task_with_controller(move |controller| { .task_with_controller(move |controller| {
canvas_controller.set(controller.clone());
selected_var_refs.signal_vec().delay_remove(clone!((hierarchy) move |var_ref| { selected_var_refs.signal_vec().delay_remove(clone!((hierarchy) move |var_ref| {
clone!((var_ref, hierarchy) async move { clone!((var_ref, hierarchy) async move {
if let Some(hierarchy) = hierarchy.get_cloned() { if let Some(hierarchy) = hierarchy.get_cloned() {
@ -112,12 +116,15 @@ impl WaveformPanel {
) { ) {
let hierarchy = hierarchy.get_cloned().unwrap(); let hierarchy = hierarchy.get_cloned().unwrap();
let var_format = shared::VarFormat::default();
let var = hierarchy.get(var_ref); let var = hierarchy.get(var_ref);
let signal_ref = var.signal_ref(); let signal_ref = var.signal_ref();
let timeline = platform::load_signal_and_get_timeline( let timeline = platform::load_signal_and_get_timeline(
signal_ref, signal_ref,
controller.screen_width(), controller.screen_width(),
ROW_HEIGHT, ROW_HEIGHT,
var_format,
) )
.await; .await;
@ -128,7 +135,8 @@ impl WaveformPanel {
// Note: Sync `timeline`'s type with the `Timeline` in `frontend/typescript/pixi_canvas/pixi_canvas.ts' // Note: Sync `timeline`'s type with the `Timeline` in `frontend/typescript/pixi_canvas/pixi_canvas.ts'
let timeline = serde_wasm_bindgen::to_value(&timeline).unwrap_throw(); let timeline = serde_wasm_bindgen::to_value(&timeline).unwrap_throw();
let signal_ref_index = signal_ref.index(); let signal_ref_index = signal_ref.index();
controller.push_var(signal_ref_index, timeline); let var_format = serde_wasm_bindgen::to_value(&var_format).unwrap_throw();
controller.push_var(signal_ref_index, timeline, var_format);
} }
fn selected_var_panel( fn selected_var_panel(
@ -141,8 +149,8 @@ impl WaveformPanel {
}; };
let var = hierarchy.get(var_ref); let var = hierarchy.get(var_ref);
Row::new() Row::new()
.item(self.selected_var_name_button(var.name(&hierarchy), index)) .item(self.selected_var_name_button(var.name(&hierarchy), index.clone()))
.item(self.selected_var_format_button()) .item(self.selected_var_format_button(index))
.apply(Some) .apply(Some)
} }
@ -174,9 +182,10 @@ impl WaveformPanel {
}) })
} }
fn selected_var_format_button(&self) -> impl Element { fn selected_var_format_button(&self, index: ReadOnlyMutable<Option<usize>>) -> impl Element {
let var_format = Mutable::new(shared::VarFormat::default()); let var_format = Mutable::new(shared::VarFormat::default());
let (hovered, hovered_signal) = Mutable::new_and_signal(false); let (hovered, hovered_signal) = Mutable::new_and_signal(false);
let canvas_controller = self.canvas_controller.clone();
Button::new() Button::new()
.s(Height::exact(ROW_HEIGHT)) .s(Height::exact(ROW_HEIGHT))
.s(Width::exact(70)) .s(Width::exact(70))
@ -191,6 +200,18 @@ impl WaveformPanel {
.child_signal(var_format.signal().map(|format| format.as_static_str())), .child_signal(var_format.signal().map(|format| format.as_static_str())),
) )
.on_hovered_change(move |is_hovered| hovered.set_neq(is_hovered)) .on_hovered_change(move |is_hovered| hovered.set_neq(is_hovered))
.on_press(move || var_format.update(|format| format.next())) .on_press(move || {
let next_format = var_format.get().next();
var_format.set(next_format);
if let Some(canvas_controller) = canvas_controller.get_cloned().lock_ref().as_ref()
{
if let Some(index) = index.get() {
canvas_controller.set_var_format(
index,
serde_wasm_bindgen::to_value(&next_format).unwrap_throw(),
);
}
}
})
} }
} }

View file

@ -52,13 +52,14 @@ impl PixiCanvas {
let task_with_controller = Mutable::new(None); let task_with_controller = Mutable::new(None);
// -- FastWave-specific -- // -- FastWave-specific --
let timeline_getter = Rc::new(Closure::new( let timeline_getter = Rc::new(Closure::new(
|signal_ref_index, screen_width, row_height| { |signal_ref_index, screen_width, row_height, var_format| {
future_to_promise(async move { future_to_promise(async move {
let signal_ref = wellen::SignalRef::from_index(signal_ref_index).unwrap_throw(); let signal_ref = wellen::SignalRef::from_index(signal_ref_index).unwrap_throw();
let timeline = platform::load_signal_and_get_timeline( let timeline = platform::load_signal_and_get_timeline(
signal_ref, signal_ref,
screen_width, screen_width,
row_height, row_height,
serde_wasm_bindgen::from_value(var_format).unwrap_throw(),
) )
.await; .await;
let timeline = serde_wasm_bindgen::to_value(&timeline).unwrap_throw(); let timeline = serde_wasm_bindgen::to_value(&timeline).unwrap_throw();
@ -114,8 +115,9 @@ mod js_bridge {
type SignalRefIndex = usize; type SignalRefIndex = usize;
type ScreenWidth = u32; type ScreenWidth = u32;
type RowHeight = u32; type RowHeight = u32;
type VarFormatJs = JsValue;
type TimelineGetter = type TimelineGetter =
Closure<dyn FnMut(SignalRefIndex, ScreenWidth, RowHeight) -> TimelinePromise>; Closure<dyn FnMut(SignalRefIndex, ScreenWidth, RowHeight, VarFormatJs) -> TimelinePromise>;
// Note: Add all corresponding methods to `frontend/typescript/pixi_canvas/pixi_canvas.ts` // Note: Add all corresponding methods to `frontend/typescript/pixi_canvas/pixi_canvas.ts`
#[wasm_bindgen(module = "/typescript/bundles/pixi_canvas.js")] #[wasm_bindgen(module = "/typescript/bundles/pixi_canvas.js")]
@ -145,11 +147,19 @@ mod js_bridge {
// -- FastWave-specific -- // -- FastWave-specific --
#[wasm_bindgen(method)]
pub fn set_var_format(this: &PixiController, index: usize, var_format: JsValue);
#[wasm_bindgen(method)] #[wasm_bindgen(method)]
pub fn remove_var(this: &PixiController, index: usize); pub fn remove_var(this: &PixiController, index: usize);
#[wasm_bindgen(method)] #[wasm_bindgen(method)]
pub fn push_var(this: &PixiController, signal_ref_index: usize, timeline: JsValue); pub fn push_var(
this: &PixiController,
signal_ref_index: usize,
timeline: JsValue,
var_format: JsValue,
);
#[wasm_bindgen(method)] #[wasm_bindgen(method)]
pub fn pop_var(this: &PixiController); pub fn pop_var(this: &PixiController);

View file

@ -35156,7 +35156,7 @@ var PixiController = class {
const width_changed = width !== this.previous_parent_width; const width_changed = width !== this.previous_parent_width;
this.previous_parent_width = width; this.previous_parent_width = width;
if (width_changed) { if (width_changed) {
await this.redraw_rows(); await this.redraw_all_rows();
} }
} }
destroy() { destroy() {
@ -35175,20 +35175,35 @@ var PixiController = class {
return this.app.screen.width; return this.app.screen.width;
} }
// -- FastWave-specific -- // -- FastWave-specific --
async redraw_rows() { async redraw_all_rows() {
await Promise.all(this.var_signal_rows.map(async (row) => { await Promise.all(this.var_signal_rows.map(async (row) => {
const timeline = await this.timeline_getter(row.signal_ref_index, this.app.screen.width, this.row_height); const timeline = await this.timeline_getter(row.signal_ref_index, this.app.screen.width, this.row_height, row.var_format);
row.redraw(timeline); row.redraw(timeline);
})); }));
} }
async redraw_row(index) {
const row = this.var_signal_rows[index];
if (typeof row !== "undefined") {
const timeline = await this.timeline_getter(row.signal_ref_index, this.app.screen.width, this.row_height, row.var_format);
row.redraw(timeline);
}
}
async set_var_format(index, var_format) {
const row = this.var_signal_rows[index];
if (typeof row !== "undefined") {
row.set_var_format(var_format);
this.redraw_row(index);
}
}
remove_var(index) { remove_var(index) {
if (typeof this.var_signal_rows[index] !== "undefined") { if (typeof this.var_signal_rows[index] !== "undefined") {
this.var_signal_rows[index].destroy(); this.var_signal_rows[index].destroy();
} }
} }
push_var(signal_ref_index, timeline) { push_var(signal_ref_index, timeline, var_format) {
new VarSignalRow( new VarSignalRow(
signal_ref_index, signal_ref_index,
var_format,
timeline, timeline,
this.app, this.app,
this.var_signal_rows, this.var_signal_rows,
@ -35206,6 +35221,7 @@ var PixiController = class {
}; };
var VarSignalRow = class { var VarSignalRow = class {
signal_ref_index; signal_ref_index;
var_format;
timeline; timeline;
app; app;
owner; owner;
@ -35223,8 +35239,9 @@ var VarSignalRow = class {
fontSize: 16, fontSize: 16,
fontFamily: '"Courier New", monospace' fontFamily: '"Courier New", monospace'
}); });
constructor(signal_ref_index, timeline, app, owner, rows_container, row_height, row_gap) { constructor(signal_ref_index, var_format, timeline, app, owner, rows_container, row_height, row_gap) {
this.signal_ref_index = signal_ref_index; this.signal_ref_index = signal_ref_index;
this.var_format = var_format;
this.timeline = timeline; this.timeline = timeline;
this.app = app; this.app = app;
this.row_height = row_height; this.row_height = row_height;
@ -35244,6 +35261,9 @@ var VarSignalRow = class {
this.row_container.addChild(this.signal_blocks_container); this.row_container.addChild(this.signal_blocks_container);
this.draw(); this.draw();
} }
set_var_format(var_format) {
this.var_format = var_format;
}
redraw(timeline) { redraw(timeline) {
this.timeline = timeline; this.timeline = timeline;
this.draw(); this.draw();

View file

@ -2520,8 +2520,8 @@ async function pick_and_load_waveform() {
async function get_hierarchy() { async function get_hierarchy() {
return await invoke2("get_hierarchy"); return await invoke2("get_hierarchy");
} }
async function load_signal_and_get_timeline(signal_ref_index, screen_width, block_height) { async function load_signal_and_get_timeline(signal_ref_index, screen_width, block_height, var_format) {
return await invoke2("load_signal_and_get_timeline", { signal_ref_index, screen_width, block_height }); return await invoke2("load_signal_and_get_timeline", { signal_ref_index, screen_width, block_height, var_format });
} }
async function unload_signal(signal_ref_index) { async function unload_signal(signal_ref_index) {
return await invoke2("unload_signal", { signal_ref_index }); return await invoke2("unload_signal", { signal_ref_index });

View file

@ -16,7 +16,18 @@ type TimeLineBlockLabel = {
y: number, y: number,
} }
type TimelineGetter = (signal_ref_index: number, screen_width: number, row_height: number) => Promise<Timeline>; // @TODO sync with Rust
enum VarFormat {
ASCII,
Binary,
BinaryWithGroups,
Hexadecimal,
Octal,
Signed,
Unsigned,
}
type TimelineGetter = (signal_ref_index: number, screen_width: number, row_height: number, var_format: VarFormat) => Promise<Timeline>;
export class PixiController { export class PixiController {
app: Application app: Application
@ -26,7 +37,7 @@ export class PixiController {
row_height: number; row_height: number;
row_gap: number; row_gap: number;
previous_parent_width: number | null; previous_parent_width: number | null;
timeline_getter: TimelineGetter timeline_getter: TimelineGetter;
constructor(row_height: number, row_gap: number, timeline_getter: TimelineGetter) { constructor(row_height: number, row_gap: number, timeline_getter: TimelineGetter) {
this.app = new Application(); this.app = new Application();
@ -51,7 +62,7 @@ export class PixiController {
const width_changed = width !== this.previous_parent_width; const width_changed = width !== this.previous_parent_width;
this.previous_parent_width = width; this.previous_parent_width = width;
if (width_changed) { if (width_changed) {
await this.redraw_rows(); await this.redraw_all_rows();
} }
} }
@ -74,22 +85,39 @@ export class PixiController {
// -- FastWave-specific -- // -- FastWave-specific --
async redraw_rows() { async redraw_all_rows() {
await Promise.all(this.var_signal_rows.map(async row => { await Promise.all(this.var_signal_rows.map(async row => {
const timeline = await this.timeline_getter(row.signal_ref_index, this.app.screen.width, this.row_height); const timeline = await this.timeline_getter(row.signal_ref_index, this.app.screen.width, this.row_height, row.var_format);
row.redraw(timeline); row.redraw(timeline);
})) }))
} }
async redraw_row(index: number) {
const row = this.var_signal_rows[index];
if (typeof row !== 'undefined') {
const timeline = await this.timeline_getter(row.signal_ref_index, this.app.screen.width, this.row_height, row.var_format);
row.redraw(timeline);
}
}
async set_var_format(index: number, var_format: VarFormat) {
const row = this.var_signal_rows[index];
if (typeof row !== 'undefined') {
row.set_var_format(var_format);
this.redraw_row(index);
}
}
remove_var(index: number) { remove_var(index: number) {
if (typeof this.var_signal_rows[index] !== 'undefined') { if (typeof this.var_signal_rows[index] !== 'undefined') {
this.var_signal_rows[index].destroy(); this.var_signal_rows[index].destroy();
} }
} }
push_var(signal_ref_index: number, timeline: Timeline) { push_var(signal_ref_index: number, timeline: Timeline, var_format: VarFormat) {
new VarSignalRow( new VarSignalRow(
signal_ref_index, signal_ref_index,
var_format,
timeline, timeline,
this.app, this.app,
this.var_signal_rows, this.var_signal_rows,
@ -110,6 +138,7 @@ export class PixiController {
class VarSignalRow { class VarSignalRow {
signal_ref_index: number; signal_ref_index: number;
var_format: VarFormat;
timeline: Timeline; timeline: Timeline;
app: Application; app: Application;
owner: Array<VarSignalRow>; owner: Array<VarSignalRow>;
@ -130,6 +159,7 @@ class VarSignalRow {
constructor( constructor(
signal_ref_index: number, signal_ref_index: number,
var_format: VarFormat,
timeline: Timeline, timeline: Timeline,
app: Application, app: Application,
owner: Array<VarSignalRow>, owner: Array<VarSignalRow>,
@ -138,6 +168,7 @@ class VarSignalRow {
row_gap: number, row_gap: number,
) { ) {
this.signal_ref_index = signal_ref_index; this.signal_ref_index = signal_ref_index;
this.var_format = var_format;
this.timeline = timeline; this.timeline = timeline;
this.app = app; this.app = app;
@ -168,6 +199,10 @@ class VarSignalRow {
this.draw(); this.draw();
} }
set_var_format(var_format: VarFormat) {
this.var_format = var_format;
}
redraw(timeline: Timeline) { redraw(timeline: Timeline) {
this.timeline = timeline; this.timeline = timeline;
this.draw(); this.draw();

View file

@ -9,6 +9,7 @@ type WellenHierarchy = unknown;
type WellenTimeTable = unknown; type WellenTimeTable = unknown;
type WellenSignal = unknown; type WellenSignal = unknown;
type Timeline = unknown; type Timeline = unknown;
type VarFormat = unknown;
export async function show_window(): Promise<void> { export async function show_window(): Promise<void> {
return await invoke("show_window"); return await invoke("show_window");
@ -22,8 +23,13 @@ export async function get_hierarchy(): Promise<WellenHierarchy> {
return await invoke("get_hierarchy"); return await invoke("get_hierarchy");
} }
export async function load_signal_and_get_timeline(signal_ref_index: number, screen_width: number, block_height: number): Promise<Timeline> { export async function load_signal_and_get_timeline(
return await invoke("load_signal_and_get_timeline", { signal_ref_index, screen_width, block_height }); signal_ref_index: number,
screen_width: number,
block_height: number,
var_format: VarFormat,
): Promise<Timeline> {
return await invoke("load_signal_and_get_timeline", { signal_ref_index, screen_width, block_height, var_format });
} }
export async function unload_signal(signal_ref_index: number): Promise<void> { export async function unload_signal(signal_ref_index: number): Promise<void> {

View file

@ -1,4 +1,7 @@
#[derive(Default, Clone, Copy, Debug)] use moonlight::*;
#[derive(Default, Clone, Copy, Debug, Serialize, Deserialize)]
#[serde(crate = "serde")]
pub enum VarFormat { pub enum VarFormat {
ASCII, ASCII,
Binary, Binary,
@ -55,12 +58,14 @@ impl VarFormat {
} }
VarFormat::Binary => value, VarFormat::Binary => value,
VarFormat::BinaryWithGroups => { VarFormat::BinaryWithGroups => {
let char_count = value.len();
value value
.chars() .chars()
.enumerate() .enumerate()
.fold(String::new(), |mut value, (index, one_or_zero)| { .fold(String::new(), |mut value, (index, one_or_zero)| {
value.push(one_or_zero); value.push(one_or_zero);
if (index + 1) % 4 == 0 { let is_last = index == char_count - 1;
if !is_last && (index + 1) % 4 == 0 {
value.push(' '); value.push(' ');
} }
value value

View file

@ -44,6 +44,7 @@ async fn load_signal_and_get_timeline(
signal_ref_index: usize, signal_ref_index: usize,
screen_width: u32, screen_width: u32,
block_height: u32, block_height: u32,
var_format: shared::VarFormat,
store: tauri::State<'_, Store>, store: tauri::State<'_, Store>,
) -> Result<serde_json::Value, ()> { ) -> Result<serde_json::Value, ()> {
// @TODO run (all?) in a blocking thread? // @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]); waveform.load_signals_multi_threaded(&[signal_ref]);
let signal = waveform.get_signal(signal_ref).unwrap(); let signal = waveform.get_signal(signal_ref).unwrap();
let time_table = waveform.time_table(); 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()) Ok(serde_json::to_value(timeline).unwrap())
} }
@ -94,11 +95,12 @@ fn signal_to_timeline(
time_table: &[wellen::Time], time_table: &[wellen::Time],
screen_width: u32, screen_width: u32,
block_height: u32, block_height: u32,
var_format: shared::VarFormat,
) -> shared::Timeline { ) -> shared::Timeline {
const MIN_BLOCK_WIDTH: u32 = 3; const MIN_BLOCK_WIDTH: u32 = 3;
// Courier New, 16px, sync with `label_style` in `pixi_canvas.rs` // Courier New, 16px, sync with `label_style` in `pixi_canvas.rs`
const LETTER_WIDTH: f64 = 9.61; const LETTER_WIDTH: f64 = 9.61;
const LETTER_HEIGHT: u32 = 21; const LETTER_HEIGHT: u32 = 18;
const LABEL_X_PADDING: u32 = 10; const LABEL_X_PADDING: u32 = 10;
let Some(last_time) = time_table.last().copied() else { let Some(last_time) = time_table.last().copied() else {
@ -133,7 +135,7 @@ fn signal_to_timeline(
} }
// @TODO cache? // @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; let value_width = (value.chars().count() as f64 * LETTER_WIDTH) as u32;
// @TODO Ellipsis instead of hiding? // @TODO Ellipsis instead of hiding?