Show the modulation value in Diopser X-Y pad
This commit is contained in:
parent
1d9e7e6256
commit
1ef987a403
|
@ -86,3 +86,7 @@ xy-pad__handle {
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
.xy-pad__handle--modulated {
|
||||||
|
background-color: #a4eafc69;
|
||||||
|
border-color: #a4eafc96;
|
||||||
|
}
|
||||||
|
|
|
@ -142,6 +142,15 @@ impl XyPad {
|
||||||
Percentage((1.0 - param.unmodulated_normalized_value()) * 100.0)
|
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(|param| {
|
||||||
|
Percentage(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.
|
// Can't use `.to_string()` here as that would include the modulation.
|
||||||
let x_display_value_lens = x_param_data.make_lens(|param| {
|
let x_display_value_lens = x_param_data.make_lens(|param| {
|
||||||
param.normalized_value_to_string(
|
param.normalized_value_to_string(
|
||||||
|
@ -165,6 +174,11 @@ impl XyPad {
|
||||||
if text_input_active.get(cx) {
|
if text_input_active.get(cx) {
|
||||||
Self::text_input_view(cx, x_display_value_lens.clone());
|
Self::text_input_view(cx, x_display_value_lens.clone());
|
||||||
} else {
|
} else {
|
||||||
|
Self::xy_pad_modulation_handle_view(
|
||||||
|
cx,
|
||||||
|
modulated_x_position_lens.clone(),
|
||||||
|
modulated_y_position_lens.clone(),
|
||||||
|
);
|
||||||
Self::xy_pad_handle_view(
|
Self::xy_pad_handle_view(
|
||||||
cx,
|
cx,
|
||||||
x_position_lens.clone(),
|
x_position_lens.clone(),
|
||||||
|
@ -247,6 +261,24 @@ impl XyPad {
|
||||||
.hoverable(false);
|
.hoverable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The secondary handle that shows the modulated value if the plugin is being monophonically
|
||||||
|
/// modualted.
|
||||||
|
fn xy_pad_modulation_handle_view(
|
||||||
|
cx: &mut Context,
|
||||||
|
modulated_x_position_lens: impl Lens<Target = Units>,
|
||||||
|
modulated_y_position_lens: impl Lens<Target = Units>,
|
||||||
|
) {
|
||||||
|
XyPadHandle::new(cx)
|
||||||
|
.class("xy-pad__handle--modulated")
|
||||||
|
.position_type(PositionType::SelfDirected)
|
||||||
|
.top(modulated_y_position_lens)
|
||||||
|
.left(modulated_x_position_lens)
|
||||||
|
.translate((-(HANDLE_WIDTH_PX / 2.0), -(HANDLE_WIDTH_PX / 2.0)))
|
||||||
|
.width(Pixels(HANDLE_WIDTH_PX))
|
||||||
|
.height(Pixels(HANDLE_WIDTH_PX))
|
||||||
|
.hoverable(false);
|
||||||
|
}
|
||||||
|
|
||||||
/// Should be called at the start of a drag operation.
|
/// Should be called at the start of a drag operation.
|
||||||
fn begin_set_parameters(&self, cx: &mut EventContext) {
|
fn begin_set_parameters(&self, cx: &mut EventContext) {
|
||||||
// NOTE: Since the X-parameter is the main parmaeter, we'll always modify this parameter
|
// NOTE: Since the X-parameter is the main parmaeter, we'll always modify this parameter
|
||||||
|
|
Loading…
Reference in a new issue