Update vizia fork
This commit is contained in:
parent
4d8a515e9a
commit
5b03ae8d0e
38
Cargo.lock
generated
38
Cargo.lock
generated
|
@ -455,7 +455,7 @@ checksum = "17cc5e6b5ab06331c33589842070416baa137e8b0eb912b008cfd4a78ada7919"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap-sys"
|
name = "clap-sys"
|
||||||
version = "0.24.0"
|
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]]
|
[[package]]
|
||||||
name = "clipboard-win"
|
name = "clipboard-win"
|
||||||
|
@ -932,8 +932,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "femtovg"
|
name = "femtovg"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/femtovg/femtovg?rev=87fe627794f3f793d8e3a338c838a2f8e8a8aa9d#87fe627794f3f793d8e3a338c838a2f8e8a8aa9d"
|
||||||
checksum = "8f95b1b0a3a4dc9bb7f866b2d6efc9c5c5f5bccefc21e40be75dfc2c12cb6ef8"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"fnv",
|
"fnv",
|
||||||
|
@ -1773,9 +1772,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.121"
|
version = "0.2.122"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
|
checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
|
@ -1972,7 +1971,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "morphorm"
|
name = "morphorm"
|
||||||
version = "0.3.0"
|
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 = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
@ -2068,7 +2067,6 @@ version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)",
|
"baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)",
|
||||||
"crossbeam",
|
"crossbeam",
|
||||||
"femtovg",
|
|
||||||
"nih_plug",
|
"nih_plug",
|
||||||
"nih_plug_assets",
|
"nih_plug_assets",
|
||||||
"vizia",
|
"vizia",
|
||||||
|
@ -2241,9 +2239,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ouroboros"
|
name = "ouroboros"
|
||||||
version = "0.14.2"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "71643f290d126e18ac2598876d01e1d57aed164afc78fdb6e2a0c6589a1f6662"
|
checksum = "9f31a3b678685b150cba82b702dcdc5e155893f63610cf388d30cd988d4ca2bf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aliasable",
|
"aliasable",
|
||||||
"ouroboros_macro",
|
"ouroboros_macro",
|
||||||
|
@ -2252,9 +2250,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ouroboros_macro"
|
name = "ouroboros_macro"
|
||||||
version = "0.14.2"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed9a247206016d424fe8497bc611e510887af5c261fbbf977877c4bb55ca4d82"
|
checksum = "084fd65d5dd8b3772edccb5ffd1e4b7eba43897ecd0f9401e330e8c542959408"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
|
@ -2546,9 +2544,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.36"
|
version = "1.0.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
|
checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
@ -3199,9 +3197,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.90"
|
version = "1.0.91"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f"
|
checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -3460,7 +3458,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia"
|
name = "vizia"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"vizia_baseview",
|
"vizia_baseview",
|
||||||
"vizia_core",
|
"vizia_core",
|
||||||
|
@ -3469,7 +3467,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia_baseview"
|
name = "vizia_baseview"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)",
|
"baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)",
|
||||||
"femtovg",
|
"femtovg",
|
||||||
|
@ -3481,7 +3479,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia_core"
|
name = "vizia_core"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"copypasta",
|
"copypasta",
|
||||||
|
@ -3497,14 +3495,16 @@ dependencies = [
|
||||||
"locale_config",
|
"locale_config",
|
||||||
"morphorm",
|
"morphorm",
|
||||||
"unic-langid",
|
"unic-langid",
|
||||||
|
"unicode-bidi",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"vizia_derive",
|
"vizia_derive",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia_derive"
|
name = "vizia_derive"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
@ -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" }
|
baseview = { git = "https://github.com/robbert-vdh/baseview.git", branch = "feature/resize" }
|
||||||
crossbeam = "0.8"
|
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
|
# This fork contains changed for better keyboard modifier handling and DPI
|
||||||
# scaling, window scaling, and a lot more fixes and improvements
|
# 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"] }
|
vizia = { git = "https://github.com/robbert-vdh/vizia.git", branch = "patched", default_features = false, features = ["baseview", "clipboard"] }
|
||||||
|
|
|
@ -8,7 +8,6 @@ use std::sync::Arc;
|
||||||
use vizia::{Application, Color, Context, Entity, Model, PropSet, WindowDescription};
|
use vizia::{Application, Color, Context, Entity, Model, PropSet, WindowDescription};
|
||||||
|
|
||||||
// Re-export for convenience
|
// Re-export for convenience
|
||||||
pub use femtovg;
|
|
||||||
pub use vizia;
|
pub use vizia;
|
||||||
|
|
||||||
pub mod assets;
|
pub mod assets;
|
||||||
|
|
|
@ -78,17 +78,17 @@ impl GenericUi {
|
||||||
Ps: Params + 'static,
|
Ps: Params + 'static,
|
||||||
{
|
{
|
||||||
// Basic styling is done in the `theme.css` style sheet
|
// 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
|
// 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
|
// 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 {
|
for (_, param_ptr, _) in param_map {
|
||||||
let flags = unsafe { param_ptr.flags() };
|
let flags = unsafe { param_ptr.flags() };
|
||||||
if flags.contains(ParamFlags::HIDE_IN_GENERIC_UI) {
|
if flags.contains(ParamFlags::HIDE_IN_GENERIC_UI) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
make_widget(cx, *param_ptr);
|
make_widget(cx, param_ptr);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,13 +112,13 @@ impl ParamSlider {
|
||||||
// this appraoch looks a bit jarring.
|
// 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
|
// We need to do a bit of a nasty and erase the lifetime bound by going through the raw
|
||||||
// GuiContext and a ParamPtr.
|
// GuiContext and a ParamPtr.
|
||||||
let param_ptr = *params
|
let param_ptr = params
|
||||||
.map(move |params| params_to_param(params).as_ptr())
|
.map(move |params| params_to_param(params).as_ptr())
|
||||||
.get(cx);
|
.get(cx);
|
||||||
let default_value = *params
|
let default_value = params
|
||||||
.map(move |params| params_to_param(params).default_normalized_value())
|
.map(move |params| params_to_param(params).default_normalized_value())
|
||||||
.get(cx);
|
.get(cx);
|
||||||
let step_count = *params
|
let step_count = params
|
||||||
.map(move |params| params_to_param(params).step_count())
|
.map(move |params| params_to_param(params).step_count())
|
||||||
.get(cx);
|
.get(cx);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ impl ParamSlider {
|
||||||
is_double_click: false,
|
is_double_click: false,
|
||||||
granular_drag_start_x_value: None,
|
granular_drag_start_x_value: None,
|
||||||
}
|
}
|
||||||
.build2(cx, move |cx| {
|
.build(cx, move |cx| {
|
||||||
ParamSliderInternal {
|
ParamSliderInternal {
|
||||||
style: ParamSliderStyle::Centered,
|
style: ParamSliderStyle::Centered,
|
||||||
text_input_active: false,
|
text_input_active: false,
|
||||||
|
@ -137,7 +137,7 @@ impl ParamSlider {
|
||||||
.build(cx);
|
.build(cx);
|
||||||
|
|
||||||
Binding::new(cx, ParamSliderInternal::style, move |cx, style| {
|
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)
|
let draw_fill_from_default = matches!(style, ParamSliderStyle::Centered)
|
||||||
&& step_count.is_none()
|
&& step_count.is_none()
|
||||||
&& (0.45..=0.55).contains(&default_value);
|
&& (0.45..=0.55).contains(&default_value);
|
||||||
|
@ -161,7 +161,7 @@ impl ParamSlider {
|
||||||
let normalized_param_value_lens =
|
let normalized_param_value_lens =
|
||||||
params.map(move |params| params_to_param(params).normalized_value());
|
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)
|
Textbox::new(cx, param_display_value_lens)
|
||||||
.class("value-entry")
|
.class("value-entry")
|
||||||
.on_submit(|cx, string| {
|
.on_submit(|cx, string| {
|
||||||
|
@ -174,7 +174,10 @@ impl ParamSlider {
|
||||||
cx.emit(TextEvent::StartEdit);
|
cx.emit(TextEvent::StartEdit);
|
||||||
cx.emit(TextEvent::SelectAll);
|
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))
|
.height(Stretch(1.0))
|
||||||
.width(Stretch(1.0));
|
.width(Stretch(1.0));
|
||||||
} else {
|
} else {
|
||||||
|
@ -186,7 +189,7 @@ impl ParamSlider {
|
||||||
.class("fill")
|
.class("fill")
|
||||||
.height(Stretch(1.0))
|
.height(Stretch(1.0))
|
||||||
.bind(normalized_param_value_lens, move |handle, value| {
|
.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 {
|
let (start_t, delta) = match style {
|
||||||
ParamSliderStyle::Centered
|
ParamSliderStyle::Centered
|
||||||
if draw_fill_from_default =>
|
if draw_fill_from_default =>
|
||||||
|
@ -264,6 +267,7 @@ impl ParamSlider {
|
||||||
)
|
)
|
||||||
.class("value")
|
.class("value")
|
||||||
.class("value--multiple")
|
.class("value--multiple")
|
||||||
|
.child_space(Stretch(1.0))
|
||||||
.height(Stretch(1.0))
|
.height(Stretch(1.0))
|
||||||
.width(Stretch(1.0))
|
.width(Stretch(1.0))
|
||||||
.hoverable(false);
|
.hoverable(false);
|
||||||
|
@ -277,6 +281,7 @@ impl ParamSlider {
|
||||||
Label::new(cx, param_display_value_lens)
|
Label::new(cx, param_display_value_lens)
|
||||||
.class("value")
|
.class("value")
|
||||||
.class("value--single")
|
.class("value--single")
|
||||||
|
.child_space(Stretch(1.0))
|
||||||
.height(Stretch(1.0))
|
.height(Stretch(1.0))
|
||||||
.width(Stretch(1.0))
|
.width(Stretch(1.0))
|
||||||
.hoverable(false);
|
.hoverable(false);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! A super simple peak meter widget.
|
//! A super simple peak meter widget.
|
||||||
|
|
||||||
use femtovg::{Paint, Path};
|
|
||||||
use nih_plug::prelude::util;
|
use nih_plug::prelude::util;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
@ -43,7 +42,7 @@ impl PeakMeter {
|
||||||
where
|
where
|
||||||
L: Lens<Target = f32>,
|
L: Lens<Target = f32>,
|
||||||
{
|
{
|
||||||
Self.build2(cx, |cx| {
|
Self.build(cx, |cx| {
|
||||||
// Now for something that may be illegal under some jurisdictions. If a hold time is
|
// 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
|
// 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.
|
// current moment in time by mutating some values captured into the mapping closure.
|
||||||
|
@ -77,7 +76,7 @@ impl PeakMeter {
|
||||||
level_dbfs,
|
level_dbfs,
|
||||||
peak_dbfs,
|
peak_dbfs,
|
||||||
}
|
}
|
||||||
.build(cx)
|
.build(cx, |_| {})
|
||||||
.class("bar");
|
.class("bar");
|
||||||
|
|
||||||
ZStack::new(cx, |cx| {
|
ZStack::new(cx, |cx| {
|
||||||
|
@ -98,7 +97,7 @@ impl PeakMeter {
|
||||||
Element::new(cx).class("ticks__tick");
|
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;
|
* cx.style.dpi_factor as f32;
|
||||||
let label = if first_tick {
|
let label = if first_tick {
|
||||||
Label::new(cx, "-inf")
|
Label::new(cx, "-inf")
|
||||||
|
@ -145,8 +144,8 @@ where
|
||||||
P: Lens<Target = f32>,
|
P: Lens<Target = f32>,
|
||||||
{
|
{
|
||||||
fn draw(&self, cx: &mut Context, canvas: &mut Canvas) {
|
fn draw(&self, cx: &mut Context, canvas: &mut Canvas) {
|
||||||
let level_dbfs = *self.level_dbfs.get(cx);
|
let level_dbfs = self.level_dbfs.get(cx);
|
||||||
let peak_dbfs = *self.peak_dbfs.get(cx);
|
let peak_dbfs = self.peak_dbfs.get(cx);
|
||||||
|
|
||||||
// These basics are taken directly from the default implementation of this function
|
// These basics are taken directly from the default implementation of this function
|
||||||
let entity = cx.current;
|
let entity = cx.current;
|
||||||
|
@ -170,9 +169,9 @@ where
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let opacity = cx.cache.get_opacity(entity);
|
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);
|
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);
|
border_color.set_alphaf(border_color.a * opacity);
|
||||||
|
|
||||||
let border_width = match cx
|
let border_width = match cx
|
||||||
|
@ -187,7 +186,7 @@ where
|
||||||
_ => 0.0,
|
_ => 0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut path = Path::new();
|
let mut path = vg::Path::new();
|
||||||
{
|
{
|
||||||
let x = bounds.x + border_width / 2.0;
|
let x = bounds.x + border_width / 2.0;
|
||||||
let y = bounds.y + border_width / 2.0;
|
let y = bounds.y + border_width / 2.0;
|
||||||
|
@ -202,7 +201,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill with background color
|
// Fill with background color
|
||||||
let paint = Paint::color(background_color);
|
let paint = vg::Paint::color(background_color);
|
||||||
canvas.fill_path(&mut path, paint);
|
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
|
// 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
|
// 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.
|
// 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.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());
|
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 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,
|
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
|
// 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.
|
// 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 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.move_to(peak_x + (dpi_scale / 2.0), bar_bounds.top());
|
||||||
path.line_to(peak_x + (dpi_scale / 2.0), bar_bounds.bottom());
|
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);
|
paint.set_line_width(TICK_WIDTH * dpi_scale);
|
||||||
canvas.stroke_path(&mut path, paint);
|
canvas.stroke_path(&mut path, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw border last
|
// Draw border last
|
||||||
let mut paint = Paint::color(border_color);
|
let mut paint = vg::Paint::color(border_color);
|
||||||
paint.set_line_width(border_width);
|
paint.set_line_width(border_width);
|
||||||
canvas.stroke_path(&mut path, paint);
|
canvas.stroke_path(&mut path, paint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! A resize handle for uniformly scaling a plugin GUI.
|
//! A resize handle for uniformly scaling a plugin GUI.
|
||||||
|
|
||||||
use femtovg::{Paint, Path};
|
|
||||||
use vizia::*;
|
use vizia::*;
|
||||||
|
|
||||||
/// A resize handle placed at the bottom right of the window that lets you resize the window.
|
/// 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_scale_factor: 1.0,
|
||||||
start_physical_coordinates: (0.0, 0.0),
|
start_physical_coordinates: (0.0, 0.0),
|
||||||
}
|
}
|
||||||
.build(cx)
|
.build(cx, |_| {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +124,9 @@ impl View for ResizeHandle {
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let opacity = cx.cache.get_opacity(entity);
|
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);
|
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);
|
border_color.set_alphaf(border_color.a * opacity);
|
||||||
|
|
||||||
let border_width = match cx
|
let border_width = match cx
|
||||||
|
@ -142,7 +141,7 @@ impl View for ResizeHandle {
|
||||||
_ => 0.0,
|
_ => 0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut path = Path::new();
|
let mut path = vg::Path::new();
|
||||||
let x = bounds.x + border_width / 2.0;
|
let x = bounds.x + border_width / 2.0;
|
||||||
let y = bounds.y + border_width / 2.0;
|
let y = bounds.y + border_width / 2.0;
|
||||||
let w = bounds.w - border_width;
|
let w = bounds.w - border_width;
|
||||||
|
@ -155,17 +154,17 @@ impl View for ResizeHandle {
|
||||||
path.close();
|
path.close();
|
||||||
|
|
||||||
// Fill with background color
|
// Fill with background color
|
||||||
let paint = Paint::color(background_color);
|
let paint = vg::Paint::color(background_color);
|
||||||
canvas.fill_path(&mut path, paint);
|
canvas.fill_path(&mut path, paint);
|
||||||
|
|
||||||
// Borders are only supported to make debugging easier
|
// 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);
|
paint.set_line_width(border_width);
|
||||||
canvas.stroke_path(&mut path, paint);
|
canvas.stroke_path(&mut path, paint);
|
||||||
|
|
||||||
// We'll draw a simple triangle, since we're going flat everywhere anyways and that style
|
// We'll draw a simple triangle, since we're going flat everywhere anyways and that style
|
||||||
// tends to not look too tacky
|
// 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 x = bounds.x + border_width / 2.0;
|
||||||
let y = bounds.y + border_width / 2.0;
|
let y = bounds.y + border_width / 2.0;
|
||||||
let w = bounds.w - border_width;
|
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.move_to(x + (w / 3.0 * 1.5), y + h);
|
||||||
// path.close();
|
// path.close();
|
||||||
|
|
||||||
let mut color: femtovg::Color = cx
|
let mut color: vg::Color = cx
|
||||||
.style
|
.style
|
||||||
.font_color
|
.font_color
|
||||||
.get(entity)
|
.get(entity)
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or(crate::Color::white())
|
.unwrap_or(Color::white())
|
||||||
.into();
|
.into();
|
||||||
color.set_alphaf(color.a * opacity);
|
color.set_alphaf(color.a * opacity);
|
||||||
let paint = Paint::color(color);
|
let paint = vg::Paint::color(color);
|
||||||
canvas.fill_path(&mut path, paint);
|
canvas.fill_path(&mut path, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue