2022-07-14 06:27:56 +10:00
|
|
|
// Spectral Compressor: an FFT based compressor
|
|
|
|
// Copyright (C) 2021-2022 Robbert van der Helm
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
use nih_plug::prelude::Editor;
|
|
|
|
use nih_plug_vizia::vizia::prelude::*;
|
|
|
|
use nih_plug_vizia::widgets::*;
|
|
|
|
use nih_plug_vizia::{assets, create_vizia_editor, ViziaState};
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use crate::SpectralCompressorParams;
|
|
|
|
|
|
|
|
/// VIZIA uses points instead of pixels for text
|
|
|
|
const POINT_SCALE: f32 = 0.75;
|
|
|
|
|
|
|
|
#[derive(Lens)]
|
|
|
|
struct Data {
|
|
|
|
params: Arc<SpectralCompressorParams>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Model for Data {}
|
|
|
|
|
|
|
|
// Makes sense to also define this here, makes it a bit easier to keep track of
|
|
|
|
pub(crate) fn default_state() -> Arc<ViziaState> {
|
2022-07-22 23:51:54 +10:00
|
|
|
ViziaState::from_size(380, 500)
|
2022-07-14 06:27:56 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn create(
|
|
|
|
params: Arc<SpectralCompressorParams>,
|
|
|
|
editor_state: Arc<ViziaState>,
|
|
|
|
) -> Option<Box<dyn Editor>> {
|
|
|
|
create_vizia_editor(editor_state, move |cx, _| {
|
|
|
|
Data {
|
|
|
|
params: params.clone(),
|
|
|
|
}
|
|
|
|
.build(cx);
|
|
|
|
|
|
|
|
ResizeHandle::new(cx);
|
|
|
|
|
|
|
|
VStack::new(cx, |cx| {
|
|
|
|
Label::new(cx, "Spectral Compressor")
|
|
|
|
.font(assets::NOTO_SANS_THIN)
|
|
|
|
.font_size(40.0 * POINT_SCALE)
|
|
|
|
.height(Pixels(50.0))
|
|
|
|
.child_top(Stretch(1.0))
|
|
|
|
.child_bottom(Pixels(0.0))
|
2022-07-21 04:27:25 +10:00
|
|
|
.right(Pixels(10.0));
|
2022-07-14 06:27:56 +10:00
|
|
|
|
2022-07-21 04:27:25 +10:00
|
|
|
ScrollView::new(cx, 0.0, 0.0, false, true, |cx| {
|
|
|
|
// This looks better if it's flush at the top, and then we'll just add some padding
|
|
|
|
// at the top of the scroll view
|
|
|
|
GenericUi::new(cx, Data::params).child_top(Pixels(0.0));
|
|
|
|
})
|
|
|
|
.width(Percentage(100.0))
|
|
|
|
.top(Pixels(5.0));
|
2022-07-14 06:27:56 +10:00
|
|
|
})
|
|
|
|
.row_between(Pixels(0.0))
|
|
|
|
.child_left(Stretch(1.0))
|
|
|
|
.child_right(Stretch(1.0));
|
|
|
|
})
|
|
|
|
}
|