Compute SC editor size based on the editor mode
Using the new declarative editor size interface.
This commit is contained in:
parent
3be5e3fa99
commit
da61acc7b9
|
@ -14,6 +14,7 @@
|
|||
// 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 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> {
|
||||
ViziaState::new(|| (EXPANDED_GUI_WIDTH, GUI_HEIGHT))
|
||||
pub(crate) fn default_state(editor_mode: Arc<AtomicCell<EditorMode>>) -> Arc<ViziaState> {
|
||||
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(
|
||||
|
|
|
@ -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<AtomicCell<EditorMode>> = 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.
|
||||
|
|
Loading…
Reference in a new issue