Skip to content

Commit

Permalink
#160 Fix most important remaining todos
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Mar 8, 2021
1 parent eb54a09 commit 1f1a98d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
21 changes: 15 additions & 6 deletions main/src/application/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ impl Session {
});
all_subscriptions.add(subscription);
}
// Keep auto-detecting mode settings
// Keep auto-correcting mode settings
if self.auto_correct_settings.get() {
let processor_context = self.context().clone();
let subscription = when(
Expand All @@ -570,11 +570,16 @@ impl Session {
)
.with(Rc::downgrade(&shared_mapping))
.do_sync(move |mapping, _| {
// TODO-high We need access to the parameters when adjusting the mode but
// we can't just copy them! Find a solution.
// mapping
// .borrow_mut()
// .adjust_mode_if_necessary(&processor_context);
// Parameter values are not important for mode auto correction because
// dynamic targets don't really profit from it anyway. Therefore just
// use zero parameters.
let extended_context = ExtendedProcessorContext::new(
&processor_context,
&ZEROED_PLUGIN_PARAMETERS,
);
mapping
.borrow_mut()
.adjust_mode_if_necessary(extended_context);
});
all_subscriptions.add(subscription);
}
Expand Down Expand Up @@ -1586,6 +1591,10 @@ impl Session {
}
}

pub fn parameters(&self) -> &ParameterArray {
&self.parameters
}

/// Just syncs whether control globally enabled or not.
fn sync_control_is_globally_enabled(&self) {
let enabled = self.control_is_globally_enabled();
Expand Down
16 changes: 11 additions & 5 deletions main/src/infrastructure/ui/header_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ impl HeaderPanel {

fn save_active_preset(&self) -> Result<(), &'static str> {
let session = self.session();
let (context, mut mappings, preset_id, compartment) = {
let (context, params, mut mappings, preset_id, compartment) = {
let session = session.borrow();
let compartment = self.active_compartment();
let preset_id = match compartment {
Expand All @@ -1106,12 +1106,13 @@ impl HeaderPanel {
.collect();
(
session.context().clone(),
*session.parameters(),
mappings,
preset_id.to_owned(),
compartment,
)
};
let extended_context = ExtendedProcessorContext::new(&context, todo!());
let extended_context = ExtendedProcessorContext::new(&context, &params);
self.make_mappings_project_independent_if_desired(extended_context, &mut mappings);
let session = session.borrow();
match compartment {
Expand Down Expand Up @@ -1178,16 +1179,21 @@ impl HeaderPanel {

fn save_as_preset(&self) -> Result<(), &'static str> {
let session = self.session();
let (context, mut mappings, compartment) = {
let (context, params, mut mappings, compartment) = {
let session = session.borrow_mut();
let compartment = self.active_compartment();
let mappings: Vec<_> = session
.mappings(compartment)
.map(|ptr| ptr.borrow().clone())
.collect();
(session.context().clone(), mappings, compartment)
(
session.context().clone(),
*session.parameters(),
mappings,
compartment,
)
};
let extended_context = ExtendedProcessorContext::new(&context, todo!());
let extended_context = ExtendedProcessorContext::new(&context, &params);
self.make_mappings_project_independent_if_desired(extended_context, &mut mappings);
let preset_name = match dialog_util::prompt_for("Preset name", "") {
None => return Ok(()),
Expand Down

0 comments on commit 1f1a98d

Please sign in to comment.