Zoom, pan, value formatting #2

Merged
MartinKavik merged 23 commits from zoom_pan into main 2024-06-14 20:39:30 +00:00
7 changed files with 20 additions and 7 deletions
Showing only changes of commit b308fa85fb - Show all commits

8
Cargo.lock generated
View file

@ -859,6 +859,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "convert-base"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e56a404f2112d00ba80a516b60ca3744ef6bd776baa14126eb7d7c11b42cac8a"
[[package]]
name = "convert_case"
version = "0.4.0"
@ -1414,6 +1420,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
name = "fastwave"
version = "0.1.0"
dependencies = [
"convert-base",
"serde",
"serde_json",
"shared",
@ -1499,6 +1506,7 @@ dependencies = [
name = "frontend"
version = "0.1.0"
dependencies = [
"convert-base",
"gloo-file",
"shared",
"wasm-bindgen-test",

View file

@ -16,6 +16,7 @@ readme = "../README.md"
publish = false
[workspace.dependencies]
convert-base = "1.1.2"
# wellen = { version = "0.9.9", features = ["serde1"] }
# wellen = { path = "../wellen/wellen", features = ["serde1"] }
wellen = { git = "https://github.com/MartinKavik/wellen", features = ["serde1"], branch = "new_pub_types" }

View file

@ -13,6 +13,7 @@ wasm-bindgen-test = "0.3.19"
[dependencies]
zoon.workspace = true
wellen.workspace = true
convert-base.workspace = true
shared = { path = "../shared", features = ["frontend"] }
web-sys = { version = "*", features = ["FileSystemFileHandle"] }
gloo-file = { version = "0.3.0", features = ["futures"] }

View file

@ -35152,12 +35152,12 @@ var PixiController = class {
// 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
async resize(width, height) {
this.app.resize();
const width_changed = width !== this.previous_parent_width;
this.previous_parent_width = width;
if (width_changed) {
await this.redraw_rows();
}
this.app.resize();
}
destroy() {
const rendererDestroyOptions = {

View file

@ -46,14 +46,13 @@ export class PixiController {
// 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
async resize(width: number, height: number) {
this.app.resize();
// -- FastWave-specific --
const width_changed = width !== this.previous_parent_width;
this.previous_parent_width = width;
if (width_changed) {
await this.redraw_rows();
}
// -- // --
this.app.resize();
}
destroy() {

View file

@ -17,6 +17,7 @@ tauri-build = { version = "=2.0.0-beta.17", features = [] }
[dependencies]
wellen.workspace = true
convert-base.workspace = true
shared = { path = "../shared", features = ["backend"] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

View file

@ -116,8 +116,8 @@ fn signal_to_timeline(
})
.peekable();
// @TODO parallelize?
let mut blocks = Vec::new();
while let Some((block_x, value)) = x_value_pairs.next() {
let next_block_x = if let Some((next_block_x, _)) = x_value_pairs.peek() {
*next_block_x
@ -130,10 +130,13 @@ fn signal_to_timeline(
continue;
}
let value = value.to_string();
// @TODO dynamic formatter
let value = u128::from_str_radix(&value, 2).unwrap();
let value = format!("{value:x}");
// @TODO optimize it by not using `.to_string` if possible
let value = value.to_string();
let ones_and_zeros = value.chars().rev().map(|char| char.to_digit(2).unwrap()).collect::<Vec<_>>();
let mut base = convert_base::Convert::new(2, 16);
let output = base.convert::<u32, u32>(&ones_and_zeros);
let value: String = output.into_iter().map(|number| char::from_digit(number, 16).unwrap()).collect();
let value_width = value.chars().count() as u32 * LETTER_WIDTH;
let label = if (value_width + (2 * LABEL_X_PADDING)) <= block_width {