diff --git a/plugins/spectral_compressor/src/editor.rs b/plugins/spectral_compressor/src/editor.rs index 9d1a16b1..488dbed4 100644 --- a/plugins/spectral_compressor/src/editor.rs +++ b/plugins/spectral_compressor/src/editor.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use crossbeam::atomic::AtomicCell; use nih_plug::prelude::*; use nih_plug_vizia::vizia::prelude::*; use nih_plug_vizia::widgets::*; @@ -21,6 +22,7 @@ use nih_plug_vizia::{assets, create_vizia_editor, ViziaState, ViziaTheming}; use serde::{Deserialize, Serialize}; use std::sync::Arc; +use self::mode_button::EditorModeButton; use crate::{SpectralCompressor, SpectralCompressorParams}; mod mode_button; @@ -58,8 +60,11 @@ struct Data { 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::new(|| (EXPANDED_GUI_WIDTH, GUI_HEIGHT)) +pub(crate) fn default_state(editor_mode: Arc>) -> Arc { + ViziaState::new(move || match editor_mode.load() { + EditorMode::Collapsed => (COLLAPSED_GUI_WIDTH, GUI_HEIGHT), + EditorMode::VisualizerVisible => (EXPANDED_GUI_WIDTH, GUI_HEIGHT), + }) } pub(crate) fn create( diff --git a/plugins/spectral_compressor/src/lib.rs b/plugins/spectral_compressor/src/lib.rs index 4147fb60..d2baaa9d 100644 --- a/plugins/spectral_compressor/src/lib.rs +++ b/plugins/spectral_compressor/src/lib.rs @@ -243,9 +243,11 @@ impl SpectralCompressorParams { /// Create a new [`SpectralCompressorParams`] object. Changing any of the compressor threshold /// or ratio parameters causes the passed compressor bank's parameters to be updated. pub fn new(compressor_bank: &compressor_bank::CompressorBank) -> Self { + let editor_mode: Arc> = Arc::default(); + SpectralCompressorParams { - editor_state: editor::default_state(), - editor_mode: Arc::default(), + editor_state: editor::default_state(editor_mode.clone()), + editor_mode, // TODO: Do still enable per-block smoothing for these settings, because why not. This // will require updating the compressor bank.