Update Diopser for upstream vizia changes
This commit is contained in:
parent
455f651d39
commit
b702b9a55e
|
@ -123,6 +123,7 @@ fn top_bar(cx: &mut Context) {
|
||||||
.for_bypass()
|
.for_bypass()
|
||||||
.left(Pixels(10.0));
|
.left(Pixels(10.0));
|
||||||
})
|
})
|
||||||
|
.width(Auto)
|
||||||
.child_space(Pixels(10.0))
|
.child_space(Pixels(10.0))
|
||||||
.left(Stretch(1.0));
|
.left(Stretch(1.0));
|
||||||
})
|
})
|
||||||
|
@ -137,10 +138,7 @@ fn spectrum_analyzer(cx: &mut Context) {
|
||||||
HStack::new(cx, |cx| {
|
HStack::new(cx, |cx| {
|
||||||
Label::new(cx, "Resonance")
|
Label::new(cx, "Resonance")
|
||||||
.font_size(18.0)
|
.font_size(18.0)
|
||||||
// HACK: Rotating doesn't really work in vizia, but with text wrap disabled this at
|
.rotate(Angle::Deg(270.0f32))
|
||||||
// least visually does the right thing
|
|
||||||
.text_wrap(false)
|
|
||||||
.rotate(270.0f32)
|
|
||||||
.width(Pixels(LABEL_HEIGHT))
|
.width(Pixels(LABEL_HEIGHT))
|
||||||
.height(Pixels(SPECTRUM_ANALYZER_HEIGHT))
|
.height(Pixels(SPECTRUM_ANALYZER_HEIGHT))
|
||||||
// HACK: The `.space()` on the HStack doesn't seem to work correctly here
|
// HACK: The `.space()` on the HStack doesn't seem to work correctly here
|
||||||
|
@ -185,15 +183,19 @@ fn spectrum_analyzer(cx: &mut Context) {
|
||||||
.height(Pixels(20.0))
|
.height(Pixels(20.0))
|
||||||
.child_space(Stretch(1.0));
|
.child_space(Stretch(1.0));
|
||||||
})
|
})
|
||||||
.space(Pixels(10.0))
|
.left(Pixels(10.0))
|
||||||
|
.right(Pixels(10.0))
|
||||||
|
.top(Pixels(10.0))
|
||||||
|
.height(Auto)
|
||||||
.width(Stretch(1.0));
|
.width(Stretch(1.0));
|
||||||
});
|
})
|
||||||
|
.height(Auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The area below the spectrum analyzer that contains all of the other parameters.
|
/// The area below the spectrum analyzer that contains all of the other parameters.
|
||||||
fn other_params(cx: &mut Context) {
|
fn other_params(cx: &mut Context) {
|
||||||
VStack::new(cx, |cx| {
|
VStack::new(cx, |cx| {
|
||||||
HStack::new(cx, move |cx| {
|
HStack::new(cx, |cx| {
|
||||||
Label::new(cx, "Filter Stages").class("param-label");
|
Label::new(cx, "Filter Stages").class("param-label");
|
||||||
RestrictedParamSlider::new(
|
RestrictedParamSlider::new(
|
||||||
cx,
|
cx,
|
||||||
|
@ -209,25 +211,26 @@ fn other_params(cx: &mut Context) {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
.size(Auto)
|
||||||
.bottom(Pixels(10.0));
|
.bottom(Pixels(10.0));
|
||||||
|
|
||||||
HStack::new(cx, move |cx| {
|
HStack::new(cx, |cx| {
|
||||||
Label::new(cx, "Frequency Spread").class("param-label");
|
Label::new(cx, "Frequency Spread").class("param-label");
|
||||||
ParamSlider::new(cx, Data::params, |params| ¶ms.filter_spread_octaves);
|
ParamSlider::new(cx, Data::params, |params| ¶ms.filter_spread_octaves);
|
||||||
})
|
})
|
||||||
|
.size(Auto)
|
||||||
.bottom(Pixels(10.0));
|
.bottom(Pixels(10.0));
|
||||||
|
|
||||||
HStack::new(cx, move |cx| {
|
HStack::new(cx, |cx| {
|
||||||
Label::new(cx, "Spread Style").class("param-label");
|
Label::new(cx, "Spread Style").class("param-label");
|
||||||
ParamSlider::new(cx, Data::params, |params| ¶ms.filter_spread_style)
|
ParamSlider::new(cx, Data::params, |params| ¶ms.filter_spread_style)
|
||||||
.set_style(ParamSliderStyle::CurrentStepLabeled { even: true });
|
.set_style(ParamSliderStyle::CurrentStepLabeled { even: true });
|
||||||
});
|
})
|
||||||
|
.size(Auto);
|
||||||
})
|
})
|
||||||
.id("param-sliders")
|
.id("param-sliders")
|
||||||
.width(Percentage(100.0))
|
.width(Percentage(100.0))
|
||||||
.top(Pixels(7.0))
|
|
||||||
// This should take up all remaining space
|
// This should take up all remaining space
|
||||||
.bottom(Stretch(1.0))
|
.height(Stretch(1.0))
|
||||||
.child_space(Stretch(1.0))
|
.child_space(Stretch(1.0));
|
||||||
.child_left(Stretch(1.0));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,9 +90,8 @@ impl View for SpectrumAnalyzer {
|
||||||
// NOTE: We could do the same thing like in Spectral Compressor and draw part of this
|
// NOTE: We could do the same thing like in Spectral Compressor and draw part of this
|
||||||
// spectrum analyzer as a single mesh but for whatever erason the aliasing/moire
|
// spectrum analyzer as a single mesh but for whatever erason the aliasing/moire
|
||||||
// pattern here doesn't look nearly as bad.
|
// pattern here doesn't look nearly as bad.
|
||||||
let line_width = cx.style.dpi_factor as f32 * 1.5;
|
let line_width = cx.scale_factor() * 1.5;
|
||||||
let paint = vg::Paint::color(cx.font_color().cloned().unwrap_or_default().into())
|
let paint = vg::Paint::color(cx.font_color().into()).with_line_width(line_width);
|
||||||
.with_line_width(line_width);
|
|
||||||
let mut path = vg::Path::new();
|
let mut path = vg::Path::new();
|
||||||
for (bin_idx, magnitude) in spectrum.iter().enumerate() {
|
for (bin_idx, magnitude) in spectrum.iter().enumerate() {
|
||||||
// We'll match up the bin's x-coordinate with the filter frequency parameter
|
// We'll match up the bin's x-coordinate with the filter frequency parameter
|
||||||
|
@ -117,6 +116,6 @@ impl View for SpectrumAnalyzer {
|
||||||
path.line_to(bounds.x + (bounds.w * t), bounds.y + bounds.h);
|
path.line_to(bounds.x + (bounds.w * t), bounds.y + bounds.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.stroke_path(&mut path, &paint);
|
canvas.stroke_path(&path, &paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,15 +31,15 @@ pub struct SafeModeButton<L: Lens<Target = SafeModeClamper>> {
|
||||||
|
|
||||||
impl<L: Lens<Target = SafeModeClamper>> SafeModeButton<L> {
|
impl<L: Lens<Target = SafeModeClamper>> SafeModeButton<L> {
|
||||||
/// Creates a new button bound to the [`SafeModeClamper`].
|
/// Creates a new button bound to the [`SafeModeClamper`].
|
||||||
pub fn new<T>(cx: &mut Context, lens: L, label: impl Res<T>) -> Handle<Self>
|
pub fn new<T>(cx: &mut Context, lens: L, label: impl Res<T> + Clone) -> Handle<Self>
|
||||||
where
|
where
|
||||||
T: ToString,
|
T: ToString,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
lens: lens.clone(),
|
lens,
|
||||||
scrolled_lines: 0.0,
|
scrolled_lines: 0.0,
|
||||||
}
|
}
|
||||||
.build(cx, move |cx| {
|
.build(cx, |cx| {
|
||||||
Label::new(cx, label).hoverable(false);
|
Label::new(cx, label).hoverable(false);
|
||||||
})
|
})
|
||||||
.checked(lens.map(|v| v.status()))
|
.checked(lens.map(|v| v.status()))
|
||||||
|
|
|
@ -91,7 +91,7 @@ impl RestrictedParamSlider {
|
||||||
{
|
{
|
||||||
// See the original `ParamSlider` implementation for more details.
|
// See the original `ParamSlider` implementation for more details.
|
||||||
Self {
|
Self {
|
||||||
param_base: ParamWidgetBase::new(cx, params.clone(), params_to_param),
|
param_base: ParamWidgetBase::new(cx, params, params_to_param),
|
||||||
|
|
||||||
renormalize_display: Box::new(renormalize_display.clone()),
|
renormalize_display: Box::new(renormalize_display.clone()),
|
||||||
renormalize_event: Box::new(renormalize_event),
|
renormalize_event: Box::new(renormalize_event),
|
||||||
|
@ -146,15 +146,9 @@ impl RestrictedParamSlider {
|
||||||
RestrictedParamSlider::text_input_active,
|
RestrictedParamSlider::text_input_active,
|
||||||
move |cx, text_input_active| {
|
move |cx, text_input_active| {
|
||||||
if text_input_active.get(cx) {
|
if text_input_active.get(cx) {
|
||||||
Self::text_input_view(cx, display_value_lens.clone());
|
Self::text_input_view(cx, display_value_lens);
|
||||||
} else {
|
} else {
|
||||||
// All of this data needs to be moved into the `ZStack` closure, and
|
ZStack::new(cx, |cx| {
|
||||||
// the `Map` lens combinator isn't `Copy`
|
|
||||||
let fill_start_delta_lens = fill_start_delta_lens.clone();
|
|
||||||
let modulation_start_delta_lens = modulation_start_delta_lens.clone();
|
|
||||||
let display_value_lens = display_value_lens.clone();
|
|
||||||
|
|
||||||
ZStack::new(cx, move |cx| {
|
|
||||||
Self::slider_fill_view(
|
Self::slider_fill_view(
|
||||||
cx,
|
cx,
|
||||||
fill_start_delta_lens,
|
fill_start_delta_lens,
|
||||||
|
@ -204,11 +198,7 @@ impl RestrictedParamSlider {
|
||||||
Element::new(cx)
|
Element::new(cx)
|
||||||
.class("fill")
|
.class("fill")
|
||||||
.height(Stretch(1.0))
|
.height(Stretch(1.0))
|
||||||
.left(
|
.left(fill_start_delta_lens.map(|(start_t, _)| Percentage(start_t * 100.0)))
|
||||||
fill_start_delta_lens
|
|
||||||
.clone()
|
|
||||||
.map(|(start_t, _)| Percentage(start_t * 100.0)),
|
|
||||||
)
|
|
||||||
.width(fill_start_delta_lens.map(|(_, delta)| Percentage(delta * 100.0)))
|
.width(fill_start_delta_lens.map(|(_, delta)| Percentage(delta * 100.0)))
|
||||||
// Hovering is handled on the param slider as a whole, this
|
// Hovering is handled on the param slider as a whole, this
|
||||||
// should not affect that
|
// should not affect that
|
||||||
|
@ -221,18 +211,10 @@ impl RestrictedParamSlider {
|
||||||
.class("fill")
|
.class("fill")
|
||||||
.class("fill--modulation")
|
.class("fill--modulation")
|
||||||
.height(Stretch(1.0))
|
.height(Stretch(1.0))
|
||||||
.visibility(
|
.visibility(modulation_start_delta_lens.map(|(_, delta)| *delta != 0.0))
|
||||||
modulation_start_delta_lens
|
|
||||||
.clone()
|
|
||||||
.map(|(_, delta)| *delta != 0.0),
|
|
||||||
)
|
|
||||||
// Widths cannot be negative, so we need to compensate the start
|
// Widths cannot be negative, so we need to compensate the start
|
||||||
// position if the width does happen to be negative
|
// position if the width does happen to be negative
|
||||||
.width(
|
.width(modulation_start_delta_lens.map(|(_, delta)| Percentage(delta.abs() * 100.0)))
|
||||||
modulation_start_delta_lens
|
|
||||||
.clone()
|
|
||||||
.map(|(_, delta)| Percentage(delta.abs() * 100.0)),
|
|
||||||
)
|
|
||||||
.left(modulation_start_delta_lens.map(|(start_t, delta)| {
|
.left(modulation_start_delta_lens.map(|(start_t, delta)| {
|
||||||
if *delta < 0.0 {
|
if *delta < 0.0 {
|
||||||
Percentage((start_t + delta) * 100.0)
|
Percentage((start_t + delta) * 100.0)
|
||||||
|
@ -330,11 +312,11 @@ impl View for RestrictedParamSlider {
|
||||||
// still won't work.
|
// still won't work.
|
||||||
WindowEvent::MouseDown(MouseButton::Left)
|
WindowEvent::MouseDown(MouseButton::Left)
|
||||||
| WindowEvent::MouseTripleClick(MouseButton::Left) => {
|
| WindowEvent::MouseTripleClick(MouseButton::Left) => {
|
||||||
if cx.modifiers.alt() {
|
if cx.modifiers().alt() {
|
||||||
// ALt+Click brings up a text entry dialog
|
// ALt+Click brings up a text entry dialog
|
||||||
self.text_input_active = true;
|
self.text_input_active = true;
|
||||||
cx.set_active(true);
|
cx.set_active(true);
|
||||||
} else if cx.modifiers.command() {
|
} else if cx.modifiers().command() {
|
||||||
// Ctrl+Click, double click, and right clicks should reset the parameter instead
|
// Ctrl+Click, double click, and right clicks should reset the parameter instead
|
||||||
// of initiating a drag operation
|
// of initiating a drag operation
|
||||||
self.param_base.begin_set_parameter(cx);
|
self.param_base.begin_set_parameter(cx);
|
||||||
|
@ -351,16 +333,16 @@ impl View for RestrictedParamSlider {
|
||||||
// When holding down shift while clicking on a parameter we want to granuarly
|
// When holding down shift while clicking on a parameter we want to granuarly
|
||||||
// edit the parameter without jumping to a new value
|
// edit the parameter without jumping to a new value
|
||||||
self.param_base.begin_set_parameter(cx);
|
self.param_base.begin_set_parameter(cx);
|
||||||
if cx.modifiers.shift() {
|
if cx.modifiers().shift() {
|
||||||
self.granular_drag_status = Some(GranularDragStatus {
|
self.granular_drag_status = Some(GranularDragStatus {
|
||||||
starting_x_coordinate: cx.mouse.cursorx,
|
starting_x_coordinate: cx.mouse().cursorx,
|
||||||
starting_value: self.param_base.unmodulated_normalized_value(),
|
starting_value: self.param_base.unmodulated_normalized_value(),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.granular_drag_status = None;
|
self.granular_drag_status = None;
|
||||||
self.set_normalized_value_drag(
|
self.set_normalized_value_drag(
|
||||||
cx,
|
cx,
|
||||||
util::remap_current_entity_x_coordinate(cx, cx.mouse.cursorx),
|
util::remap_current_entity_x_coordinate(cx, cx.mouse().cursorx),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,7 +377,7 @@ impl View for RestrictedParamSlider {
|
||||||
if self.drag_active {
|
if self.drag_active {
|
||||||
// If shift is being held then the drag should be more granular instead of
|
// If shift is being held then the drag should be more granular instead of
|
||||||
// absolute
|
// absolute
|
||||||
if cx.modifiers.shift() {
|
if cx.modifiers().shift() {
|
||||||
let granular_drag_status =
|
let granular_drag_status =
|
||||||
*self
|
*self
|
||||||
.granular_drag_status
|
.granular_drag_status
|
||||||
|
@ -413,7 +395,7 @@ impl View for RestrictedParamSlider {
|
||||||
);
|
);
|
||||||
let delta_x = (*x - granular_drag_status.starting_x_coordinate)
|
let delta_x = (*x - granular_drag_status.starting_x_coordinate)
|
||||||
* GRANULAR_DRAG_MULTIPLIER
|
* GRANULAR_DRAG_MULTIPLIER
|
||||||
* cx.style.dpi_factor as f32;
|
* cx.scale_factor();
|
||||||
|
|
||||||
self.set_normalized_value_drag(
|
self.set_normalized_value_drag(
|
||||||
cx,
|
cx,
|
||||||
|
@ -436,7 +418,7 @@ impl View for RestrictedParamSlider {
|
||||||
self.granular_drag_status = None;
|
self.granular_drag_status = None;
|
||||||
self.param_base.set_normalized_value(
|
self.param_base.set_normalized_value(
|
||||||
cx,
|
cx,
|
||||||
util::remap_current_entity_x_coordinate(cx, cx.mouse.cursorx),
|
util::remap_current_entity_x_coordinate(cx, cx.mouse().cursorx),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,7 +432,7 @@ impl View for RestrictedParamSlider {
|
||||||
|value| (self.renormalize_event)((self.renormalize_display)(value));
|
|value| (self.renormalize_event)((self.renormalize_display)(value));
|
||||||
|
|
||||||
if self.scrolled_lines.abs() >= 1.0 {
|
if self.scrolled_lines.abs() >= 1.0 {
|
||||||
let use_finer_steps = cx.modifiers.shift();
|
let use_finer_steps = cx.modifiers().shift();
|
||||||
|
|
||||||
// Scrolling while dragging needs to be taken into account here
|
// Scrolling while dragging needs to be taken into account here
|
||||||
if !self.drag_active {
|
if !self.drag_active {
|
||||||
|
|
|
@ -138,85 +138,68 @@ impl XyPad {
|
||||||
cx,
|
cx,
|
||||||
// We need to create lenses for both the x-parameter's values and the y-parameter's
|
// We need to create lenses for both the x-parameter's values and the y-parameter's
|
||||||
// values
|
// values
|
||||||
ParamWidgetBase::build_view(
|
ParamWidgetBase::build_view(params, params_to_x_param, move |cx, x_param_data| {
|
||||||
params,
|
ParamWidgetBase::view(cx, params, params_to_y_param, move |cx, y_param_data| {
|
||||||
params_to_x_param,
|
// The x-parameter's range is clamped when safe mode is enabled
|
||||||
move |cx, x_param_data| {
|
let x_position_lens = {
|
||||||
ParamWidgetBase::view(
|
let x_renormalize_display = x_renormalize_display.clone();
|
||||||
|
x_param_data.make_lens(move |param| {
|
||||||
|
Percentage(
|
||||||
|
x_renormalize_display(param.unmodulated_normalized_value()) * 100.0,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
let y_position_lens = y_param_data.make_lens(|param| {
|
||||||
|
// NOTE: The y-axis increments downards, and we want high values at
|
||||||
|
// the top and low values at the bottom
|
||||||
|
Percentage((1.0 - param.unmodulated_normalized_value()) * 100.0)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Another handle is drawn below the regular handle to show the
|
||||||
|
// modualted value
|
||||||
|
let modulated_x_position_lens = x_param_data.make_lens(move |param| {
|
||||||
|
Percentage(
|
||||||
|
x_renormalize_display(param.modulated_normalized_value()) * 100.0,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
let modulated_y_position_lens = y_param_data.make_lens(|param| {
|
||||||
|
Percentage((1.0 - param.modulated_normalized_value()) * 100.0)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Can't use `.to_string()` here as that would include the modulation.
|
||||||
|
let x_display_value_lens = x_param_data.make_lens(|param| {
|
||||||
|
param.normalized_value_to_string(param.unmodulated_normalized_value(), true)
|
||||||
|
});
|
||||||
|
let y_display_value_lens = y_param_data.make_lens(|param| {
|
||||||
|
param.normalized_value_to_string(param.unmodulated_normalized_value(), true)
|
||||||
|
});
|
||||||
|
|
||||||
|
// When the X-Y pad gets Alt+clicked, we'll replace it with a text input
|
||||||
|
// box for the frequency parameter
|
||||||
|
Binding::new(
|
||||||
cx,
|
cx,
|
||||||
params,
|
XyPad::text_input_active,
|
||||||
params_to_y_param,
|
move |cx, text_input_active| {
|
||||||
move |cx, y_param_data| {
|
if text_input_active.get(cx) {
|
||||||
// The x-parameter's range is clamped when safe mode is enabled
|
Self::text_input_view(cx, x_display_value_lens);
|
||||||
let x_position_lens = {
|
} else {
|
||||||
let x_renormalize_display = x_renormalize_display.clone();
|
Self::xy_pad_modulation_handle_view(
|
||||||
x_param_data.make_lens(move |param| {
|
cx,
|
||||||
Percentage(
|
modulated_x_position_lens,
|
||||||
x_renormalize_display(param.unmodulated_normalized_value())
|
modulated_y_position_lens,
|
||||||
* 100.0,
|
);
|
||||||
)
|
Self::xy_pad_handle_view(
|
||||||
})
|
cx,
|
||||||
};
|
x_position_lens,
|
||||||
let y_position_lens = y_param_data.make_lens(|param| {
|
y_position_lens,
|
||||||
// NOTE: The y-axis increments downards, and we want high values at
|
x_display_value_lens,
|
||||||
// the top and low values at the bottom
|
y_display_value_lens,
|
||||||
Percentage((1.0 - param.unmodulated_normalized_value()) * 100.0)
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
// Another handle is drawn below the regular handle to show the
|
|
||||||
// modualted value
|
|
||||||
let modulated_x_position_lens = x_param_data.make_lens(move |param| {
|
|
||||||
Percentage(
|
|
||||||
x_renormalize_display(param.modulated_normalized_value())
|
|
||||||
* 100.0,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
let modulated_y_position_lens = y_param_data.make_lens(|param| {
|
|
||||||
Percentage((1.0 - param.modulated_normalized_value()) * 100.0)
|
|
||||||
});
|
|
||||||
|
|
||||||
// Can't use `.to_string()` here as that would include the modulation.
|
|
||||||
let x_display_value_lens = x_param_data.make_lens(|param| {
|
|
||||||
param.normalized_value_to_string(
|
|
||||||
param.unmodulated_normalized_value(),
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
let y_display_value_lens = y_param_data.make_lens(|param| {
|
|
||||||
param.normalized_value_to_string(
|
|
||||||
param.unmodulated_normalized_value(),
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
// When the X-Y pad gets Alt+clicked, we'll replace it with a text input
|
|
||||||
// box for the frequency parameter
|
|
||||||
Binding::new(
|
|
||||||
cx,
|
|
||||||
XyPad::text_input_active,
|
|
||||||
move |cx, text_input_active| {
|
|
||||||
if text_input_active.get(cx) {
|
|
||||||
Self::text_input_view(cx, x_display_value_lens);
|
|
||||||
} else {
|
|
||||||
Self::xy_pad_modulation_handle_view(
|
|
||||||
cx,
|
|
||||||
modulated_x_position_lens,
|
|
||||||
modulated_y_position_lens,
|
|
||||||
);
|
|
||||||
Self::xy_pad_handle_view(
|
|
||||||
cx,
|
|
||||||
x_position_lens,
|
|
||||||
y_position_lens,
|
|
||||||
x_display_value_lens,
|
|
||||||
y_display_value_lens,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +240,7 @@ impl XyPad {
|
||||||
// pad. Its position is set to the mouse coordinate in the event
|
// pad. Its position is set to the mouse coordinate in the event
|
||||||
// handler. If there's enough space, the tooltip is drawn at the top
|
// handler. If there's enough space, the tooltip is drawn at the top
|
||||||
// right of the mouse cursor.
|
// right of the mouse cursor.
|
||||||
VStack::new(cx, move |cx| {
|
VStack::new(cx, |cx| {
|
||||||
// The X-parameter is the 'important' one, so we'll display that at
|
// The X-parameter is the 'important' one, so we'll display that at
|
||||||
// the bottom since it's closer to the mouse cursor. We'll also
|
// the bottom since it's closer to the mouse cursor. We'll also
|
||||||
// hardcode the `Q: ` prefix for now to make it a bit clearer and to
|
// hardcode the `Q: ` prefix for now to make it a bit clearer and to
|
||||||
|
|
|
@ -101,7 +101,7 @@ 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().unwrap_or_default() {
|
let border_width = match cx.border_width() {
|
||||||
Units::Pixels(val) => val,
|
Units::Pixels(val) => val,
|
||||||
Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0),
|
Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0),
|
||||||
_ => 0.0,
|
_ => 0.0,
|
||||||
|
@ -122,7 +122,7 @@ impl View for Analyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
let paint = vg::Paint::color(border_color).with_line_width(border_width);
|
let paint = vg::Paint::color(border_color).with_line_width(border_width);
|
||||||
canvas.stroke_path(&mut path, &paint);
|
canvas.stroke_path(&path, &paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,8 +144,8 @@ fn draw_spectrum(
|
||||||
) {
|
) {
|
||||||
let bounds = cx.bounds();
|
let bounds = cx.bounds();
|
||||||
|
|
||||||
let line_width = cx.style.dpi_factor as f32 * 1.5;
|
let line_width = cx.scale_factor() * 1.5;
|
||||||
let text_color: vg::Color = cx.font_color().cloned().unwrap_or_default().into();
|
let text_color: vg::Color = cx.font_color().into();
|
||||||
// This is used to draw the individual bars
|
// This is used to draw the individual bars
|
||||||
let bars_paint = vg::Paint::color(text_color).with_line_width(line_width);
|
let bars_paint = vg::Paint::color(text_color).with_line_width(line_width);
|
||||||
// And this color is used to draw the mesh part of the spectrum. We'll create a gradient paint
|
// And this color is used to draw the mesh part of the spectrum. We'll create a gradient paint
|
||||||
|
@ -265,7 +265,7 @@ fn draw_spectrum(
|
||||||
fn draw_threshold_curve(cx: &mut DrawContext, canvas: &mut Canvas, analyzer_data: &AnalyzerData) {
|
fn draw_threshold_curve(cx: &mut DrawContext, canvas: &mut Canvas, analyzer_data: &AnalyzerData) {
|
||||||
let bounds = cx.bounds();
|
let bounds = cx.bounds();
|
||||||
|
|
||||||
let line_width = cx.style.dpi_factor as f32 * 3.0;
|
let line_width = cx.scale_factor() * 3.0;
|
||||||
let downwards_paint =
|
let downwards_paint =
|
||||||
vg::Paint::color(DOWNWARDS_THRESHOLD_CURVE_COLOR).with_line_width(line_width);
|
vg::Paint::color(DOWNWARDS_THRESHOLD_CURVE_COLOR).with_line_width(line_width);
|
||||||
let upwards_paint = vg::Paint::color(UPWARDS_THRESHOLD_CURVE_COLOR).with_line_width(line_width);
|
let upwards_paint = vg::Paint::color(UPWARDS_THRESHOLD_CURVE_COLOR).with_line_width(line_width);
|
||||||
|
@ -301,7 +301,7 @@ fn draw_threshold_curve(cx: &mut DrawContext, canvas: &mut Canvas, analyzer_data
|
||||||
// This does a way better job at cutting off the tops and bottoms of the graph than we could do
|
// This does a way better job at cutting off the tops and bottoms of the graph than we could do
|
||||||
// by hand
|
// by hand
|
||||||
canvas.scissor(bounds.x, bounds.y, bounds.w, bounds.h);
|
canvas.scissor(bounds.x, bounds.y, bounds.w, bounds.h);
|
||||||
canvas.stroke_path(&mut path, &paint);
|
canvas.stroke_path(&path, &paint);
|
||||||
canvas.reset_scissor();
|
canvas.reset_scissor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -374,6 +374,6 @@ fn draw_gain_reduction(
|
||||||
|
|
||||||
canvas
|
canvas
|
||||||
.global_composite_blend_func(vg::BlendFactor::DstAlpha, vg::BlendFactor::OneMinusDstColor);
|
.global_composite_blend_func(vg::BlendFactor::DstAlpha, vg::BlendFactor::OneMinusDstColor);
|
||||||
canvas.fill_path(&mut path, &paint);
|
canvas.fill_path(&path, &paint);
|
||||||
canvas.global_composite_blend_func(vg::BlendFactor::One, vg::BlendFactor::OneMinusSrcAlpha);
|
canvas.global_composite_blend_func(vg::BlendFactor::One, vg::BlendFactor::OneMinusSrcAlpha);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue