platform::timeline
This commit is contained in:
parent
c0de520811
commit
6e85b7fa35
16 changed files with 157 additions and 217 deletions
|
@ -37,6 +37,10 @@ pub async fn load_and_get_signal(signal_ref: wellen::SignalRef) -> wellen::Signa
|
|||
platform::load_and_get_signal(signal_ref).await
|
||||
}
|
||||
|
||||
pub async fn timeline(signal_ref: wellen::SignalRef, screen_width: u32) -> shared::Timeline {
|
||||
platform::timeline(signal_ref, screen_width).await
|
||||
}
|
||||
|
||||
pub async fn unload_signal(signal_ref: wellen::SignalRef) {
|
||||
platform::unload_signal(signal_ref).await
|
||||
}
|
||||
|
|
|
@ -91,6 +91,10 @@ pub(super) async fn load_and_get_signal(signal_ref: wellen::SignalRef) -> wellen
|
|||
serde_json::from_value(serde_json::to_value(signal).unwrap_throw()).unwrap_throw()
|
||||
}
|
||||
|
||||
pub(super) async fn timeline(signal_ref: wellen::SignalRef, screen_width: u32) -> shared::Timeline {
|
||||
shared::Timeline { blocks: Vec::new() }
|
||||
}
|
||||
|
||||
pub(super) async fn unload_signal(signal_ref: wellen::SignalRef) {
|
||||
let mut waveform_lock = STORE.waveform.lock().unwrap_throw();
|
||||
let waveform = waveform_lock.as_mut().unwrap_throw();
|
||||
|
|
|
@ -30,6 +30,15 @@ pub(super) async fn load_and_get_signal(signal_ref: wellen::SignalRef) -> wellen
|
|||
.unwrap_throw()
|
||||
}
|
||||
|
||||
pub(super) async fn timeline(signal_ref: wellen::SignalRef, screen_width: u32) -> shared::Timeline {
|
||||
serde_wasm_bindgen::from_value(
|
||||
tauri_glue::timeline(signal_ref.index(), screen_width)
|
||||
.await
|
||||
.unwrap_throw(),
|
||||
)
|
||||
.unwrap_throw()
|
||||
}
|
||||
|
||||
pub(super) async fn unload_signal(signal_ref: wellen::SignalRef) {
|
||||
tauri_glue::unload_signal(signal_ref.index())
|
||||
.await
|
||||
|
@ -57,6 +66,9 @@ mod tauri_glue {
|
|||
#[wasm_bindgen(catch)]
|
||||
pub async fn load_and_get_signal(signal_ref_index: usize) -> Result<JsValue, JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn timeline(signal_ref_index: usize, screen_width: u32) -> Result<JsValue, JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn unload_signal(signal_ref_index: usize) -> Result<(), JsValue>;
|
||||
}
|
||||
|
|
|
@ -117,24 +117,19 @@ impl WaveformPanel {
|
|||
|
||||
let var = hierarchy.get(var_ref);
|
||||
let signal_ref = var.signal_ref();
|
||||
let signal = platform::load_and_get_signal(signal_ref).await;
|
||||
let timeline = platform::timeline(signal_ref, controller.screen_width()).await;
|
||||
|
||||
// @TODO remove
|
||||
zoon::println!("Timeline in Rust: {timeline:#?}");
|
||||
|
||||
let timescale = hierarchy.timescale();
|
||||
// @TODO remove
|
||||
zoon::println!("{timescale:?}");
|
||||
|
||||
let mut timeline: Vec<(wellen::Time, String)> = signal
|
||||
.iter_changes()
|
||||
.map(|(time_index, signal_value)| {
|
||||
(time_table[time_index as usize], signal_value.to_string())
|
||||
})
|
||||
.collect();
|
||||
if timeline.is_empty() {
|
||||
if timeline.blocks.is_empty() {
|
||||
eprintln!("timeline is empty");
|
||||
return;
|
||||
}
|
||||
timeline.push((last_time, timeline.last().cloned().unwrap_throw().1));
|
||||
|
||||
// Note: Sync `timeline`'s type with the `Timeline` in `frontend/typescript/pixi_canvas/pixi_canvas.ts'
|
||||
controller.push_var(serde_wasm_bindgen::to_value(&timeline).unwrap_throw());
|
||||
}
|
||||
|
|
|
@ -100,11 +100,14 @@ mod js_bridge {
|
|||
#[wasm_bindgen(method)]
|
||||
pub async fn init(this: &PixiController, parent_element: &JsValue);
|
||||
|
||||
#[wasm_bindgen(method)]
|
||||
pub fn queue_resize(this: &PixiController);
|
||||
|
||||
#[wasm_bindgen(method)]
|
||||
pub fn destroy(this: &PixiController);
|
||||
|
||||
#[wasm_bindgen(method)]
|
||||
pub fn queue_resize(this: &PixiController);
|
||||
pub fn screen_width(this: &PixiController) -> u32;
|
||||
|
||||
// -- FastWave-specific --
|
||||
|
||||
|
|
Reference in a new issue