From 65b893828678cff4d9de5c335c64ae03bc305913 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Tue, 23 Mar 2021 22:04:06 +0100 Subject: [PATCH] #231 Save/load compartment parameter settings together with compartment --- main/src/application/controller_preset.rs | 11 +- main/src/application/main_preset.rs | 12 +- main/src/application/preset.rs | 12 +- main/src/application/session.rs | 135 +++++++++++++----- .../infrastructure/data/controller_preset.rs | 18 ++- main/src/infrastructure/data/main_preset.rs | 16 ++- .../src/infrastructure/data/parameter_data.rs | 2 +- main/src/infrastructure/data/preset.rs | 15 +- main/src/infrastructure/data/session_data.rs | 12 +- main/src/infrastructure/ui/header_panel.rs | 39 +++-- 10 files changed, 204 insertions(+), 68 deletions(-) diff --git a/main/src/application/controller_preset.rs b/main/src/application/controller_preset.rs index 8b9b0d426..c6769141d 100644 --- a/main/src/application/controller_preset.rs +++ b/main/src/application/controller_preset.rs @@ -1,4 +1,4 @@ -use crate::application::{GroupModel, MappingModel, Preset}; +use crate::application::{GroupModel, MappingModel, ParameterSetting, Preset}; use std::collections::HashMap; use std::fmt; @@ -9,6 +9,7 @@ pub struct ControllerPreset { default_group: GroupModel, groups: Vec, mappings: Vec, + parameters: HashMap, custom_data: HashMap, } @@ -19,6 +20,7 @@ impl ControllerPreset { default_group: GroupModel, groups: Vec, mappings: Vec, + parameters: HashMap, custom_data: HashMap, ) -> ControllerPreset { ControllerPreset { @@ -27,6 +29,7 @@ impl ControllerPreset { default_group, groups, mappings, + parameters, custom_data, } } @@ -47,10 +50,12 @@ impl ControllerPreset { default_group: GroupModel, groups: Vec, mappings: Vec, + parameters: HashMap, ) { self.default_group = default_group; self.groups = groups; self.mappings = mappings; + self.parameters = parameters; } } @@ -70,6 +75,10 @@ impl Preset for ControllerPreset { fn mappings(&self) -> &Vec { &self.mappings } + + fn parameters(&self) -> &HashMap { + &self.parameters + } } impl fmt::Display for ControllerPreset { diff --git a/main/src/application/main_preset.rs b/main/src/application/main_preset.rs index 0f7766e9b..835958e2a 100644 --- a/main/src/application/main_preset.rs +++ b/main/src/application/main_preset.rs @@ -1,4 +1,5 @@ -use crate::application::{GroupModel, MappingModel, Preset, SharedMapping}; +use crate::application::{GroupModel, MappingModel, ParameterSetting, Preset, SharedMapping}; +use std::collections::HashMap; use std::fmt; #[derive(Clone, Debug)] @@ -8,6 +9,7 @@ pub struct MainPreset { default_group: GroupModel, groups: Vec, mappings: Vec, + parameters: HashMap, } impl MainPreset { @@ -17,6 +19,7 @@ impl MainPreset { default_group: GroupModel, groups: Vec, mappings: Vec, + parameters: HashMap, ) -> MainPreset { MainPreset { id, @@ -24,6 +27,7 @@ impl MainPreset { default_group, groups, mappings, + parameters, } } @@ -36,10 +40,12 @@ impl MainPreset { default_group: GroupModel, groups: Vec, mappings: Vec, + parameters: HashMap, ) { self.default_group = default_group; self.groups = groups; self.mappings = mappings; + self.parameters = parameters; } } @@ -59,6 +65,10 @@ impl Preset for MainPreset { fn mappings(&self) -> &Vec { &self.mappings } + + fn parameters(&self) -> &HashMap { + &self.parameters + } } impl fmt::Display for MainPreset { diff --git a/main/src/application/preset.rs b/main/src/application/preset.rs index 06977c228..ba6a3a189 100644 --- a/main/src/application/preset.rs +++ b/main/src/application/preset.rs @@ -1,5 +1,8 @@ -use crate::application::{GroupModel, MappingModel, SharedGroup, SharedMapping, TargetCategory}; +use crate::application::{ + GroupModel, MappingModel, ParameterSetting, SharedGroup, SharedMapping, TargetCategory, +}; use crate::domain::{ExtendedProcessorContext, VirtualFx, VirtualTrack}; +use std::collections::HashMap; use std::fmt; use std::fmt::Debug; @@ -8,6 +11,7 @@ pub trait Preset: Clone + Debug { fn default_group(&self) -> &GroupModel; fn groups(&self) -> &Vec; fn mappings(&self) -> &Vec; + fn parameters(&self) -> &HashMap; } pub trait PresetManager: fmt::Debug { @@ -17,6 +21,12 @@ pub trait PresetManager: fmt::Debug { fn mappings_are_dirty(&self, id: &str, mappings: &[SharedMapping]) -> bool; + fn parameter_settings_are_dirty( + &self, + id: &str, + parameter_settings: &HashMap, + ) -> bool; + fn groups_are_dirty( &self, id: &str, diff --git a/main/src/application/session.rs b/main/src/application/session.rs index 138694eae..63b84678c 100644 --- a/main/src/application/session.rs +++ b/main/src/application/session.rs @@ -3,6 +3,7 @@ use crate::application::{ MainPresetAutoLoadMode, MappingModel, Preset, PresetLinkManager, PresetManager, SharedGroup, SharedMapping, TargetCategory, TargetModel, VirtualControlElementType, }; +use crate::core::default_util::is_default; use crate::core::{prop, when, AsyncNotifier, Global, Prop}; use crate::domain::{ CompoundMappingSource, DomainEvent, DomainEventHandler, ExtendedProcessorContext, MainMapping, @@ -12,6 +13,7 @@ use crate::domain::{ VirtualSource, COMPARTMENT_PARAMETER_COUNT, PLUGIN_PARAMETER_COUNT, ZEROED_PLUGIN_PARAMETERS, }; use enum_map::{enum_map, EnumMap}; +use serde::{Deserialize, Serialize}; use reaper_high::Reaper; use rx_util::{BoxedUnitEvent, Event, Notifier, SharedItemEvent, SharedPayload, UnitEvent}; @@ -70,6 +72,7 @@ pub struct Session { mapping_list_changed_subject: LocalSubject<'static, (MappingCompartment, Option), ()>, group_list_changed_subject: LocalSubject<'static, MappingCompartment, ()>, + parameter_settings_changed_subject: LocalSubject<'static, MappingCompartment, ()>, mapping_changed_subject: LocalSubject<'static, MappingCompartment, ()>, group_changed_subject: LocalSubject<'static, MappingCompartment, ()>, source_touched_subject: LocalSubject<'static, CompoundMappingSource, ()>, @@ -186,6 +189,7 @@ impl Session { everything_changed_subject: Default::default(), mapping_list_changed_subject: Default::default(), group_list_changed_subject: Default::default(), + parameter_settings_changed_subject: Default::default(), mapping_changed_subject: Default::default(), group_changed_subject: Default::default(), source_touched_subject: Default::default(), @@ -267,6 +271,18 @@ impl Session { &self.parameter_settings[compartment][index as usize] } + pub fn non_default_parameter_settings_by_compartment( + &self, + compartment: MappingCompartment, + ) -> HashMap { + self.parameter_settings[compartment] + .iter() + .enumerate() + .filter(|(_, s)| !s.is_default()) + .map(|(i, s)| (i as u32, s.clone())) + .collect() + } + pub fn get_qualified_parameter_name( &self, compartment: MappingCompartment, @@ -282,19 +298,22 @@ impl Session { pub fn get_parameter_name(&self, compartment: MappingCompartment, rel_index: u32) -> String { let setting = &self.parameter_settings[compartment][rel_index as usize]; - match &setting.custom_name { - None => format!("Param {}", rel_index + 1), - Some(n) => n.clone(), + if setting.name.is_empty() { + format!("Param {}", rel_index + 1) + } else { + setting.name.clone() } } - pub fn set_parameter_setting_without_notification( + pub fn set_parameter_settings( &mut self, compartment: MappingCompartment, - rel_index: u32, - parameter_setting: ParameterSetting, + settings: impl Iterator, ) { - self.parameter_settings[compartment][rel_index as usize] = parameter_setting; + for (i, s) in settings { + self.parameter_settings[compartment][i as usize] = s; + } + self.notify_parameter_settings_changed(compartment); } pub fn set_parameter_settings_without_notification( @@ -305,6 +324,18 @@ impl Session { self.parameter_settings[compartment] = parameter_settings; } + pub fn set_parameter_settings_from_non_default( + &mut self, + compartment: MappingCompartment, + parameter_settings: &HashMap, + ) { + let mut settings = empty_parameter_settings(); + for (i, s) in parameter_settings { + settings[*i as usize] = s.clone(); + } + self.parameter_settings[compartment] = settings; + } + fn initial_sync(&mut self, weak_session: WeakSession) { for compartment in MappingCompartment::enum_iter() { self.resubscribe_to_groups(weak_session.clone(), compartment); @@ -1332,33 +1363,42 @@ impl Session { } pub fn controller_preset_is_out_of_date(&self) -> bool { + let compartment = MappingCompartment::ControllerMappings; let id = match &self.active_controller_preset_id { - None => return self.mapping_count(MappingCompartment::ControllerMappings) > 0, + None => return self.mapping_count(compartment) > 0, Some(id) => id, }; self.controller_preset_manager - .mappings_are_dirty(id, &self.mappings[MappingCompartment::ControllerMappings]) + .mappings_are_dirty(id, &self.mappings[compartment]) || self.controller_preset_manager.groups_are_dirty( id, - &self.default_group(MappingCompartment::ControllerMappings), - &self.groups[MappingCompartment::ControllerMappings], + &self.default_group(compartment), + &self.groups[compartment], + ) + || self.controller_preset_manager.parameter_settings_are_dirty( + id, + &self.non_default_parameter_settings_by_compartment(compartment), ) } pub fn main_preset_is_out_of_date(&self) -> bool { + let compartment = MappingCompartment::MainMappings; let id = match &self.active_main_preset_id { None => { - return self.mapping_count(MappingCompartment::MainMappings) > 0 - || !self.groups.is_empty(); + return self.mapping_count(compartment) > 0 || !self.groups.is_empty(); } Some(id) => id, }; self.main_preset_manager - .mappings_are_dirty(id, &self.mappings[MappingCompartment::MainMappings]) + .mappings_are_dirty(id, &self.mappings[compartment]) || self.main_preset_manager.groups_are_dirty( id, &self.default_main_group, - &self.groups[MappingCompartment::MainMappings], + &self.groups[compartment], + ) + || self.main_preset_manager.parameter_settings_are_dirty( + id, + &self.non_default_parameter_settings_by_compartment(compartment), ) } @@ -1367,20 +1407,22 @@ impl Session { id: Option, weak_session: WeakSession, ) -> Result<(), &'static str> { + // TODO-medium The code duplication with main mappings is terrible. let compartment = MappingCompartment::ControllerMappings; self.active_controller_preset_id = id.clone(); if let Some(id) = id.as_ref() { - let controller = self + let preset = self .controller_preset_manager .find_by_id(id) - .ok_or("controller not found")?; - self.set_mappings_without_notification( - compartment, - controller.mappings().iter().cloned(), - ); + .ok_or("controller preset not found")?; + self.default_controller_group + .replace(preset.default_group().clone()); + self.set_groups_without_notification(compartment, preset.groups().iter().cloned()); + self.set_mappings_without_notification(compartment, preset.mappings().iter().cloned()); + self.set_parameter_settings_from_non_default(compartment, preset.parameters()); } else { // preset - self.set_mappings_without_notification(compartment, std::iter::empty()); + self.clear_compartment_data(compartment); }; self.notify_everything_has_changed(weak_session); Ok(()) @@ -1394,28 +1436,31 @@ impl Session { let compartment = MappingCompartment::MainMappings; self.active_main_preset_id = id.clone(); if let Some(id) = id.as_ref() { - let main_preset = self + let preset = self .main_preset_manager .find_by_id(id) .ok_or("main preset not found")?; self.default_main_group - .replace(main_preset.default_group().clone()); - self.set_groups_without_notification(compartment, main_preset.groups().iter().cloned()); - self.set_mappings_without_notification( - compartment, - main_preset.mappings().iter().cloned(), - ); + .replace(preset.default_group().clone()); + self.set_groups_without_notification(compartment, preset.groups().iter().cloned()); + self.set_mappings_without_notification(compartment, preset.mappings().iter().cloned()); + self.set_parameter_settings_from_non_default(compartment, preset.parameters()); } else { // preset - self.default_main_group - .replace(GroupModel::default_for_compartment(compartment)); - self.set_groups_without_notification(compartment, std::iter::empty()); - self.set_mappings_without_notification(compartment, std::iter::empty()); + self.clear_compartment_data(compartment); } self.notify_everything_has_changed(weak_session); Ok(()) } + fn clear_compartment_data(&mut self, compartment: MappingCompartment) { + self.default_group(compartment) + .replace(GroupModel::default_for_compartment(compartment)); + self.set_groups_without_notification(compartment, std::iter::empty()); + self.set_mappings_without_notification(compartment, std::iter::empty()); + self.set_parameter_settings_without_notification(compartment, empty_parameter_settings()); + } + fn containing_fx_enabled_or_disabled(&self) -> impl UnitEvent { let containing_fx = self.context.containing_fx().clone(); Global::control_surface_rx() @@ -1459,6 +1504,10 @@ impl Session { self.group_list_changed_subject.clone() } + pub fn parameter_settings_changed(&self) -> impl SharedItemEvent { + self.parameter_settings_changed_subject.clone() + } + /// Fires if a group itself has been changed. pub fn group_changed(&self) -> impl SharedItemEvent { self.default_main_group @@ -1641,6 +1690,10 @@ impl Session { AsyncNotifier::notify(&mut self.group_list_changed_subject, &compartment); } + fn notify_parameter_settings_changed(&mut self, compartment: MappingCompartment) { + AsyncNotifier::notify(&mut self.parameter_settings_changed_subject, &compartment); + } + /// Notifies listeners async a group in the group list has changed. fn notify_group_changed(&mut self, compartment: MappingCompartment) { AsyncNotifier::notify(&mut self.group_changed_subject, &compartment); @@ -1806,9 +1859,17 @@ impl Session { } } -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct ParameterSetting { - pub custom_name: Option, + #[serde(rename = "name", default, skip_serializing_if = "is_default")] + pub name: String, +} + +impl ParameterSetting { + pub fn is_default(&self) -> bool { + self.name.is_empty() + } } impl Drop for Session { @@ -1923,3 +1984,7 @@ pub enum InputDescriptor { device_id: OscDeviceId, }, } + +pub fn empty_parameter_settings() -> Vec { + vec![Default::default(); COMPARTMENT_PARAMETER_COUNT as usize] +} diff --git a/main/src/infrastructure/data/controller_preset.rs b/main/src/infrastructure/data/controller_preset.rs index 0a92ff640..797fb7097 100644 --- a/main/src/infrastructure/data/controller_preset.rs +++ b/main/src/infrastructure/data/controller_preset.rs @@ -1,11 +1,12 @@ use crate::application::{ - ControllerPreset, GroupModel, Preset, PresetManager, SharedGroup, SharedMapping, + ControllerPreset, GroupModel, ParameterSetting, Preset, PresetManager, SharedGroup, + SharedMapping, }; use crate::core::default_util::is_default; use crate::domain::MappingCompartment; use crate::infrastructure::data::{ ExtendedPresetManager, FileBasedPresetManager, GroupModelData, MappingModelData, - MigrationDescriptor, PresetData, + MigrationDescriptor, ParameterData, PresetData, }; use crate::infrastructure::plugin::App; @@ -31,6 +32,15 @@ impl PresetManager for SharedControllerPresetManager { self.borrow().mappings_are_dirty(id, mappings) } + fn parameter_settings_are_dirty( + &self, + id: &str, + parameter_settings: &HashMap, + ) -> bool { + self.borrow() + .parameter_settings_are_dirty(id, parameter_settings) + } + fn groups_are_dirty( &self, id: &str, @@ -71,6 +81,8 @@ pub struct ControllerPresetData { #[serde(default, skip_serializing_if = "is_default")] mappings: Vec, #[serde(default, skip_serializing_if = "is_default")] + parameters: HashMap, + #[serde(default, skip_serializing_if = "is_default")] custom_data: HashMap, } @@ -92,6 +104,7 @@ impl PresetData for ControllerPresetData { .iter() .map(|m| MappingModelData::from_model(&m)) .collect(), + parameters: preset.parameters().clone(), name: preset.name().to_string(), custom_data: preset.custom_data().clone(), } @@ -124,6 +137,7 @@ impl PresetData for ControllerPresetData { ) }) .collect(), + self.parameters.clone(), self.custom_data.clone(), ) } diff --git a/main/src/infrastructure/data/main_preset.rs b/main/src/infrastructure/data/main_preset.rs index 1909a892d..330c0980c 100644 --- a/main/src/infrastructure/data/main_preset.rs +++ b/main/src/infrastructure/data/main_preset.rs @@ -1,5 +1,5 @@ use crate::application::{ - GroupModel, MainPreset, Preset, PresetManager, SharedGroup, SharedMapping, + GroupModel, MainPreset, ParameterSetting, Preset, PresetManager, SharedGroup, SharedMapping, }; use crate::core::default_util::is_default; use crate::domain::MappingCompartment; @@ -12,6 +12,7 @@ use crate::infrastructure::plugin::App; use semver::Version; use serde::{Deserialize, Serialize}; use std::cell::RefCell; +use std::collections::HashMap; use std::rc::Rc; pub type FileBasedMainPresetManager = FileBasedPresetManager; @@ -29,6 +30,15 @@ impl PresetManager for SharedMainPresetManager { self.borrow().mappings_are_dirty(id, mappings) } + fn parameter_settings_are_dirty( + &self, + id: &str, + parameter_settings: &HashMap, + ) -> bool { + self.borrow() + .parameter_settings_are_dirty(id, parameter_settings) + } + fn groups_are_dirty( &self, id: &str, @@ -68,6 +78,8 @@ pub struct MainPresetData { groups: Vec, #[serde(default, skip_serializing_if = "is_default")] mappings: Vec, + #[serde(default, skip_serializing_if = "is_default")] + parameters: HashMap, } impl PresetData for MainPresetData { @@ -88,6 +100,7 @@ impl PresetData for MainPresetData { .iter() .map(|m| MappingModelData::from_model(&m)) .collect(), + parameters: preset.parameters().clone(), name: preset.name().to_string(), } } @@ -119,6 +132,7 @@ impl PresetData for MainPresetData { ) }) .collect(), + self.parameters.clone(), ) } diff --git a/main/src/infrastructure/data/parameter_data.rs b/main/src/infrastructure/data/parameter_data.rs index 1fae71486..a23e203f1 100644 --- a/main/src/infrastructure/data/parameter_data.rs +++ b/main/src/infrastructure/data/parameter_data.rs @@ -7,5 +7,5 @@ pub struct ParameterData { #[serde(default, skip_serializing_if = "is_default")] pub value: f32, #[serde(default, skip_serializing_if = "is_default")] - pub name: Option, + pub name: String, } diff --git a/main/src/infrastructure/data/preset.rs b/main/src/infrastructure/data/preset.rs index f99b1eb71..ab441a856 100644 --- a/main/src/infrastructure/data/preset.rs +++ b/main/src/infrastructure/data/preset.rs @@ -1,5 +1,5 @@ use crate::application::{ - GroupModel, MappingModel, Preset, PresetManager, SharedGroup, SharedMapping, + GroupModel, MappingModel, ParameterSetting, Preset, PresetManager, SharedGroup, SharedMapping, }; use crate::infrastructure::data::{GroupModelData, MappingModelData}; @@ -10,6 +10,7 @@ use rxrust::prelude::*; use serde::de::DeserializeOwned; use serde::export::PhantomData; use serde::Serialize; +use std::collections::HashMap; use std::fmt::Debug; use std::fs; use std::path::{Path, PathBuf}; @@ -186,6 +187,18 @@ impl> PresetManager for FileBasedPresetManager< }) } + fn parameter_settings_are_dirty( + &self, + id: &str, + parameter_settings: &HashMap, + ) -> bool { + let preset = match self.find_preset_ref_by_id(id) { + None => return false, + Some(c) => c, + }; + parameter_settings != preset.parameters() + } + fn groups_are_dirty( &self, id: &str, diff --git a/main/src/infrastructure/data/session_data.rs b/main/src/infrastructure/data/session_data.rs index a34ce7bff..2c6110741 100644 --- a/main/src/infrastructure/data/session_data.rs +++ b/main/src/infrastructure/data/session_data.rs @@ -1,4 +1,6 @@ -use crate::application::{GroupModel, MainPresetAutoLoadMode, ParameterSetting, Session}; +use crate::application::{ + empty_parameter_settings, GroupModel, MainPresetAutoLoadMode, ParameterSetting, Session, +}; use crate::core::default_util::{bool_true, is_bool_true, is_default}; use crate::domain::{ ExtendedProcessorContext, MappingCompartment, MidiControlInput, MidiFeedbackOutput, @@ -364,12 +366,12 @@ fn get_parameter_data_map( let parameter_slice = compartment.slice_params(parameters); let value = parameter_slice[i as usize]; let settings = session.get_parameter_settings(compartment, i); - if value == 0.0 && settings.custom_name.is_none() { + if value == 0.0 && settings.name.is_empty() { return None; } let data = ParameterData { value, - name: settings.custom_name.clone(), + name: settings.name.clone(), }; Some((i, data)) }) @@ -377,10 +379,10 @@ fn get_parameter_data_map( } fn get_parameter_settings(data_map: &HashMap) -> Vec { - let mut settings = vec![Default::default(); COMPARTMENT_PARAMETER_COUNT as usize]; + let mut settings = empty_parameter_settings(); for (i, p) in data_map.iter() { settings[*i as usize] = ParameterSetting { - custom_name: p.name.clone(), + name: p.name.clone(), }; } settings diff --git a/main/src/infrastructure/ui/header_panel.rs b/main/src/infrastructure/ui/header_panel.rs index e86a5bcc9..d5452240c 100644 --- a/main/src/infrastructure/ui/header_panel.rs +++ b/main/src/infrastructure/ui/header_panel.rs @@ -1482,6 +1482,7 @@ impl HeaderPanel { self.make_mappings_project_independent_if_desired(extended_context, &mut mappings); let session = session.borrow(); let default_group = session.default_group(compartment).borrow().clone(); + let parameter_settings = session.non_default_parameter_settings_by_compartment(compartment); let groups = session .groups(compartment) .map(|ptr| ptr.borrow().clone()) @@ -1492,7 +1493,12 @@ impl HeaderPanel { let mut controller_preset = preset_manager .find_by_id(&preset_id) .ok_or("controller preset not found")?; - controller_preset.update_realearn_data(default_group, groups, mappings); + controller_preset.update_realearn_data( + default_group, + groups, + mappings, + parameter_settings, + ); preset_manager .borrow_mut() .update_preset(controller_preset)?; @@ -1502,7 +1508,7 @@ impl HeaderPanel { let mut main_preset = preset_manager .find_by_id(&preset_id) .ok_or("main preset not found")?; - main_preset.update_data(default_group, groups, mappings); + main_preset.update_data(default_group, groups, mappings, parameter_settings); preset_manager.borrow_mut().update_preset(main_preset)?; } }; @@ -1550,7 +1556,7 @@ impl HeaderPanel { fn save_as_preset(&self) -> Result<(), &'static str> { let session = self.session(); - let (context, params, mut mappings, compartment) = { + let (context, params, mut mappings, compartment, param_settings) = { let session = session.borrow_mut(); let compartment = self.active_compartment(); let mappings: Vec<_> = session @@ -1562,6 +1568,7 @@ impl HeaderPanel { *session.parameters(), mappings, compartment, + session.non_default_parameter_settings_by_compartment(compartment), ) }; let extended_context = ExtendedProcessorContext::new(&context, ¶ms); @@ -1589,6 +1596,7 @@ impl HeaderPanel { default_group, groups, mappings, + param_settings, custom_data, ); App::get() @@ -1604,6 +1612,7 @@ impl HeaderPanel { default_group, groups, mappings, + param_settings, ); App::get() .main_preset_manager() @@ -1783,6 +1792,7 @@ impl HeaderPanel { .merge(session.mapping_changed().map_to(())) .merge(session.group_list_changed().map_to(())) .merge(session.group_changed().map_to(())) + .merge(session.parameter_settings_changed().map_to(())) .take_until(self.view.closed()), ) .with(Rc::downgrade(&self)) @@ -2087,11 +2097,9 @@ fn edit_compartment_parameter( .collect(); edit_compartment_parameter_internal(offset, &settings)? }; - for (i, s) in range.zip(modified_settings) { - session - .borrow_mut() - .set_parameter_setting_without_notification(compartment, i, s); - } + session + .borrow_mut() + .set_parameter_settings(compartment, range.zip(modified_settings)); Ok(()) } @@ -2111,10 +2119,7 @@ fn edit_compartment_parameter_internal( .map(|(i, s)| format!("Param {} name", i + 1)) .join(","); captions_csv.push_str(",separator=;,extrawidth=80"); - let initial_csv = settings - .iter() - .map(|s| s.custom_name.clone().unwrap_or_default()) - .join(";"); + let initial_csv = settings.iter().map(|s| s.name.clone()).join(";"); let csv = Reaper::get() .medium_reaper() .get_user_inputs( @@ -2128,14 +2133,8 @@ fn edit_compartment_parameter_internal( let out_settings: Vec<_> = csv .to_str() .split(';') - .map(|name| { - let custom_name = name.trim().to_owned(); - let custom_name = if custom_name.is_empty() { - None - } else { - Some(custom_name) - }; - ParameterSetting { custom_name } + .map(|name| ParameterSetting { + name: name.trim().to_owned(), }) .collect(); if out_settings.len() != settings.len() {