await redraw, u128 for bitstring parsing

This commit is contained in:
Martin Kavík 2024-06-07 23:06:14 +02:00
parent 8e285c7b5e
commit 869a31ca5f
4 changed files with 16 additions and 15 deletions

View file

@ -40,11 +40,12 @@ impl PixiCanvas {
let width = width.signal(), let width = width.signal(),
let height = height.signal() => (*width, *height) let height = height.signal() => (*width, *height)
} }
.for_each_sync(clone!((controller) move |(width, height)| { .throttle(|| Timer::sleep(50))
.for_each(clone!((controller) move |(width, height)| clone!((controller) async move {
if let Some(controller) = controller.lock_ref().as_ref() { if let Some(controller) = controller.lock_ref().as_ref() {
controller.resize(width, height); controller.resize(width, height).await
} }
})), }))),
); );
let task_with_controller = Mutable::new(None); let task_with_controller = Mutable::new(None);
// -- FastWave-specific -- // -- FastWave-specific --
@ -120,7 +121,7 @@ mod js_bridge {
pub async fn init(this: &PixiController, parent_element: &JsValue); pub async fn init(this: &PixiController, parent_element: &JsValue);
#[wasm_bindgen(method)] #[wasm_bindgen(method)]
pub fn resize(this: &PixiController, width: u32, height: u32); pub async fn resize(this: &PixiController, width: u32, height: u32);
#[wasm_bindgen(method)] #[wasm_bindgen(method)]
pub fn destroy(this: &PixiController); pub fn destroy(this: &PixiController);

View file

@ -35151,12 +35151,12 @@ var PixiController = class {
} }
// Default automatic Pixi resizing according to the parent is not reliable // Default automatic Pixi resizing according to the parent is not reliable
// and the `app.renderer`'s `resize` event is fired on every browser window size change // and the `app.renderer`'s `resize` event is fired on every browser window size change
resize(width, height) { async resize(width, height) {
this.app.resize(); this.app.resize();
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) {
this.redraw_rows(); await this.redraw_rows();
} }
} }
destroy() { destroy() {
@ -35175,11 +35175,11 @@ var PixiController = class {
return this.app.screen.width; return this.app.screen.width;
} }
// -- FastWave-specific -- // -- FastWave-specific --
redraw_rows() { async redraw_rows() {
this.var_signal_rows.forEach(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.redraw(timeline); row.redraw(timeline);
}); }));
} }
remove_var(index) { remove_var(index) {
if (typeof this.var_signal_rows[index] !== "undefined") { if (typeof this.var_signal_rows[index] !== "undefined") {

View file

@ -45,13 +45,13 @@ export class PixiController {
// Default automatic Pixi resizing according to the parent is not reliable // Default automatic Pixi resizing according to the parent is not reliable
// and the `app.renderer`'s `resize` event is fired on every browser window size change // and the `app.renderer`'s `resize` event is fired on every browser window size change
resize(width: number, height: number) { async resize(width: number, height: number) {
this.app.resize(); this.app.resize();
// -- FastWave-specific -- // -- FastWave-specific --
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) {
this.redraw_rows(); await this.redraw_rows();
} }
} }
@ -74,11 +74,11 @@ export class PixiController {
// -- FastWave-specific -- // -- FastWave-specific --
redraw_rows() { async redraw_rows() {
this.var_signal_rows.forEach(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.redraw(timeline); row.redraw(timeline);
}); }))
} }
remove_var(index: number) { remove_var(index: number) {

View file

@ -140,7 +140,7 @@ fn signal_to_timeline(
let value = value.to_string(); let value = value.to_string();
// @TODO dynamic formatter // @TODO dynamic formatter
let value = u32::from_str_radix(&value, 2).unwrap(); let value = u128::from_str_radix(&value, 2).unwrap();
let value = format!("{value:x}"); let value = format!("{value:x}");
let value_width = value.chars().count() as u32 * LETTER_WIDTH; let value_width = value.chars().count() as u32 * LETTER_WIDTH;