MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / restoreState

Method restoreState

Source/Core/CtrlrModulator/CtrlrModulator.cpp:75–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void CtrlrModulator::restoreState (const ValueTree &savedState)
76{
77 setRestoreState (true);
78 modulatorTree.removeAllChildren (0);
79
80 for (int i=0; i<savedState.getNumChildren(); i++)
81 {
82 if (savedState.getChild(i).hasType(Ids::component))
83 {
84 setComponentType (savedState.getChild(i));
85 }
86
87 if (savedState.getChild(i).hasType(Ids::midi))
88 {
89 if (getMidiMessagePtr())
90 {
91 setMidiType (savedState.getChild(i));
92 modulatorTree.addChild (processor.getMidiMessage().getMidiTree(), -1, 0);
93 }
94 }
95 }
96
97 for (int i=0; i<savedState.getNumProperties(); i++)
98 {
99 if (savedState.getPropertyName(i) == Ids::name)
100 {
101 modulatorTree.setProperty (Ids::name, owner.getUniqueModulatorName(savedState.getProperty(Ids::name)), 0);
102 }
103 else if (isDelayedProperty(savedState.getPropertyName(i)))
104 {
105 setDelayedProperty(savedState.getPropertyName(i), savedState.getProperty(savedState.getPropertyName(i)));
106 continue;
107 }
108 else if (savedState.getPropertyName(i) == Ids::modulatorValue
109 && owner.getCtrlrManagerOwner().getInstanceMode() == InstanceMulti)
110 {
111 /*
112 set the modulator value
113 First see if it has a component attached to check out radio groups
114 if (savedState.getChildWithName(Ids::component).isValid())
115 {
116 ValueTree c = savedState.getChildWithName(Ids::component);
117
118 If the component belongs to a radio group, only set the value
119 to the group member that has the TRUE value all others will be FALSE
120 if (((int)c.getProperty(Ids::componentRadioGroupId) > 0))
121 {
122 if ((int)savedState.getProperty(Ids::modulatorValue) == 1)
123 {
124 processor.setValueFromGUI (savedState.getProperty(Ids::modulatorValue), true);
125
126 This is something that should not be here, this should be called from the HOST
127 as setParameter() call but it doesn't get called with the value set to 1.
128
129 Fuck if I know why, for now it stays here, i don't know if it's a good idea
130 i don't even know if it's an OK idea. But it seems to do the trick
131
132

Callers 1

setMidiTypeMethod · 0.45

Calls 11

getNumChildrenMethod · 0.80
getPropertyNameMethod · 0.80
getInstanceModeMethod · 0.80
getNameFunction · 0.50
getChildMethod · 0.45
addChildMethod · 0.45
setPropertyMethod · 0.45
getPropertyMethod · 0.45

Tested by

no test coverage detected