timeline_width/viewport_width/viewport_x
This commit is contained in:
parent
48dad951a5
commit
7107f77c82
11 changed files with 188 additions and 37 deletions
|
@ -31,11 +31,20 @@ pub async fn get_hierarchy() -> wellen::Hierarchy {
|
|||
|
||||
pub async fn load_signal_and_get_timeline(
|
||||
signal_ref: wellen::SignalRef,
|
||||
screen_width: u32,
|
||||
timeline_width: u32,
|
||||
timeline_viewport_width: u32,
|
||||
timeline_viewport_x: u32,
|
||||
block_height: u32,
|
||||
var_format: shared::VarFormat,
|
||||
) -> shared::Timeline {
|
||||
platform::load_signal_and_get_timeline(signal_ref, screen_width, block_height, var_format).await
|
||||
platform::load_signal_and_get_timeline(
|
||||
signal_ref,
|
||||
timeline_width,
|
||||
timeline_viewport_width,
|
||||
timeline_viewport_x,
|
||||
block_height,
|
||||
var_format,
|
||||
).await
|
||||
}
|
||||
|
||||
pub async fn unload_signal(signal_ref: wellen::SignalRef) {
|
||||
|
|
|
@ -76,7 +76,9 @@ pub(super) async fn get_hierarchy() -> wellen::Hierarchy {
|
|||
|
||||
pub(super) async fn load_signal_and_get_timeline(
|
||||
signal_ref: wellen::SignalRef,
|
||||
screen_width: u32,
|
||||
timeline_width: u32,
|
||||
timeline_viewport_width: u32,
|
||||
timeline_viewport_x: u32,
|
||||
block_height: u32,
|
||||
var_format: shared::VarFormat,
|
||||
) -> shared::Timeline {
|
||||
|
@ -86,7 +88,15 @@ pub(super) async fn load_signal_and_get_timeline(
|
|||
let signal = waveform.get_signal(signal_ref).unwrap();
|
||||
let time_table = waveform.time_table();
|
||||
let timeline =
|
||||
shared::signal_to_timeline(signal, time_table, screen_width, block_height, var_format);
|
||||
shared::signal_to_timeline(
|
||||
signal,
|
||||
time_table,
|
||||
timeline_width,
|
||||
timeline_viewport_width,
|
||||
timeline_viewport_x,
|
||||
block_height,
|
||||
var_format,
|
||||
);
|
||||
timeline
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ pub(super) async fn get_hierarchy() -> wellen::Hierarchy {
|
|||
|
||||
pub(super) async fn load_signal_and_get_timeline(
|
||||
signal_ref: wellen::SignalRef,
|
||||
screen_width: u32,
|
||||
timeline_width: u32,
|
||||
timeline_viewport_width: u32,
|
||||
timeline_viewport_x: u32,
|
||||
block_height: u32,
|
||||
var_format: shared::VarFormat,
|
||||
) -> shared::Timeline {
|
||||
|
@ -27,7 +29,9 @@ pub(super) async fn load_signal_and_get_timeline(
|
|||
serde_wasm_bindgen::from_value(
|
||||
tauri_glue::load_signal_and_get_timeline(
|
||||
signal_ref.index(),
|
||||
screen_width,
|
||||
timeline_width,
|
||||
timeline_viewport_width,
|
||||
timeline_viewport_x,
|
||||
block_height,
|
||||
var_format,
|
||||
)
|
||||
|
@ -61,7 +65,9 @@ mod tauri_glue {
|
|||
#[wasm_bindgen(catch)]
|
||||
pub async fn load_signal_and_get_timeline(
|
||||
signal_ref_index: usize,
|
||||
screen_width: u32,
|
||||
timeline_width: u32,
|
||||
timeline_viewport_width: u32,
|
||||
timeline_viewport_x: u32,
|
||||
block_height: u32,
|
||||
var_format: JsValue,
|
||||
) -> Result<JsValue, JsValue>;
|
||||
|
|
|
@ -122,7 +122,9 @@ impl WaveformPanel {
|
|||
let signal_ref = var.signal_ref();
|
||||
let timeline = platform::load_signal_and_get_timeline(
|
||||
signal_ref,
|
||||
controller.screen_width(),
|
||||
controller.get_timeline_width(),
|
||||
controller.get_timeline_viewport_width(),
|
||||
controller.get_timeline_viewport_x(),
|
||||
ROW_HEIGHT,
|
||||
var_format,
|
||||
)
|
||||
|
|
|
@ -52,12 +52,14 @@ impl PixiCanvas {
|
|||
let task_with_controller = Mutable::new(None);
|
||||
// -- FastWave-specific --
|
||||
let timeline_getter = Rc::new(Closure::new(
|
||||
|signal_ref_index, screen_width, row_height, var_format| {
|
||||
|signal_ref_index, timeline_width, timeline_viewport_width, timeline_viewport_x, row_height, var_format| {
|
||||
future_to_promise(async move {
|
||||
let signal_ref = wellen::SignalRef::from_index(signal_ref_index).unwrap_throw();
|
||||
let timeline = platform::load_signal_and_get_timeline(
|
||||
signal_ref,
|
||||
screen_width,
|
||||
timeline_width,
|
||||
timeline_viewport_width,
|
||||
timeline_viewport_x,
|
||||
row_height,
|
||||
serde_wasm_bindgen::from_value(var_format).unwrap_throw(),
|
||||
)
|
||||
|
@ -81,7 +83,14 @@ impl PixiCanvas {
|
|||
}))
|
||||
.after_insert(clone!((controller, timeline_getter) move |element| {
|
||||
Task::start(async move {
|
||||
let pixi_controller = js_bridge::PixiController::new(row_height, row_gap, &timeline_getter);
|
||||
let pixi_controller = js_bridge::PixiController::new(
|
||||
width.get(),
|
||||
width.get(),
|
||||
0,
|
||||
row_height,
|
||||
row_gap,
|
||||
&timeline_getter
|
||||
);
|
||||
pixi_controller.init(&element).await;
|
||||
controller.set(Some(pixi_controller));
|
||||
});
|
||||
|
@ -113,11 +122,13 @@ mod js_bridge {
|
|||
|
||||
type TimelinePromise = js_sys::Promise;
|
||||
type SignalRefIndex = usize;
|
||||
type ScreenWidth = u32;
|
||||
type TimelineWidth = u32;
|
||||
type TimelineViewportWidth = u32;
|
||||
type TimelineViewportX = u32;
|
||||
type RowHeight = u32;
|
||||
type VarFormatJs = JsValue;
|
||||
type TimelineGetter =
|
||||
Closure<dyn FnMut(SignalRefIndex, ScreenWidth, RowHeight, VarFormatJs) -> TimelinePromise>;
|
||||
Closure<dyn FnMut(SignalRefIndex, TimelineWidth, TimelineViewportWidth, TimelineViewportX, RowHeight, VarFormatJs) -> TimelinePromise>;
|
||||
|
||||
// Note: Add all corresponding methods to `frontend/typescript/pixi_canvas/pixi_canvas.ts`
|
||||
#[wasm_bindgen(module = "/typescript/bundles/pixi_canvas.js")]
|
||||
|
@ -128,6 +139,9 @@ mod js_bridge {
|
|||
// @TODO `row_height` and `row_gap` is FastWave-specific
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(
|
||||
timeline_width: u32,
|
||||
timeline_viewport_width: u32,
|
||||
timeline_viewport_x: u32,
|
||||
row_height: u32,
|
||||
row_gap: u32,
|
||||
timeline_getter: &TimelineGetter,
|
||||
|
@ -143,7 +157,13 @@ mod js_bridge {
|
|||
pub fn destroy(this: &PixiController);
|
||||
|
||||
#[wasm_bindgen(method)]
|
||||
pub fn screen_width(this: &PixiController) -> u32;
|
||||
pub fn get_timeline_width(this: &PixiController) -> u32;
|
||||
|
||||
#[wasm_bindgen(method)]
|
||||
pub fn get_timeline_viewport_width(this: &PixiController) -> u32;
|
||||
|
||||
#[wasm_bindgen(method)]
|
||||
pub fn get_timeline_viewport_x(this: &PixiController) -> u32;
|
||||
|
||||
// -- FastWave-specific --
|
||||
|
||||
|
|
Reference in a new issue