diff --git a/Cargo.lock b/Cargo.lock index e9d6fbb3..65474a4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,6 +47,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + [[package]] name = "aliasable" version = "0.1.3" @@ -709,16 +718,6 @@ dependencies = [ "syn", ] -[[package]] -name = "cstr_core" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644828c273c063ab0d39486ba42a5d1f3a499d35529c759e763a9c6cb8a0fb08" -dependencies = [ - "cty", - "memchr", -] - [[package]] name = "ctor" version = "0.1.22" @@ -1318,9 +1317,9 @@ dependencies = [ [[package]] name = "gloo-timers" -version = "0.2.4" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" +checksum = "4d12a7f4e95cfe710f1d624fb1210b7d961a5fb05c4fd942f4feab06e61f590e" dependencies = [ "futures-channel", "futures-core", @@ -1773,9 +1772,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.124" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" +checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259" [[package]] name = "libloading" @@ -1793,6 +1792,19 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +[[package]] +name = "locale_config" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934" +dependencies = [ + "lazy_static", + "objc", + "objc-foundation", + "regex", + "winapi", +] + [[package]] name = "lock_api" version = "0.4.7" @@ -2682,9 +2694,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.2" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg", "crossbeam-deque", @@ -2694,13 +2706,14 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", + "lazy_static", "num_cpus", ] @@ -2748,6 +2761,23 @@ dependencies = [ "winapi", ] +[[package]] +name = "regex" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + [[package]] name = "renderdoc-sys" version = "0.7.1" @@ -3180,19 +3210,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "sys-locale" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3913c5a3d30054d7f77cf07cdd800c8103ace15c6e44437c5db66a43dd3a92cf" -dependencies = [ - "cc", - "cstr_core", - "libc", - "web-sys", - "winapi", -] - [[package]] name = "termcolor" version = "1.1.3" @@ -3254,9 +3271,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.9" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] @@ -3445,7 +3462,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vizia" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219" dependencies = [ "vizia_baseview", "vizia_core", @@ -3454,7 +3471,7 @@ dependencies = [ [[package]] name = "vizia_baseview" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219" dependencies = [ "baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)", "femtovg", @@ -3466,7 +3483,7 @@ dependencies = [ [[package]] name = "vizia_core" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219" dependencies = [ "bitflags", "copypasta", @@ -3479,8 +3496,8 @@ dependencies = [ "image 0.24.1", "instant", "keyboard-types", + "locale_config", "morphorm", - "sys-locale", "unic-langid", "unicode-bidi", "unicode-segmentation", @@ -3491,7 +3508,7 @@ dependencies = [ [[package]] name = "vizia_derive" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219" dependencies = [ "proc-macro2", "quote", diff --git a/nih_plug_vizia/src/widgets/peak_meter.rs b/nih_plug_vizia/src/widgets/peak_meter.rs index 6a840c7e..ab146eec 100644 --- a/nih_plug_vizia/src/widgets/peak_meter.rs +++ b/nih_plug_vizia/src/widgets/peak_meter.rs @@ -143,28 +143,44 @@ where L: Lens, P: Lens, { - fn draw(&self, cx: &mut DrawContext, canvas: &mut Canvas) { + fn draw(&self, cx: &mut Context, canvas: &mut Canvas) { let level_dbfs = self.level_dbfs.get(cx); let peak_dbfs = self.peak_dbfs.get(cx); // These basics are taken directly from the default implementation of this function - let entity = cx.current(); - let bounds = cx.cache().get_bounds(entity); + let entity = cx.current; + let bounds = cx.cache.get_bounds(entity); if bounds.w == 0.0 || bounds.h == 0.0 { return; } // TODO: It would be cool to allow the text color property to control the gradient here. For // now we'll only support basic background colors and borders. - let background_color = cx.background_color(entity).cloned().unwrap_or_default(); - let border_color = cx.border_color(entity).cloned().unwrap_or_default(); - let opacity = cx.cache().get_opacity(entity); + let background_color = cx + .style + .background_color + .get(entity) + .cloned() + .unwrap_or_default(); + let border_color = cx + .style + .border_color + .get(entity) + .cloned() + .unwrap_or_default(); + let opacity = cx.cache.get_opacity(entity); let mut background_color: vg::Color = background_color.into(); background_color.set_alphaf(background_color.a * opacity); let mut border_color: vg::Color = border_color.into(); border_color.set_alphaf(border_color.a * opacity); - let border_width = match cx.border_width(entity).unwrap_or_default() { + let border_width = match cx + .style + .border_width + .get(entity) + .cloned() + .unwrap_or_default() + { Units::Pixels(val) => val, Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0), _ => 0.0, @@ -196,7 +212,7 @@ where // NOTE: We'll scale this with the nearest integer DPI ratio. That way it will still look // good at 2x scaling, and it won't look blurry at 1.x times scaling. - let dpi_scale = cx.logical_to_physical(1.0).floor().max(1.0) as f32; + let dpi_scale = cx.style.dpi_factor.floor().max(1.0) as f32; let bar_tick_coordinates = (bar_ticks_start_x..bar_ticks_end_x) .step_by(((TICK_WIDTH + TICK_GAP) * dpi_scale).round() as usize); for tick_x in bar_tick_coordinates { diff --git a/nih_plug_vizia/src/widgets/resize_handle.rs b/nih_plug_vizia/src/widgets/resize_handle.rs index 5876ed23..8549e345 100644 --- a/nih_plug_vizia/src/widgets/resize_handle.rs +++ b/nih_plug_vizia/src/widgets/resize_handle.rs @@ -101,25 +101,41 @@ impl View for ResizeHandle { } } - fn draw(&self, cx: &mut DrawContext, canvas: &mut Canvas) { + fn draw(&self, cx: &mut Context, canvas: &mut Canvas) { // We'll draw the handle directly as styling elements for this is going to be a bit tricky // These basics are taken directly from the default implementation of this function - let entity = cx.current(); - let bounds = cx.cache().get_bounds(entity); + let entity = cx.current; + let bounds = cx.cache.get_bounds(entity); if bounds.w == 0.0 || bounds.h == 0.0 { return; } - let background_color = cx.background_color(entity).copied().unwrap_or_default(); - let border_color = cx.border_color(entity).copied().unwrap_or_default(); - let opacity = cx.cache().get_opacity(entity); + let background_color = cx + .style + .background_color + .get(entity) + .cloned() + .unwrap_or_default(); + let border_color = cx + .style + .border_color + .get(entity) + .cloned() + .unwrap_or_default(); + let opacity = cx.cache.get_opacity(entity); let mut background_color: vg::Color = background_color.into(); background_color.set_alphaf(background_color.a * opacity); let mut border_color: vg::Color = border_color.into(); border_color.set_alphaf(border_color.a * opacity); - let border_width = match cx.border_width(entity).unwrap_or_default() { + let border_width = match cx + .style + .border_width + .get(entity) + .cloned() + .unwrap_or_default() + { Units::Pixels(val) => val, Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0), _ => 0.0, @@ -175,8 +191,10 @@ impl View for ResizeHandle { // path.close(); let mut color: vg::Color = cx - .font_color(entity) - .copied() + .style + .font_color + .get(entity) + .cloned() .unwrap_or(Color::white()) .into(); color.set_alphaf(color.a * opacity);