diff --git a/Cargo.lock b/Cargo.lock index d14173e2..17cc12d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,7 @@ checksum = "17cc5e6b5ab06331c33589842070416baa137e8b0eb912b008cfd4a78ada7919" [[package]] name = "clap-sys" version = "0.24.0" -source = "git+https://github.com/robbert-vdh/clap-sys?branch=update/clap-0.24#a703ec943df1f34c0c664c91071cef4fb0daaeda" +source = "git+https://github.com/robbert-vdh/clap-sys?branch=update/clap-0.24#695556c4ebc839952e690577f3a825eb3054d2bb" [[package]] name = "clipboard-win" @@ -932,8 +932,7 @@ dependencies = [ [[package]] name = "femtovg" version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f95b1b0a3a4dc9bb7f866b2d6efc9c5c5f5bccefc21e40be75dfc2c12cb6ef8" +source = "git+https://github.com/femtovg/femtovg?rev=87fe627794f3f793d8e3a338c838a2f8e8a8aa9d#87fe627794f3f793d8e3a338c838a2f8e8a8aa9d" dependencies = [ "bitflags", "fnv", @@ -1773,9 +1772,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.121" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" +checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259" [[package]] name = "libloading" @@ -1972,7 +1971,7 @@ dependencies = [ [[package]] name = "morphorm" version = "0.3.0" -source = "git+https://github.com/vizia/morphorm?rev=07a8ba20b16660f93b551ad89873d4b382536b54#07a8ba20b16660f93b551ad89873d4b382536b54" +source = "git+https://github.com/vizia/morphorm?rev=c14e888b1d66719fc3f13ccdb1ea01a10368ef9e#c14e888b1d66719fc3f13ccdb1ea01a10368ef9e" dependencies = [ "bitflags", "smallvec", @@ -2068,7 +2067,6 @@ version = "0.0.0" dependencies = [ "baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)", "crossbeam", - "femtovg", "nih_plug", "nih_plug_assets", "vizia", @@ -2241,9 +2239,9 @@ dependencies = [ [[package]] name = "ouroboros" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71643f290d126e18ac2598876d01e1d57aed164afc78fdb6e2a0c6589a1f6662" +checksum = "9f31a3b678685b150cba82b702dcdc5e155893f63610cf388d30cd988d4ca2bf" dependencies = [ "aliasable", "ouroboros_macro", @@ -2252,9 +2250,9 @@ dependencies = [ [[package]] name = "ouroboros_macro" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9a247206016d424fe8497bc611e510887af5c261fbbf977877c4bb55ca4d82" +checksum = "084fd65d5dd8b3772edccb5ffd1e4b7eba43897ecd0f9401e330e8c542959408" dependencies = [ "Inflector", "proc-macro-error", @@ -2546,9 +2544,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" dependencies = [ "unicode-xid", ] @@ -3199,9 +3197,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f" +checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" dependencies = [ "proc-macro2", "quote", @@ -3460,7 +3458,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vizia" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#9a2cd59c66c60020ca8c2c2a596e8a6fadb9530e" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219" dependencies = [ "vizia_baseview", "vizia_core", @@ -3469,7 +3467,7 @@ dependencies = [ [[package]] name = "vizia_baseview" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#9a2cd59c66c60020ca8c2c2a596e8a6fadb9530e" +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", @@ -3481,7 +3479,7 @@ dependencies = [ [[package]] name = "vizia_core" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#9a2cd59c66c60020ca8c2c2a596e8a6fadb9530e" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219" dependencies = [ "bitflags", "copypasta", @@ -3497,14 +3495,16 @@ dependencies = [ "locale_config", "morphorm", "unic-langid", + "unicode-bidi", "unicode-segmentation", "vizia_derive", + "web-sys", ] [[package]] name = "vizia_derive" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#9a2cd59c66c60020ca8c2c2a596e8a6fadb9530e" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219" dependencies = [ "proc-macro2", "quote", diff --git a/nih_plug_vizia/Cargo.toml b/nih_plug_vizia/Cargo.toml index 53d4672a..5c198e83 100644 --- a/nih_plug_vizia/Cargo.toml +++ b/nih_plug_vizia/Cargo.toml @@ -13,8 +13,6 @@ nih_plug_assets = { git = "https://github.com/robbert-vdh/nih_plug_assets.git" } baseview = { git = "https://github.com/robbert-vdh/baseview.git", branch = "feature/resize" } crossbeam = "0.8" -# Vizia doesn't re-export this, we will -femtovg = { version = "0.3.0", default-features = false, features = ["image-loading"] } # This fork contains changed for better keyboard modifier handling and DPI # scaling, window scaling, and a lot more fixes and improvements vizia = { git = "https://github.com/robbert-vdh/vizia.git", branch = "patched", default_features = false, features = ["baseview", "clipboard"] } diff --git a/nih_plug_vizia/src/lib.rs b/nih_plug_vizia/src/lib.rs index af4afd23..0d40c33a 100644 --- a/nih_plug_vizia/src/lib.rs +++ b/nih_plug_vizia/src/lib.rs @@ -8,7 +8,6 @@ use std::sync::Arc; use vizia::{Application, Color, Context, Entity, Model, PropSet, WindowDescription}; // Re-export for convenience -pub use femtovg; pub use vizia; pub mod assets; diff --git a/nih_plug_vizia/src/widgets/generic_ui.rs b/nih_plug_vizia/src/widgets/generic_ui.rs index 21167acc..f2eab9d4 100644 --- a/nih_plug_vizia/src/widgets/generic_ui.rs +++ b/nih_plug_vizia/src/widgets/generic_ui.rs @@ -78,17 +78,17 @@ impl GenericUi { Ps: Params + 'static, { // Basic styling is done in the `theme.css` style sheet - Self.build2(cx, |cx| { + Self.build(cx, |cx| { // Rust does not have existential types, otherwise we could have passed functions that // map `params` to some `impl Param` and everything would have been a lot neater - let param_map = &*params.map(|params| params.as_ref().param_map()).get(cx); + let param_map = params.map(|params| params.as_ref().param_map()).get(cx); for (_, param_ptr, _) in param_map { let flags = unsafe { param_ptr.flags() }; if flags.contains(ParamFlags::HIDE_IN_GENERIC_UI) { continue; } - make_widget(cx, *param_ptr); + make_widget(cx, param_ptr); } }) } diff --git a/nih_plug_vizia/src/widgets/param_slider.rs b/nih_plug_vizia/src/widgets/param_slider.rs index 4051f605..17cfd131 100644 --- a/nih_plug_vizia/src/widgets/param_slider.rs +++ b/nih_plug_vizia/src/widgets/param_slider.rs @@ -112,13 +112,13 @@ impl ParamSlider { // this appraoch looks a bit jarring. // We need to do a bit of a nasty and erase the lifetime bound by going through the raw // GuiContext and a ParamPtr. - let param_ptr = *params + let param_ptr = params .map(move |params| params_to_param(params).as_ptr()) .get(cx); - let default_value = *params + let default_value = params .map(move |params| params_to_param(params).default_normalized_value()) .get(cx); - let step_count = *params + let step_count = params .map(move |params| params_to_param(params).step_count()) .get(cx); @@ -129,7 +129,7 @@ impl ParamSlider { is_double_click: false, granular_drag_start_x_value: None, } - .build2(cx, move |cx| { + .build(cx, move |cx| { ParamSliderInternal { style: ParamSliderStyle::Centered, text_input_active: false, @@ -137,7 +137,7 @@ impl ParamSlider { .build(cx); Binding::new(cx, ParamSliderInternal::style, move |cx, style| { - let style = *style.get(cx); + let style = style.get(cx); let draw_fill_from_default = matches!(style, ParamSliderStyle::Centered) && step_count.is_none() && (0.45..=0.55).contains(&default_value); @@ -161,7 +161,7 @@ impl ParamSlider { let normalized_param_value_lens = params.map(move |params| params_to_param(params).normalized_value()); - if *text_input_active.get(cx) { + if text_input_active.get(cx) { Textbox::new(cx, param_display_value_lens) .class("value-entry") .on_submit(|cx, string| { @@ -174,7 +174,10 @@ impl ParamSlider { cx.emit(TextEvent::StartEdit); cx.emit(TextEvent::SelectAll); }) - .child_space(Stretch(1.0)) + // `.child_space(Stretch(1.0))` no longer works + .class("align_center") + .child_top(Stretch(1.0)) + .child_bottom(Stretch(1.0)) .height(Stretch(1.0)) .width(Stretch(1.0)); } else { @@ -186,7 +189,7 @@ impl ParamSlider { .class("fill") .height(Stretch(1.0)) .bind(normalized_param_value_lens, move |handle, value| { - let current_value = *value.get(handle.cx); + let current_value = value.get(handle.cx); let (start_t, delta) = match style { ParamSliderStyle::Centered if draw_fill_from_default => @@ -264,6 +267,7 @@ impl ParamSlider { ) .class("value") .class("value--multiple") + .child_space(Stretch(1.0)) .height(Stretch(1.0)) .width(Stretch(1.0)) .hoverable(false); @@ -277,6 +281,7 @@ impl ParamSlider { Label::new(cx, param_display_value_lens) .class("value") .class("value--single") + .child_space(Stretch(1.0)) .height(Stretch(1.0)) .width(Stretch(1.0)) .hoverable(false); diff --git a/nih_plug_vizia/src/widgets/peak_meter.rs b/nih_plug_vizia/src/widgets/peak_meter.rs index db8b2059..ab146eec 100644 --- a/nih_plug_vizia/src/widgets/peak_meter.rs +++ b/nih_plug_vizia/src/widgets/peak_meter.rs @@ -1,6 +1,5 @@ //! A super simple peak meter widget. -use femtovg::{Paint, Path}; use nih_plug::prelude::util; use std::cell::Cell; use std::time::Duration; @@ -43,7 +42,7 @@ impl PeakMeter { where L: Lens, { - Self.build2(cx, |cx| { + Self.build(cx, |cx| { // Now for something that may be illegal under some jurisdictions. If a hold time is // given, then we'll build a new lens that always gives the held peak level for the // current moment in time by mutating some values captured into the mapping closure. @@ -77,7 +76,7 @@ impl PeakMeter { level_dbfs, peak_dbfs, } - .build(cx) + .build(cx, |_| {}) .class("bar"); ZStack::new(cx, |cx| { @@ -98,7 +97,7 @@ impl PeakMeter { Element::new(cx).class("ticks__tick"); } - let font_size = *cx.style.font_size.get(cx.current).unwrap_or(&15.0) + let font_size = cx.style.font_size.get(cx.current).unwrap_or(&15.0) * cx.style.dpi_factor as f32; let label = if first_tick { Label::new(cx, "-inf") @@ -145,8 +144,8 @@ where P: Lens, { 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); + 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; @@ -170,9 +169,9 @@ where .cloned() .unwrap_or_default(); let opacity = cx.cache.get_opacity(entity); - let mut background_color: femtovg::Color = background_color.into(); + let mut background_color: vg::Color = background_color.into(); background_color.set_alphaf(background_color.a * opacity); - let mut border_color: femtovg::Color = border_color.into(); + let mut border_color: vg::Color = border_color.into(); border_color.set_alphaf(border_color.a * opacity); let border_width = match cx @@ -187,7 +186,7 @@ where _ => 0.0, }; - let mut path = Path::new(); + let mut path = vg::Path::new(); { let x = bounds.x + border_width / 2.0; let y = bounds.y + border_width / 2.0; @@ -202,7 +201,7 @@ where } // Fill with background color - let paint = Paint::color(background_color); + let paint = vg::Paint::color(background_color); canvas.fill_path(&mut path, paint); // And now for the fun stuff. We'll try to not overlap the border, but we'll draw that last @@ -226,12 +225,12 @@ where // femtovg draws paths centered on these coordinates, so in order to be pixel perfect we // need to account for that. Otherwise the ticks will be 2px wide instead of 1px. - let mut path = Path::new(); + let mut path = vg::Path::new(); path.move_to(tick_x as f32 + (dpi_scale / 2.0), bar_bounds.top()); path.line_to(tick_x as f32 + (dpi_scale / 2.0), bar_bounds.bottom()); let grayscale_color = 0.3 + ((1.0 - tick_fraction) * 0.5); - let mut paint = Paint::color(femtovg::Color::rgbaf( + let mut paint = vg::Paint::color(vg::Color::rgbaf( grayscale_color, grayscale_color, grayscale_color, @@ -251,17 +250,17 @@ where // femtovg draws paths centered on these coordinates, so in order to be pixel perfect we // need to account for that. Otherwise the ticks will be 2px wide instead of 1px. let peak_x = db_to_x_coord(peak_dbfs); - let mut path = Path::new(); + let mut path = vg::Path::new(); path.move_to(peak_x + (dpi_scale / 2.0), bar_bounds.top()); path.line_to(peak_x + (dpi_scale / 2.0), bar_bounds.bottom()); - let mut paint = Paint::color(femtovg::Color::rgbaf(0.3, 0.3, 0.3, opacity)); + let mut paint = vg::Paint::color(vg::Color::rgbaf(0.3, 0.3, 0.3, opacity)); paint.set_line_width(TICK_WIDTH * dpi_scale); canvas.stroke_path(&mut path, paint); } // Draw border last - let mut paint = Paint::color(border_color); + let mut paint = vg::Paint::color(border_color); paint.set_line_width(border_width); canvas.stroke_path(&mut path, paint); } diff --git a/nih_plug_vizia/src/widgets/resize_handle.rs b/nih_plug_vizia/src/widgets/resize_handle.rs index 61aa299f..8549e345 100644 --- a/nih_plug_vizia/src/widgets/resize_handle.rs +++ b/nih_plug_vizia/src/widgets/resize_handle.rs @@ -1,6 +1,5 @@ //! A resize handle for uniformly scaling a plugin GUI. -use femtovg::{Paint, Path}; use vizia::*; /// A resize handle placed at the bottom right of the window that lets you resize the window. @@ -26,7 +25,7 @@ impl ResizeHandle { start_scale_factor: 1.0, start_physical_coordinates: (0.0, 0.0), } - .build(cx) + .build(cx, |_| {}) } } @@ -125,9 +124,9 @@ impl View for ResizeHandle { .cloned() .unwrap_or_default(); let opacity = cx.cache.get_opacity(entity); - let mut background_color: femtovg::Color = background_color.into(); + let mut background_color: vg::Color = background_color.into(); background_color.set_alphaf(background_color.a * opacity); - let mut border_color: femtovg::Color = border_color.into(); + let mut border_color: vg::Color = border_color.into(); border_color.set_alphaf(border_color.a * opacity); let border_width = match cx @@ -142,7 +141,7 @@ impl View for ResizeHandle { _ => 0.0, }; - let mut path = Path::new(); + let mut path = vg::Path::new(); let x = bounds.x + border_width / 2.0; let y = bounds.y + border_width / 2.0; let w = bounds.w - border_width; @@ -155,17 +154,17 @@ impl View for ResizeHandle { path.close(); // Fill with background color - let paint = Paint::color(background_color); + let paint = vg::Paint::color(background_color); canvas.fill_path(&mut path, paint); // Borders are only supported to make debugging easier - let mut paint = Paint::color(border_color); + let mut paint = vg::Paint::color(border_color); paint.set_line_width(border_width); canvas.stroke_path(&mut path, paint); // We'll draw a simple triangle, since we're going flat everywhere anyways and that style // tends to not look too tacky - let mut path = Path::new(); + let mut path = vg::Path::new(); let x = bounds.x + border_width / 2.0; let y = bounds.y + border_width / 2.0; let w = bounds.w - border_width; @@ -191,15 +190,15 @@ impl View for ResizeHandle { // path.move_to(x + (w / 3.0 * 1.5), y + h); // path.close(); - let mut color: femtovg::Color = cx + let mut color: vg::Color = cx .style .font_color .get(entity) .cloned() - .unwrap_or(crate::Color::white()) + .unwrap_or(Color::white()) .into(); color.set_alphaf(color.a * opacity); - let paint = Paint::color(color); + let paint = vg::Paint::color(color); canvas.fill_path(&mut path, paint); } }