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.

227 lines
8.5KB

  1. /*
  2. Copyright (C) 2009 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 __PLUGINEDITOR_H_F4EBBBA1__
  17. #define __PLUGINEDITOR_H_F4EBBBA1__
  18. #include "../CabbageCustomWidgets.h"
  19. #include "../JuceHeader.h"
  20. #include "CabbagePluginProcessor.h"
  21. //#include "../CabbageLookAndFeel.h"
  22. #include "../CabbagePropertiesDialog.h"
  23. #include "../CabbageUtils.h"
  24. extern CabbageLookAndFeel* lookAndFeel;
  25. extern CabbageLookAndFeelBasic* lookAndFeelBasic;
  26. class CabbageMainPanel;
  27. class ComponentLayoutEditor;
  28. class CabbageCornerResizer;
  29. //==============================================================================
  30. class CabbagePlantWindow : public DocumentWindow
  31. {
  32. public:
  33. CabbagePlantWindow(const String& title, const Colour& backgroundColour)
  34. : DocumentWindow (title, backgroundColour, DocumentWindow::closeButton){};
  35. ~CabbagePlantWindow(){
  36. };
  37. void closeButtonPressed(){
  38. setVisible(false);
  39. setAlwaysOnTop(false);
  40. };
  41. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CabbagePlantWindow);
  42. };
  43. //==============================================================================
  44. // pointData class for holding info about each segment of a line
  45. class PointData
  46. {
  47. public:
  48. Point <int> point;
  49. int curveType;
  50. PointData(Point<int> point, int curveType):point(point),curveType(curveType)
  51. {}
  52. ~PointData(){}
  53. };
  54. //==============================================================================
  55. // main GUI editor window
  56. //==============================================================================
  57. class CabbagePluginAudioProcessorEditor : public AudioProcessorEditor,
  58. public CabbageUtils,
  59. public SliderListener,
  60. public ComboBoxListener,
  61. public ButtonListener,
  62. public KeyListener,
  63. public ChangeBroadcaster,
  64. public ChangeListener,
  65. public ActionListener,
  66. public Timer
  67. {
  68. public:
  69. CabbagePluginAudioProcessorEditor (CabbagePluginAudioProcessor* ownerFilter);
  70. ~CabbagePluginAudioProcessorEditor();
  71. void paint (Graphics& g);
  72. void resized();
  73. void setEditMode(bool on);
  74. void InsertGUIControls(CabbageGUIClass cAttr);
  75. void ksmpsYieldCallback();
  76. void updateSize();
  77. ScopedPointer<CabbagePropertiesDialog> propsWindow;
  78. //main GUI controls vectors..
  79. OwnedArray<Component> comps;
  80. OwnedArray<Component> layoutComps;
  81. void updateLayoutEditorFrames();
  82. ScopedPointer<CabbageTable> cabTable;
  83. ScopedPointer<CabbageCornerResizer> resizer;
  84. private:
  85. void createfTableData(Table* table);
  86. bool keyPressed(const juce::KeyPress &,Component *);
  87. void updateSizesAndPositionsOfComponents(int newLine = 0);
  88. void deleteComponents();
  89. void duplicateComponents();
  90. void populateLineNumberArray(StringArray csdArray);
  91. void addToRepository(String entryName);
  92. void convertIntoPlant();
  93. void breakUpPlant();
  94. void InsertGroupBox(CabbageGUIClass &cAttr);
  95. void comboBoxChanged (ComboBox* combo);
  96. void InsertComboBox(CabbageGUIClass &cAttr);
  97. void InsertSoundfiler(CabbageGUIClass &cAttr);
  98. void InsertDirectoryList(CabbageGUIClass &cAttr);
  99. void SetupWindow(CabbageGUIClass &cAttr);
  100. void InsertSlider(CabbageGUIClass &cAttr);
  101. void sliderValueChanged (Slider*);
  102. void InsertButton(CabbageGUIClass &cAttr);
  103. void InsertSourceButton(CabbageGUIClass &cAttr);
  104. void InsertVUMeter(CabbageGUIClass &cAttr);
  105. void InsertCheckBox(CabbageGUIClass &cAttr);
  106. void InsertCsoundOutput(CabbageGUIClass &cAttr);
  107. void InsertMIDIKeyboard(CabbageGUIClass &cAttr);
  108. void InsertXYPad(CabbageGUIClass &cAttr);
  109. void InsertFileButton(CabbageGUIClass &cAttr);
  110. void InsertImage(CabbageGUIClass &cAttr);
  111. void InsertLabel(CabbageGUIClass &cAttr);
  112. void InsertTable(CabbageGUIClass &cAttr);
  113. void InsertMultiTab(CabbageGUIClass &cAttr);
  114. void InsertInfoButton(CabbageGUIClass &cAttr);
  115. void InsertLineSeparator(CabbageGUIClass &cAttr);
  116. void InsertPatternMatrix(CabbageGUIClass &cAttr);
  117. void InsertSnapshot(CabbageGUIClass &cAttr);
  118. void InsertPVSViewer(CabbageGUIClass &cAttr);
  119. void InsertTransport(CabbageGUIClass &cAttr);
  120. void buttonClicked(Button*);
  121. void buttonStateChanged(Button*);
  122. void showInsertControlsMenu(int x, int y);
  123. void actionListenerCallbackForWidgets(const String message);
  124. void insertScoreStatementText(Table *table, bool overwrite);
  125. void restoreParametersFromPresets(XmlElement* xmlData);
  126. void savePresetsFromParameters(File selectedFile, String mode);
  127. void refreshDiskReadingGUIControls(String typeOfControl);
  128. void updateGUIControls();
  129. void timerCallback();
  130. bool LOCKED;
  131. void insertComponentsFromCabbageText(StringArray text, bool useOffset);
  132. // void insertComponentsFromCabbageTextArray(StringArray text, bool plant);
  133. Array<int> lineNumbers;
  134. Array<int> plantLineNumbers;
  135. int currentLineNumber;
  136. File SnapShotFile;
  137. String presetFileText;
  138. String tempPlantText;
  139. void actionListenerCallback (const String& message);
  140. int zero_dbfs;
  141. StringArray tempArray;
  142. StringArray pastEvents;
  143. Array<Rectangle <int> > boundsForDuplicatedCtrls;
  144. //CabbagePluginAudioProcessor* filter;
  145. CabbagePluginAudioProcessor* getFilter() const
  146. {
  147. return static_cast <CabbagePluginAudioProcessor*> (getAudioProcessor());
  148. }
  149. bool keyStateChanged(bool onoff){
  150. keyIsPressed = onoff;
  151. return false;
  152. }
  153. bool keyIsPressed;
  154. bool isMouseDown;
  155. void positionComponentWithinPlant(String type, int idx, float left, float top, float width, float height, Component *layout, Component *control);
  156. //ScopedPointer<CabbagePlantWindow> subPatch;
  157. OwnedArray<CabbageButton> plantButton;
  158. OwnedArray<CabbagePlantWindow> subPatch;
  159. ScopedPointer<InfoWindow> infoWindow;
  160. #ifdef Cabbage_GUI_Editor
  161. ScopedPointer<CabbageMainPanel> componentPanel;
  162. ScopedPointer<ComponentLayoutEditor> layoutEditor;
  163. #else
  164. ScopedPointer<Component> componentPanel;
  165. #endif
  166. ScopedPointer<MidiKeyboardComponent> midiKeyboard;
  167. ScopedPointer<LookAndFeel> feely;
  168. Array<float> incomingValues;
  169. ComponentBoundsConstrainer resizeLimits;
  170. AudioPlayHead::CurrentPositionInfo hostInfo;
  171. void changeListenerCallback (ChangeBroadcaster *source);
  172. Colour formColour, fontColour;
  173. String authorText;
  174. String formPic;
  175. float inValue;
  176. int xyPadIndex;
  177. ScopedPointer<CabbageLookAndFeel> lookAndFeel;
  178. ScopedPointer<CabbageLookAndFeelBasic> basicLookAndFeel;
  179. ScopedPointer<Label> debugLabel;
  180. StringArray scoreEvents;
  181. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CabbagePluginAudioProcessorEditor);
  182. };
  183. //==============================================================================
  184. class CabbageCornerResizer : public ResizableCornerComponent
  185. {
  186. CabbagePluginAudioProcessorEditor* editor;
  187. public:
  188. CabbageCornerResizer(CabbagePluginAudioProcessorEditor* parent, Component* comp, ComponentBoundsConstrainer *constrainer):
  189. ResizableCornerComponent(comp, constrainer), editor(parent){};
  190. ~CabbageCornerResizer(){};
  191. void mouseUp(const MouseEvent &e){
  192. editor->updateSize();
  193. }
  194. };
  195. #endif // __PLUGINEDITOR_H_F4EBBBA1__