Skip to content

Commit

Permalink
tweak look
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Apr 23, 2024
1 parent e133e7d commit 2c31161
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 89 deletions.
172 changes: 97 additions & 75 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use cyma::{
};

const METER_MIN: f32 = -26.0;
const METER_MAX: f32 = 0.0;
const METER_MAX: f32 = 2.0;

#[derive(Lens, Clone)]
struct LambData {
Expand Down Expand Up @@ -194,7 +194,7 @@ pub(crate) fn create(
// .height(Pixels(260.0));
Label::new(cx, "GR graph time scale").class("fader-label");
ParamSlider::new(cx, LambData::params, |params| &params.time_scale)
.set_style(ParamSliderStyle::CurrentStep{ even: true })
.set_style(ParamSliderStyle::CurrentStep { even: true })
.bottom(Pixels(6.0));
}) // graph + zoom
.height(Auto)
Expand Down Expand Up @@ -261,7 +261,8 @@ impl<AttackReleaseDataL: Lens<Target = Arc<LambParams>>> View
// let border_width = cx.scale_factor() * cx.border_width();
let border_width = cx.border_width();

let rounding = 3.0 * border_width;
// let rounding = 3.0 * border_width;
let rounding = 0.0;

// Create a new `Path` from the `vg` module.
let x = bounds.x + border_width / 2.0;
Expand Down Expand Up @@ -377,107 +378,124 @@ impl<AttackReleaseDataL: Lens<Target = Arc<LambParams>>> View
/// Draws a peak graph with a grid backdrop, unit ruler, and a peak meter to side.
fn peak_graph(cx: &mut Context) {
HStack::new(cx, |cx| {
HStack::new(cx, |cx| {
ZStack::new(cx, |cx| {
Grid::new(
cx,
ValueScaling::Linear,
(METER_MIN, METER_MAX),
vec![0.0, -6.0, -12.0, -18.0, -24.0],
Orientation::Horizontal,
)
ZStack::new(cx, |cx| {
Grid::new(
cx,
ValueScaling::Linear,
(METER_MIN, METER_MAX),
vec![0.0, -6.0, -12.0, -18.0, -24.0],
Orientation::Horizontal,
)
.color(Color::rgba(160, 160, 160, 60));

// level
Graph::new(
cx,
LambData::level_buffer_l,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
// level
Graph::new(
cx,
LambData::level_buffer_l,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
.color(Color::rgba(0, 0, 255, 30))
.background_color(Color::rgba(0, 0, 0, 40));

Graph::new(
cx,
LambData::level_buffer_r,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
Graph::new(
cx,
LambData::level_buffer_r,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
.color(Color::rgba(255, 0, 0, 30))
.background_color(Color::rgba(0, 0, 0, 40));

// gain reduction
Graph::new(
cx,
LambData::gr_buffer_l,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
// gain reduction
Graph::new(
cx,
LambData::gr_buffer_l,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
.color(Color::rgba(0, 0, 255, 255))
.background_color(Color::rgba(250, 250, 250, 40))
.fill_from(0.0);
Graph::new(
cx,
LambData::gr_buffer_r,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
Graph::new(
cx,
LambData::gr_buffer_r,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
)
.color(Color::rgba(255, 0, 0, 255))
.background_color(Color::rgba(250, 250, 250, 40))
.fill_from(0.0);
});
// gain reduction
});

ZStack::new(cx, |cx| {
HStack::new(cx, |cx| {
// gain reduction
HStack::new(cx, |cx| {
Meter::new(
cx,
LambData::gr_buffer_l,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
Orientation::Vertical,
)
.background_color(Color::rgb(250, 250, 250))
.color(Color::rgba(0, 0, 255, 255));
})
.left(Pixels(4.0))
.width(Pixels(15.0))
.background_color(Color::rgb(220, 220, 220));
HStack::new(cx, |cx| {
Meter::new(
cx,
LambData::gr_buffer_r,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
Orientation::Vertical,
)
.background_color(Color::rgb(250, 250, 250))
.color(Color::rgba(255, 0, 0, 255));
})
.width(Pixels(15.0))
.background_color(Color::rgb(220, 220, 220));
// level
Meter::new(
cx,
LambData::gr_buffer_l,
LambData::level_buffer_l,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
Orientation::Vertical,
)
.background_color(Color::rgb(250, 250, 250))
.color(Color::rgba(0, 0, 255, 255));
})
.width(Pixels(15.0))
.background_color(Color::rgb(220, 220, 220));
HStack::new(cx, |cx| {
.width(Pixels(15.0))
.color(Color::rgba(0, 0, 255, 255))
.background_color(Color::rgba(60, 60, 60, 60));
Meter::new(
cx,
LambData::gr_buffer_r,
LambData::level_buffer_r,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
Orientation::Vertical,
)
.background_color(Color::rgb(250, 250, 250))
.color(Color::rgba(255, 0, 0, 255));
.width(Pixels(15.0))
.color(Color::rgba(255, 0, 0, 255))
.background_color(Color::rgba(60, 60, 60, 60));
})
.width(Pixels(15.0))
.background_color(Color::rgb(220, 220, 220));
// level
Meter::new(
cx,
LambData::level_buffer_l,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
Orientation::Vertical,
)
.width(Pixels(15.0))
.color(Color::rgba(0, 0, 255, 125))
.background_color(Color::rgba(60, 60, 60, 60));
Meter::new(
.col_between(Pixels(2.))
.width(Auto)
;
Grid::new(
cx,
LambData::level_buffer_r,
ValueScaling::Linear,
(METER_MIN, METER_MAX),
ValueScaling::Decibels,
Orientation::Vertical,
vec![0.0, -6.0, -12.0, -18.0, -24.0],
Orientation::Horizontal,
)
.width(Pixels(15.0))
.color(Color::rgba(255, 0, 0, 125))
.background_color(Color::rgba(60, 60, 60, 60));
.color(Color::rgba(160, 160, 160, 60));

})
.border_color(Color::rgb(80, 80, 80))
.border_width(Pixels(1.));
.width(Pixels(70.0))
// .width(Auto)
;
UnitRuler::new(
cx,
(METER_MIN, METER_MAX),
Expand All @@ -491,12 +509,16 @@ fn peak_graph(cx: &mut Context) {
],
Orientation::Vertical,
)
.left(Pixels(2.0))
.right(Pixels(2.0))
.font_size(12.)
.color(Color::rgb(30, 30, 30))
.width(Pixels(32.));
})
.width(Auto)
.border_color(Color::rgb(163, 163, 163))
.border_width(Pixels(1.4))
.top(Pixels(20.0))
.height(Pixels(260.0))
.width(Percentage(100.0))
.col_between(Pixels(8.));
.height(Pixels(255.0))
.width(Percentage(100.0));
}
24 changes: 10 additions & 14 deletions src/params.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::sync::atomic::{AtomicBool, Ordering};
use faust_types::ParamIndex;
use std::sync::atomic::{AtomicBool, Ordering};

#[derive(Params)]
struct LambParams {
Expand Down Expand Up @@ -166,9 +166,7 @@ pub fn ratio_to_strength() -> Arc<dyn Fn(&str) -> Option<f32> + Send + Sync> {
}

impl LambParams {
pub fn new(
should_update_time_scale: Arc<AtomicBool>,
) -> Self {
pub fn new(should_update_time_scale: Arc<AtomicBool>) -> Self {
Self {
editor_state: editor::default_state(),

Expand Down Expand Up @@ -251,9 +249,9 @@ impl LambParams {
max: 50.0,
},
)
.with_unit(" ms")
.with_step_size(0.01)
.non_automatable(),
.with_unit(" ms")
.with_step_size(0.01)
.non_automatable(),
knee: FloatParam::new(
"knee",
1.0,
Expand Down Expand Up @@ -308,13 +306,11 @@ impl LambParams {
zoom_mode: EnumParam::new("zoom_mode", ZoomMode::Relative)
.hide()
.hide_in_generic_ui(),
time_scale: EnumParam::new("time_scale", TimeScale::EightSec)
.with_callback(
{
let should_update_time_scale = should_update_time_scale.clone();
Arc::new(move |_| should_update_time_scale.store(true, Ordering::Release))
},
)
time_scale: EnumParam::new("time_scale", TimeScale::FourSec)
.with_callback({
let should_update_time_scale = should_update_time_scale.clone();
Arc::new(move |_| should_update_time_scale.store(true, Ordering::Release))
})
.hide()
.hide_in_generic_ui(),
}
Expand Down

0 comments on commit 2c31161

Please sign in to comment.