Extra "ports" of juce-based plugins using the distrho build system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
9.6KB

  1. /*
  2. Copyright (C) 2007 Rory Walsh
  3. Cabbage is free software; you can redistribute it
  4. and/or modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. Cabbage is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. // You should have received a copy of the GNU Lesser General Public
  12. License along with Csound; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA
  15. */
  16. #ifndef CABBPARSE_H
  17. #define CABBPARSE_H
  18. #include <stdio.h>
  19. #include <string>
  20. #include <iostream>
  21. #include <vector>
  22. #include <string>
  23. #include <cctype>
  24. #include <algorithm>
  25. #include <fstream>
  26. #include <sstream>
  27. #include "CabbageUtils.h"
  28. namespace CabbageIDs
  29. {
  30. static const Identifier top = "top";
  31. static const Identifier left = "left";
  32. static const Identifier width = "width";
  33. static const Identifier height = "height";
  34. static const Identifier min = "min";
  35. static const Identifier max = "max";
  36. static const Identifier value = "value";
  37. static const Identifier channel = "channel";
  38. static const Identifier colour = "colour";
  39. static const Identifier tablecolour = "tablecolour";
  40. static const Identifier fontcolour= "fontcolour";
  41. static const Identifier items = "items";
  42. static const Identifier text = "text";
  43. static const Identifier range = "range";
  44. static const Identifier sliderrange = "sliderrange";
  45. static const Identifier amprange = "amprange";
  46. static const Identifier caption = "caption";
  47. static const Identifier basetype = "basetype";
  48. static const Identifier textbox = "textbox";
  49. static const Identifier name = "name";
  50. static const Identifier type = "type";
  51. static const Identifier trackercolour = "trackercolour";
  52. static const Identifier sliderskew = "sliderskew";
  53. static const Identifier sliderincr = "sliderince";
  54. static const Identifier midichan = "midichan";
  55. static const Identifier midictrl = "midictrl";
  56. static const Identifier kind = "kind";
  57. static const Identifier decimalplaces = "decimalplaces";
  58. static const Identifier mode = "mode";
  59. static const Identifier shape = "shape";
  60. static const Identifier channeltype = "channeltype";
  61. static const Identifier comborange = "comborange";
  62. static const Identifier populate = "populate";
  63. static const Identifier outline = "outline";
  64. static const Identifier popup = "popup";
  65. static const Identifier plant = "plant";
  66. static const Identifier line = "line";
  67. static const Identifier tablenumber = "tablenumber";
  68. static const Identifier resizemode = "resizemode";
  69. static const Identifier drawmode = "drawmode";
  70. static const Identifier readonly = "readonly";
  71. static const Identifier xyautoindex = "xyautoindex";
  72. static const Identifier file = "file";
  73. static const Identifier latched = "latched";
  74. static const Identifier xchannel = "xchannel";
  75. static const Identifier ychannel = "ychannel";
  76. static const Identifier minx = "minx";
  77. static const Identifier miny = "miny";
  78. static const Identifier maxx = "maxx";
  79. static const Identifier maxy = "maxy";
  80. static const Identifier valuex = "valuex";
  81. static const Identifier fill = "fill";
  82. static const Identifier valuey = "valuey";
  83. static const Identifier textcolour = "textcolour";
  84. static const Identifier pluginid = "pluginid";
  85. static const Identifier tabs = "tabs";
  86. static const Identifier tabbed = "tabbed";
  87. static const Identifier rangey = "rangey";
  88. static const Identifier rangex = "rangex";
  89. static const Identifier tabpage = "tabpage";
  90. static const Identifier filetype = "filetype";
  91. static const Identifier workingdir = "workingdir";
  92. static const Identifier author = "author";
  93. static const Identifier xychannel = "xychannel";
  94. static const Identifier guirefresh = "guirefresh";
  95. //type of widgets/controls/messages
  96. static const String combobox = "combobox";
  97. static const String rslider = "rslider";
  98. static const String hslider = "hslider";
  99. static const String vslider = "vslider";
  100. static const String checkbox = "checkbox";
  101. static const String button = "button";
  102. static const String filebutton = "filebutton";
  103. static const String table = "table";
  104. static const String groupbox = "groupbox";
  105. static const String image = "image";
  106. static const String form = "form";
  107. static const String xypad = "xypad";
  108. static const String stringchannel = "string";
  109. static const String hostbpm = "HOST_BPM";
  110. static const String timeinseconds = "TIME_IN_SECONDS";
  111. static const String isplaying = "IS_PLAYING";
  112. static const String isrecording = "IS_RECORDING";
  113. static const String hostppqpos = "HOST_PPQ_POS";
  114. static const String csoundoutput = "csoundoutput";
  115. };
  116. class CabbageGUIClass : public CabbageUtils
  117. {
  118. double width, height, top, left, isRect, min, max, minX, minY, maxX, tabbed, maxY, comboRange, fftSize, overlapSize, frameSize,
  119. noOfMenus, onoff, midiChan, midiCtrl, sliderRange, xypadRangeY, xypadRangeX, noSteps, noPatterns, pvsChannel, alpha,
  120. line, anchor, linkTo, scaleX, scaleY, value, valueX, valueY, maxItems, sliderIncr, sliderSkew, decimalPlaces, rCtrls, lineIsVertical;
  121. StringArray items, onoffcaptions, key, channels, snapshotData, colours;
  122. String channel, name, sizeText, posText, boundsText, text, type, plant, reltoplant, bounds, range, fileType, workingDir,
  123. shape, beveltype, caption, kind, topitem, yChannel, xChannel, author, native, basetype,
  124. exit, csstdout, cssetup, file, debugMessage, xyChannel, pluginID, tabpage, preset;
  125. Colour outline, fill, fontcolour, textcolour, colour, trackerFill;
  126. int tableNum, textBox, numPresets, masterSnap, plantButton, xyAutoIndex, paramIndex, numTables, soundfilerIndex;
  127. Array<int> vuConfig;
  128. Array<int> tableNumbers;
  129. Array<float> tableChannelValues;
  130. //JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CabbageGUIClass);
  131. public:
  132. //constructor
  133. NamedValueSet cabbageIdentifiers;
  134. CabbageGUIClass(String str, int ID);
  135. CabbageGUIClass(){};
  136. ~CabbageGUIClass();
  137. int parse(String str);
  138. float getNumProp(Identifier prop);
  139. float getNumProp(Identifier prop, int index);
  140. void setNumProp(Identifier prop, float val);
  141. void setTableChannelValues(int index, float val);
  142. float getTableChannelValues(int index);
  143. void addTableChannelValues();
  144. void setStringProp(Identifier prop, String val);
  145. void setStringProp(Identifier prop, int index, String value);
  146. String getStringProp(Identifier prop);
  147. String getStringProp(Identifier prop, int index);
  148. String getPropsString();
  149. String getColourProp(Identifier prop);
  150. float getNumPropVal(Identifier prop);
  151. void setNumPropVal(Identifier prop, float val);
  152. static String getCabbageCodeFromIdentifiers(NamedValueSet props);
  153. static String getStringForIdentifier(var props, String identifier, String type);
  154. Rectangle<int> getBounds(){
  155. Rectangle<int> bounds(left, top, width, height);
  156. return bounds;
  157. }
  158. void setBounds(Rectangle<int> bounds){
  159. left = bounds.getX();
  160. top = bounds.getY();
  161. width = bounds.getWidth();
  162. height = bounds.getHeight();
  163. }
  164. static StringArray getIdentifiers(){
  165. StringArray test;
  166. return test;
  167. }
  168. Rectangle<int> getComponentBounds();
  169. StringArray getStringArrayProp(Identifier prop);
  170. String getStringArrayPropValue(Identifier prop, int index);
  171. int getIntArrayPropValue(Identifier prop, int index);
  172. Array<int> getIntArrayProp(Identifier prop);
  173. float getFloatArrayPropValue(Identifier prop, int index);
  174. Array<float> getFloatArrayProp(Identifier prop);
  175. StringArray getChannels(){
  176. return channels;
  177. }
  178. inline int getNumPresets(){
  179. return snapshotData.size();
  180. }
  181. inline void clearPresets(){
  182. snapshotData.clear();
  183. }
  184. inline String setOnOffcaptions(int index, String str){
  185. if(index<=onoffcaptions.size())
  186. onoffcaptions.getReference(index)=str;
  187. }
  188. inline String getOnOffcaptions(int index){
  189. if(index<=onoffcaptions.size())
  190. return onoffcaptions.getReference(index);
  191. else return "";
  192. }
  193. inline String setItems(int index, String str){
  194. if(index<=items.size())
  195. items.getReference(index)=str;
  196. else
  197. return "";
  198. }
  199. inline String getItems(int index){
  200. if(isPositiveAndBelow (index, items.size()))
  201. return items.getReference(index);
  202. else return "";
  203. }
  204. inline String getColours(int index){
  205. if(colours.size())
  206. return colours.getReference(index);
  207. else return "";
  208. }
  209. inline int getNumberOfColours(){
  210. return colours.size();
  211. }
  212. inline StringArray getItemArray(){
  213. if(items.size())
  214. return items;
  215. else return StringArray();
  216. }
  217. inline int getItemsSize(){
  218. return items.size();
  219. }
  220. inline Array<int> getVUConfig(){
  221. return vuConfig;
  222. }
  223. // inline String getChannel(int index){
  224. // return channels[index];
  225. // }
  226. inline void addDummyChannel(String dummyChan){
  227. return channels.add(dummyChan);
  228. }
  229. // inline String getTableChannel(int index){
  230. // return channels[index];
  231. // }
  232. // inline int getNumberOfTableChannels(){
  233. // return channels.size();
  234. // }
  235. inline int getKeySize(){
  236. return key.size();
  237. }
  238. inline String getkey(int index){
  239. return key.getReference(index);
  240. }
  241. // inline int getNumberOfTables(){
  242. // return numTables;
  243. // }
  244. // int getTableNumbers(int index)
  245. // {
  246. // if(index<tableNumbers.size())
  247. // return tableNumbers[index];
  248. // }
  249. // inline Array<int> getTableNumbersArray()
  250. // {
  251. // return tableNumbers;
  252. // }
  253. };
  254. #endif