Skip to content

Commit

Permalink
#231 Save/load compartment parameter settings together with compartment
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Mar 23, 2021
1 parent f9b598b commit 65b8938
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 68 deletions.
11 changes: 10 additions & 1 deletion main/src/application/controller_preset.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::application::{GroupModel, MappingModel, Preset};
use crate::application::{GroupModel, MappingModel, ParameterSetting, Preset};
use std::collections::HashMap;
use std::fmt;

Expand All @@ -9,6 +9,7 @@ pub struct ControllerPreset {
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
parameters: HashMap<u32, ParameterSetting>,
custom_data: HashMap<String, serde_json::Value>,
}

Expand All @@ -19,6 +20,7 @@ impl ControllerPreset {
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
parameters: HashMap<u32, ParameterSetting>,
custom_data: HashMap<String, serde_json::Value>,
) -> ControllerPreset {
ControllerPreset {
Expand All @@ -27,6 +29,7 @@ impl ControllerPreset {
default_group,
groups,
mappings,
parameters,
custom_data,
}
}
Expand All @@ -47,10 +50,12 @@ impl ControllerPreset {
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
parameters: HashMap<u32, ParameterSetting>,
) {
self.default_group = default_group;
self.groups = groups;
self.mappings = mappings;
self.parameters = parameters;
}
}

Expand All @@ -70,6 +75,10 @@ impl Preset for ControllerPreset {
fn mappings(&self) -> &Vec<MappingModel> {
&self.mappings
}

fn parameters(&self) -> &HashMap<u32, ParameterSetting> {
&self.parameters
}
}

impl fmt::Display for ControllerPreset {
Expand Down
12 changes: 11 additions & 1 deletion main/src/application/main_preset.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -8,6 +9,7 @@ pub struct MainPreset {
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
parameters: HashMap<u32, ParameterSetting>,
}

impl MainPreset {
Expand All @@ -17,13 +19,15 @@ impl MainPreset {
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
parameters: HashMap<u32, ParameterSetting>,
) -> MainPreset {
MainPreset {
id,
name,
default_group,
groups,
mappings,
parameters,
}
}

Expand All @@ -36,10 +40,12 @@ impl MainPreset {
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
parameters: HashMap<u32, ParameterSetting>,
) {
self.default_group = default_group;
self.groups = groups;
self.mappings = mappings;
self.parameters = parameters;
}
}

Expand All @@ -59,6 +65,10 @@ impl Preset for MainPreset {
fn mappings(&self) -> &Vec<MappingModel> {
&self.mappings
}

fn parameters(&self) -> &HashMap<u32, ParameterSetting> {
&self.parameters
}
}

impl fmt::Display for MainPreset {
Expand Down
12 changes: 11 additions & 1 deletion main/src/application/preset.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -8,6 +11,7 @@ pub trait Preset: Clone + Debug {
fn default_group(&self) -> &GroupModel;
fn groups(&self) -> &Vec<GroupModel>;
fn mappings(&self) -> &Vec<MappingModel>;
fn parameters(&self) -> &HashMap<u32, ParameterSetting>;
}

pub trait PresetManager: fmt::Debug {
Expand All @@ -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<u32, ParameterSetting>,
) -> bool;

fn groups_are_dirty(
&self,
id: &str,
Expand Down
Loading

0 comments on commit 65b8938

Please sign in to comment.