1
0
Fork 0

Update Spectral Compressor for upstream changes

This commit is contained in:
Robbert van der Helm 2023-12-30 14:50:31 +01:00
parent 0dd58cd4bb
commit b07220abe8
3 changed files with 41 additions and 56 deletions

View file

@ -139,11 +139,13 @@ fn main_column(cx: &mut Context) {
.top(Stretch(1.0)) .top(Stretch(1.0))
.bottom(Pixels(4.0)) .bottom(Pixels(4.0))
.left(Pixels(2.0)); .left(Pixels(2.0));
}); })
.size(Auto);
}) })
.height(Pixels(30.0)) .height(Pixels(30.0))
.right(Pixels(17.0)) .right(Pixels(17.0))
.bottom(Pixels(-5.0)) // Somehow this overrides the 'row-between' value now
.bottom(Pixels(8.0))
.left(Pixels(10.0)) .left(Pixels(10.0))
.top(Pixels(10.0)) .top(Pixels(10.0))
// This contains the editor mode buttom all the way on the left, and the plugin's name all the way on the right // This contains the editor mode buttom all the way on the left, and the plugin's name all the way on the right
@ -163,72 +165,59 @@ fn main_column(cx: &mut Context) {
use this in a project, make sure to bounce things to audio just in case \ use this in a project, make sure to bounce things to audio just in case \
they'll sound different later.", they'll sound different later.",
) )
.text_wrap(true)
.font_size(11.0) .font_size(11.0)
.left(Pixels(15.0)) .left(Pixels(15.0))
.right(Pixels(8.0)) .right(Pixels(8.0))
// The column isn't tall enough without this, for some reason
.bottom(Pixels(20.0))
.width(Stretch(1.0)); .width(Stretch(1.0));
}); });
}) })
.height(Auto) .size(Auto);
.width(Stretch(1.0));
HStack::new(cx, |cx| { HStack::new(cx, |cx| {
make_column(cx, "Upwards", |cx| { make_column(cx, "Upwards", |cx| {
// We don't want to show the 'Upwards' prefix here, but it should still be in // We don't want to show the 'Upwards' prefix here, but it should still be in
// the parameter name so the parameter list makes sense // the parameter name so the parameter list makes sense
let upwards_compressor_params = Data::params.map(|p| p.compressors.upwards.clone()); let upwards_compressor_params = Data::params.map(|p| p.compressors.upwards.clone());
GenericUi::new_custom( GenericUi::new_custom(cx, upwards_compressor_params, |cx, param_ptr| {
cx, HStack::new(cx, |cx| {
upwards_compressor_params.clone(), Label::new(
move |cx, param_ptr| { cx,
let upwards_compressor_params = upwards_compressor_params.clone(); unsafe { param_ptr.name() }
HStack::new(cx, move |cx| { .strip_prefix("Upwards ")
Label::new( .expect("Expected parameter name prefix, this is a bug"),
cx, )
unsafe { param_ptr.name() } .class("label");
.strip_prefix("Upwards ")
.expect("Expected parameter name prefix, this is a bug"),
)
.class("label");
GenericUi::draw_widget(cx, upwards_compressor_params, param_ptr); GenericUi::draw_widget(cx, upwards_compressor_params, param_ptr);
}) })
.class("row"); .class("row");
}, });
);
}); });
make_column(cx, "Downwards", |cx| { make_column(cx, "Downwards", |cx| {
let downwards_compressor_params = let downwards_compressor_params =
Data::params.map(|p| p.compressors.downwards.clone()); Data::params.map(|p| p.compressors.downwards.clone());
GenericUi::new_custom( GenericUi::new_custom(cx, downwards_compressor_params, |cx, param_ptr| {
cx, HStack::new(cx, |cx| {
downwards_compressor_params.clone(), Label::new(
move |cx, param_ptr| { cx,
let downwards_compressor_params = downwards_compressor_params.clone(); unsafe { param_ptr.name() }
HStack::new(cx, move |cx| { .strip_prefix("Downwards ")
Label::new( .expect("Expected parameter name prefix, this is a bug"),
cx, )
unsafe { param_ptr.name() } .class("label");
.strip_prefix("Downwards ")
.expect("Expected parameter name prefix, this is a bug"),
)
.class("label");
GenericUi::draw_widget(cx, downwards_compressor_params, param_ptr); GenericUi::draw_widget(cx, downwards_compressor_params, param_ptr);
}) })
.class("row"); .class("row");
}, });
);
}); });
}) })
.height(Auto) .size(Auto);
.width(Stretch(1.0));
}) })
.width(Pixels(COLLAPSED_GUI_WIDTH as f32)) .width(Pixels(COLLAPSED_GUI_WIDTH as f32))
.row_between(Pixels(15.0)) .row_between(Pixels(10.0))
.child_left(Stretch(1.0)) .child_left(Stretch(1.0))
.child_right(Stretch(1.0)); .child_right(Stretch(1.0));
} }

View file

@ -101,12 +101,8 @@ impl View for Analyzer {
// TODO: Display the frequency range below the graph // TODO: Display the frequency range below the graph
// Draw the border last // Draw the border last
let border_width = match cx.border_width() { let border_width = cx.border_width();
Units::Pixels(val) => val, let border_color: vg::Color = cx.border_color().into();
Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0),
_ => 0.0,
};
let border_color: vg::Color = cx.border_color().cloned().unwrap_or_default().into();
let mut path = vg::Path::new(); let mut path = vg::Path::new();
{ {
@ -206,7 +202,7 @@ fn draw_spectrum(
previous_physical_x_coord = physical_x_coord; previous_physical_x_coord = physical_x_coord;
} }
canvas.stroke_path(&mut bars_path, &bars_paint); canvas.stroke_path(&bars_path, &bars_paint);
// The mesh path starts at the bottom left, follows the top envelope of the spectrum analyzer, // The mesh path starts at the bottom left, follows the top envelope of the spectrum analyzer,
// and ends in the bottom right // and ends in the bottom right
@ -249,7 +245,7 @@ fn draw_spectrum(
0.0, 0.0,
previous_physical_x_coord, previous_physical_x_coord,
0.0, 0.0,
&[ [
(0.0, lighter_text_color), (0.0, lighter_text_color),
(0.707, text_color), (0.707, text_color),
(1.0, text_color), (1.0, text_color),
@ -257,7 +253,7 @@ fn draw_spectrum(
) )
// NOTE: This is very important, otherwise this looks all kinds of gnarly // NOTE: This is very important, otherwise this looks all kinds of gnarly
.with_anti_alias(false); .with_anti_alias(false);
canvas.fill_path(&mut mesh_path, &mesh_paint); canvas.fill_path(&mesh_path, &mesh_paint);
} }
/// Overlays the threshold curve over the spectrum analyzer. If either the upwards or downwards /// Overlays the threshold curve over the spectrum analyzer. If either the upwards or downwards

View file

@ -29,13 +29,13 @@ pub struct EditorModeButton {
impl EditorModeButton { impl EditorModeButton {
/// Creates a new button bound to the editor mode setting. /// Creates a new button bound to the editor mode setting.
pub fn new<L, T>(cx: &mut Context, lens: L, label: impl Res<T>) -> Handle<Self> pub fn new<L, T>(cx: &mut Context, lens: L, label: impl Res<T> + Clone) -> Handle<Self>
where where
L: Lens<Target = Arc<AtomicCell<EditorMode>>>, L: Lens<Target = Arc<AtomicCell<EditorMode>>>,
T: ToString, T: ToString,
{ {
Self { mode: lens.get(cx) } Self { mode: lens.get(cx) }
.build(cx, move |cx| { .build(cx, |cx| {
Label::new(cx, label).hoverable(false); Label::new(cx, label).hoverable(false);
}) })
.checked(lens.map(|v| v.load() == EditorMode::AnalyzerVisible)) .checked(lens.map(|v| v.load() == EditorMode::AnalyzerVisible))