diff --git a/frontend/src/controls_panel.rs b/frontend/src/controls_panel.rs index c6e6067..7aa86ab 100644 --- a/frontend/src/controls_panel.rs +++ b/frontend/src/controls_panel.rs @@ -3,7 +3,7 @@ use crate::HierarchyAndTimeTable; use std::collections::VecDeque; use std::rc::Rc; use wellen::GetItem; -use zoon::{println, *}; +use zoon::*; #[derive(Clone, Copy)] struct VarForUI<'a> { @@ -61,7 +61,13 @@ impl ControlsPanel { .s(Padding::all(20)) .s(Gap::new().y(40)) .s(Align::new().top()) - .item(self.load_button()) + .item( + Row::new() + .s(Gap::both(15)) + .s(Align::new().left()) + .item(self.load_button("simple.vcd")) + .item(self.load_button("wave_27.fst")) + ) .item_signal( self.hierarchy_and_time_table .signal_cloned() @@ -74,7 +80,7 @@ impl ControlsPanel { ) } - fn load_button(&self) -> impl Element { + fn load_button(&self, test_file_name: &'static str) -> impl Element { let (hovered, hovered_signal) = Mutable::new_and_signal(false); let hierarchy_and_time_table = self.hierarchy_and_time_table.clone(); Button::new() @@ -88,13 +94,13 @@ impl ControlsPanel { El::new().s(Font::new().no_wrap()).child_signal( hierarchy_and_time_table .signal_ref(Option::is_some) - .map_bool(|| "Unload simple.vcd", || "Load simple.vcd"), + .map_bool(|| format!("Unload test file"), move || format!("Load {test_file_name}")), ), ) .on_hovered_change(move |is_hovered| hovered.set_neq(is_hovered)) // @TODO REMOVE .after_insert(clone!((hierarchy_and_time_table) move |_| { - if crate::SIMULATE_CLICKS { + if crate::SIMULATE_CLICKS && test_file_name == "simple.vcd" { let mut hierarchy_and_time_table_lock = hierarchy_and_time_table.lock_mut(); if hierarchy_and_time_table_lock.is_some() { *hierarchy_and_time_table_lock = None; @@ -103,16 +109,18 @@ impl ControlsPanel { drop(hierarchy_and_time_table_lock); let hierarchy_and_time_table = hierarchy_and_time_table.clone(); Task::start(async move { - tauri_bridge::load_waveform().await; + tauri_bridge::load_waveform(test_file_name).await; let hierarchy = tauri_bridge::get_hierarchy().await; - for variable in hierarchy.iter_vars() { - println!("{variable:?}"); - } - for scope in hierarchy.iter_scopes() { - println!("{scope:?}"); - } + // @TODO remove + // for variable in hierarchy.iter_vars() { + // zoon::println!("{variable:?}"); + // } + // for scope in hierarchy.iter_scopes() { + // zoon::println!("{scope:?}"); + // } let time_table = tauri_bridge::get_time_table().await; - println!("{time_table:?}"); + // @TODO remove + // zoon::println!("{time_table:?}"); hierarchy_and_time_table.set(Some((Rc::new(hierarchy), Rc::new(time_table)))) }) } @@ -126,16 +134,18 @@ impl ControlsPanel { drop(hierarchy_and_time_table_lock); let hierarchy_and_time_table = hierarchy_and_time_table.clone(); Task::start(async move { - tauri_bridge::load_waveform().await; + tauri_bridge::load_waveform(test_file_name).await; let hierarchy = tauri_bridge::get_hierarchy().await; - for variable in hierarchy.iter_vars() { - println!("{variable:?}"); - } - for scope in hierarchy.iter_scopes() { - println!("{scope:?}"); - } + // @TODO remove + // for variable in hierarchy.iter_vars() { + // zoon::println!("{variable:?}"); + // } + // for scope in hierarchy.iter_scopes() { + // zoon::println!("{scope:?}"); + // } let time_table = tauri_bridge::get_time_table().await; - println!("{time_table:?}"); + // @TODO remove + // zoon::println!("{time_table:?}"); hierarchy_and_time_table.set(Some((Rc::new(hierarchy), Rc::new(time_table)))) }) }) diff --git a/frontend/src/main.rs b/frontend/src/main.rs index a23c265..2750448 100644 --- a/frontend/src/main.rs +++ b/frontend/src/main.rs @@ -12,7 +12,7 @@ use waveform_panel::WaveformPanel; type HierarchyAndTimeTable = (Rc, Rc); // @TODO REMOVE -const SIMULATE_CLICKS: bool = false; +const SIMULATE_CLICKS: bool = true; fn main() { start_app("app", root); diff --git a/frontend/src/tauri_bridge.rs b/frontend/src/tauri_bridge.rs index 68a3468..4358c01 100644 --- a/frontend/src/tauri_bridge.rs +++ b/frontend/src/tauri_bridge.rs @@ -4,8 +4,8 @@ pub async fn show_window() { tauri_glue::show_window().await } -pub async fn load_waveform() { - tauri_glue::load_waveform().await +pub async fn load_waveform(test_file_name: &'static str) { + tauri_glue::load_waveform(test_file_name).await } pub async fn get_hierarchy() -> wellen::Hierarchy { @@ -33,7 +33,7 @@ mod tauri_glue { extern "C" { pub async fn show_window(); - pub async fn load_waveform(); + pub async fn load_waveform(test_file_name: &str); pub async fn get_hierarchy() -> JsValue; diff --git a/frontend/typescript/bundles/tauri_glue.js b/frontend/typescript/bundles/tauri_glue.js index ab2584c..a8b60a0 100644 --- a/frontend/typescript/bundles/tauri_glue.js +++ b/frontend/typescript/bundles/tauri_glue.js @@ -2514,8 +2514,8 @@ var invoke2 = core_exports.invoke; async function show_window() { return await invoke2("show_window"); } -async function load_waveform() { - return await invoke2("load_waveform"); +async function load_waveform(test_file_name) { + return await invoke2("load_waveform", { test_file_name }); } async function get_hierarchy() { return await invoke2("get_hierarchy"); diff --git a/frontend/typescript/tauri_glue/tauri_glue.ts b/frontend/typescript/tauri_glue/tauri_glue.ts index 6ba1d8c..8bb13f8 100644 --- a/frontend/typescript/tauri_glue/tauri_glue.ts +++ b/frontend/typescript/tauri_glue/tauri_glue.ts @@ -12,8 +12,8 @@ export async function show_window(): Promise { return await invoke("show_window"); } -export async function load_waveform(): Promise { - return await invoke("load_waveform"); +export async function load_waveform(test_file_name: string): Promise { + return await invoke("load_waveform", { test_file_name }); } export async function get_hierarchy(): Promise { diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index f248e47..0993d82 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,4 +1,5 @@ use std::sync::Mutex; +use std::rc::Rc; use wellen::simple::Waveform; mod wellen_helpers; @@ -14,9 +15,15 @@ fn show_window(window: tauri::Window) { } #[tauri::command(rename_all = "snake_case")] -fn load_waveform(store: tauri::State) { - let waveform = - wellen_helpers::read_from_bytes(include_bytes!("../../test_files/simple.vcd").to_vec()); +fn load_waveform(test_file_name: Rc, store: tauri::State) { + static SIMPLE_VCD: &'static[u8; 311] = include_bytes!("../../test_files/simple.vcd"); + static WAVE_27_FST: &'static[u8; 28860652] = include_bytes!("../../test_files/wave_27.fst"); + let chosen_file = match test_file_name.as_str() { + "simple.vcd" => SIMPLE_VCD.to_vec(), + "wave_27.fst" => WAVE_27_FST.to_vec(), + test_file_name => todo!("add {test_file_name} to the `test_files` folder") + }; + let waveform = wellen_helpers::read_from_bytes(chosen_file); let Ok(waveform) = waveform else { panic!("VCD file reading failed") }; diff --git a/test_files/wave_27.fst b/test_files/wave_27.fst new file mode 100644 index 0000000..a573595 Binary files /dev/null and b/test_files/wave_27.fst differ