From 33d956a96bd5644139ccc2bcaa8e7866957e1399 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 8 Oct 2022 15:21:01 +0200 Subject: [PATCH] Update Vizia --- nih_plug_vizia/assets/theme.css | 7 +++++++ nih_plug_vizia/src/lib.rs | 10 ---------- nih_plug_vizia/src/widgets/peak_meter.rs | 7 +++++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/nih_plug_vizia/assets/theme.css b/nih_plug_vizia/assets/theme.css index 5464f257..c0cb9336 100644 --- a/nih_plug_vizia/assets/theme.css +++ b/nih_plug_vizia/assets/theme.css @@ -1,5 +1,12 @@ /* Overrides for default VIZIA widgets */ +:root { + background-color: #fafafa; + color: #0a0a0a; + /* VIZIA uses points instead of pixels, this is 20px */ + font-size: 15; +} + scrollview > vstack { /* Normally the scroll bar overlaps with the content, so we'll add a little offset to prevent that */ child-right: 15px; diff --git a/nih_plug_vizia/src/lib.rs b/nih_plug_vizia/src/lib.rs index 6a92f535..e2e38f5c 100644 --- a/nih_plug_vizia/src/lib.rs +++ b/nih_plug_vizia/src/lib.rs @@ -190,16 +190,6 @@ impl Editor for ViziaEditor { // lower seems to compensate for this. assets::register_fonts(cx); cx.set_default_font(assets::NOTO_SANS_LIGHT); - - // TOOD: `:root { background-color: #fafafa; }` in a stylesheet doesn't work - cx.style - .background_color - .insert(Entity::root(), Color::rgb(250, 250, 250)); - cx.style - .font_color - .insert(Entity::root(), Color::rgb(10, 10, 10)); - // VIZIA uses points instead of pixels, this is 20px - cx.style.font_size.insert(Entity::root(), 15.0); cx.add_theme(include_str!("../assets/theme.css")); // There doesn't seem to be any way to bundle styles with a widget, so we'll always diff --git a/nih_plug_vizia/src/widgets/peak_meter.rs b/nih_plug_vizia/src/widgets/peak_meter.rs index 1b42d381..90c6f97a 100644 --- a/nih_plug_vizia/src/widgets/peak_meter.rs +++ b/nih_plug_vizia/src/widgets/peak_meter.rs @@ -96,8 +96,11 @@ impl PeakMeter { Element::new(cx).class("ticks__tick"); } - let font_size = cx.style.font_size.get(cx.current()).unwrap_or(&15.0) - * cx.style.dpi_factor as f32; + let font_size = { + let current = cx.current(); + let draw_cx = DrawContext::new(cx); + draw_cx.font_size(current) * draw_cx.style.dpi_factor as f32 + }; let label = if first_tick { Label::new(cx, "-inf") .class("ticks__label")