Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: cfbab4ce3a
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 160 lines (145 sloc) 4.746 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
/* (c) Stefan Nussbaumer */
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

/* automatic GUI-creation from SynthDefs, Ndefs ... */
/* read input */

+Synth {

cvcGui { |displayDialog=true, prefix, pairs2D, environment|
var sDef, def, cDict = (), metadata;
var thisType, thisControls, thisSpec, thisSlots, thisName, done=[];
sDef = SynthDescLib.global[this.defName.asSymbol];
sDef.metadata !? { sDef.metadata.specs !? { metadata = sDef.metadata.specs }};
sDef.controlDict.pairsDo({ |n, c| cDict.put(n, c.defaultValue) });
if(displayDialog, {
CVWidgetSpecsEditor(displayDialog, this, this.defName.asSymbol, cDict, prefix, pairs2D, metadata, environment);
}, {
cDict.pairsDo({ |cName, vals|
block { |break|
pairs2D.pairsDo({ |wdgtName, cNames|
if(cNames.includes(cName), {
break.value(
thisName = wdgtName;
thisType = \w2dc;
thisControls = cNames;
if(metadata.notNil, {
metadata[cNames[0]] !? { thisSpec = metadata[cNames[0]].asSpec };
}, {
thisSpec = cName.asSpec;
});
done = done.add(cNames).flat;
)
})
})
};
if(cDict[cName].size == 0 and:{ done.includes(cName).not }, { thisType = nil; thisName = cName });
if(cDict[cName].size == 2, { thisType = \w2d; thisName = cName });
if(cDict[cName].size > 2, { thisType = \wms; thisName = cName });

switch(thisType,
\w2dc, {
thisSlots = [cDict[thisControls[0]], cDict[thisControls[1]]];
},
\w2d, {
thisSlots = cDict[cName];
if(metadata.notNil, {
metadata[cName] !? { thisSpec = metadata[cName].asSpec };
}, {
thisSpec = cName.asSpec;
})
},
\wms, {
thisSlots = cDict[cName];
if(metadata.notNil, {
metadata[cName] !? { thisSpec = metadata[cName].asSpec };
}, {
thisSpec = cName.asSpec;
})
},
thisSlots = [cDict[cName]];
if(metadata.notNil, {
metadata[cName] !? { thisSpec = metadata[cName].asSpec };
}, {
thisSpec = cName.asSpec;
})
);

prefix !? { thisName = prefix.asString++(thisName.asString[0]).toUpper ++ thisName.asString[1..] };

CVCenter.finishGui(this, cName, nil, (
cName: thisName,
type: thisType,
enterTab: this.defName.asSymbol,
controls: thisControls,
slots: thisSlots,
specSelect: thisSpec
))
})
})
}

}

+NodeProxy {

cvcGui { |displayDialog=true, prefix, pairs2D|
var cDict = (), name;
var thisType, thisControls, thisSpec, thisSlots, thisName, done=[];
this.getKeysValues.do({ |pair| cDict.put(pair[0], pair[1]) });
if(this.class === Ndef, {
name = this.key;
}, {
name = nil;
});
if(displayDialog, {
CVWidgetSpecsEditor(displayDialog, this, name, cDict, prefix, pairs2D);
}, {
cDict.pairsDo({ |cName, vals|
block { |break|
pairs2D.pairsDo({ |wdgtName, cNames|
if(cNames.includes(cName), {
break.value(
thisName = wdgtName;
thisType = \w2dc;
thisControls = cNames;
thisSpec = cName.asSpec;
done = done.add(cNames).flat;
)
})
})
};
if(cDict[cName].size == 0 and:{ done.includes(cName).not }, { thisType = nil; thisName = cName });
if(cDict[cName].size == 2, { thisType = \w2d; thisName = cName });
if(cDict[cName].size > 2, { thisType = \wms; thisName = cName });

switch(thisType,
\w2dc, {
thisSlots = [cDict[thisControls[0]], cDict[thisControls[1]]];
},
\w2d, {
thisSlots = cDict[cName];
thisSpec = cName.asSpec;
},
\wms, {
thisSlots = cDict[cName];
thisSpec = cName.asSpec;
},
thisSlots = [cDict[cName]];
thisSpec = cName.asSpec;
);

prefix !? { thisName = prefix.asString++(thisName.asString[0]).toUpper ++ thisName.asString[1..] };

CVCenter.finishGui(this, cName, nil, (
cName: thisName,
type: thisType,
enterTab: name,
controls: thisControls,
slots: thisSlots,
specSelect: thisSpec
))
})
})
}

}
Something went wrong with that request. Please try again.