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
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use crossbeam::atomic::AtomicCell;
|
||||||
use nih_plug::prelude::*;
|
use nih_plug::prelude::*;
|
||||||
use nih_plug_vizia::vizia::prelude::*;
|
use nih_plug_vizia::vizia::prelude::*;
|
||||||
use nih_plug_vizia::widgets::*;
|
use nih_plug_vizia::widgets::*;
|
||||||
|
@ -21,6 +22,7 @@ use nih_plug_vizia::{assets, create_vizia_editor, ViziaState, ViziaTheming};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use self::mode_button::EditorModeButton;
|
||||||
use crate::{SpectralCompressor, SpectralCompressorParams};
|
use crate::{SpectralCompressor, SpectralCompressorParams};
|
||||||
|
|
||||||
mod mode_button;
|
mod mode_button;
|
||||||
|
@ -58,8 +60,11 @@ struct Data {
|
||||||
impl Model for Data {}
|
impl Model for Data {}
|
||||||
|
|
||||||
// Makes sense to also define this here, makes it a bit easier to keep track of
|
// Makes sense to also define this here, makes it a bit easier to keep track of
|
||||||
pub(crate) fn default_state() -> Arc<ViziaState> {
|
pub(crate) fn default_state(editor_mode: Arc<AtomicCell<EditorMode>>) -> Arc<ViziaState> {
|
||||||
ViziaState::new(|| (EXPANDED_GUI_WIDTH, GUI_HEIGHT))
|
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(
|
pub(crate) fn create(
|
||||||
|
|
|
@ -243,9 +243,11 @@ impl SpectralCompressorParams {
|
||||||
/// Create a new [`SpectralCompressorParams`] object. Changing any of the compressor threshold
|
/// Create a new [`SpectralCompressorParams`] object. Changing any of the compressor threshold
|
||||||
/// or ratio parameters causes the passed compressor bank's parameters to be updated.
|
/// or ratio parameters causes the passed compressor bank's parameters to be updated.
|
||||||
pub fn new(compressor_bank: &compressor_bank::CompressorBank) -> Self {
|
pub fn new(compressor_bank: &compressor_bank::CompressorBank) -> Self {
|
||||||
|
let editor_mode: Arc<AtomicCell<EditorMode>> = Arc::default();
|
||||||
|
|
||||||
SpectralCompressorParams {
|
SpectralCompressorParams {
|
||||||
editor_state: editor::default_state(),
|
editor_state: editor::default_state(editor_mode.clone()),
|
||||||
editor_mode: Arc::default(),
|
editor_mode,
|
||||||
|
|
||||||
// TODO: Do still enable per-block smoothing for these settings, because why not. This
|
// TODO: Do still enable per-block smoothing for these settings, because why not. This
|
||||||
// will require updating the compressor bank.
|
// will require updating the compressor bank.
|
||||||
|
|
Loading…
Reference in a new issue