The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

384 lines
14KB

  1. /*
  2. ==============================================================================
  3. This is an automatically generated file created by the Jucer!
  4. Be careful when adding custom code to these files, as only the code within
  5. the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  6. and re-saved.
  7. Created for JUCE version: JUCE v1.53.8
  8. ------------------------------------------------------------------------------
  9. JUCE and the Jucer are copyright 2004-10 by Raw Material Software ltd.
  10. ==============================================================================
  11. */
  12. //[CppHeaders] You can add your own extra header files here...
  13. #include "jucer_ProjectExporter.h"
  14. //[/CppHeaders]
  15. #include "jucer_ProjectInformationComponent.h"
  16. //[MiscUserDefs] You can add your own user definitions and misc code here...
  17. class PropertiesWithHelpComponent : public PropertyPanelWithTooltips
  18. {
  19. public:
  20. PropertiesWithHelpComponent (Project& project_, int tabIndex_)
  21. : project (project_), tabIndex (tabIndex_)
  22. {
  23. }
  24. void rebuildProperties()
  25. {
  26. getPanel().clear();
  27. Array <PropertyComponent*> props;
  28. if (tabIndex == 0)
  29. {
  30. // The main project tab...
  31. project.createPropertyEditors (props);
  32. }
  33. else if (tabIndex == 1)
  34. {
  35. // The Juce options tab...
  36. OwnedArray <Project::ConfigFlag> flags;
  37. project.getAllConfigFlags (flags);
  38. StringArray possibleValues;
  39. possibleValues.add ("(Use default from juce_Config.h)");
  40. possibleValues.add ("Enabled");
  41. possibleValues.add ("Disabled");
  42. Array<var> mappings;
  43. mappings.add (Project::configFlagDefault);
  44. mappings.add (Project::configFlagEnabled);
  45. mappings.add (Project::configFlagDisabled);
  46. for (int i = 0; i < flags.size(); ++i)
  47. {
  48. ChoicePropertyComponent* c = new ChoicePropertyComponent (flags[i]->value, flags[i]->symbol, possibleValues, mappings);
  49. c->setTooltip (flags[i]->description);
  50. c->setPreferredHeight (22);
  51. props.add (c);
  52. }
  53. }
  54. else if (tabIndex < 2 + project.getNumConfigurations())
  55. {
  56. // A config tab..
  57. project.getConfiguration (tabIndex - 2).createPropertyEditors (props);
  58. }
  59. else
  60. {
  61. // An export tab..
  62. ScopedPointer <ProjectExporter> exp (project.createExporter (tabIndex - (2 + project.getNumConfigurations())));
  63. if (exp != nullptr)
  64. exp->createPropertyEditors (props);
  65. for (int i = props.size(); --i >= 0;)
  66. props.getUnchecked(i)->setPreferredHeight (22);
  67. }
  68. getPanel().addProperties (props);
  69. }
  70. void visibilityChanged()
  71. {
  72. if (isVisible())
  73. rebuildProperties();
  74. }
  75. private:
  76. Project& project;
  77. int tabIndex;
  78. };
  79. //[/MiscUserDefs]
  80. //==============================================================================
  81. ProjectInformationComponent::ProjectInformationComponent (Project& project_)
  82. : project (project_),
  83. configTabBox (TabbedButtonBar::TabsAtTop)
  84. {
  85. addAndMakeVisible (&configTabBox);
  86. configTabBox.setBounds ("8, 0, this.left + parent.width - 16, this.top + parent.height - 36");
  87. addAndMakeVisible (&editConfigsButton);
  88. editConfigsButton.setBounds ("8, parent.height - 30, this.left + 192, this.top + 22");
  89. editConfigsButton.setButtonText ("Add/Remove Configurations...");
  90. editConfigsButton.addListener (this);
  91. addAndMakeVisible (&openProjectButton);
  92. openProjectButton.setBounds ("608, parent.height - 30, this.left + 208, this.top + 22");
  93. openProjectButton.setButtonText ("Open Project in ");
  94. openProjectButton.addListener (this);
  95. addAndMakeVisible (&editExportersButton);
  96. editExportersButton.setBounds ("208, parent.height - 30, this.left + 160, this.top + 22");
  97. editExportersButton.setButtonText ("Add/Remove Exporters...");
  98. editExportersButton.addListener (this);
  99. addAndMakeVisible (&saveAndOpenButton);
  100. saveAndOpenButton.setBounds ("391, parent.height - 30, this.left + 208, this.top + 22");
  101. saveAndOpenButton.setButtonText ("Save And Open in");
  102. saveAndOpenButton.addListener (this);
  103. //[UserPreSize]
  104. rebuildConfigTabs();
  105. #if JUCE_MAC || JUCE_WINDOWS
  106. openProjectButton.setCommandToTrigger (commandManager, CommandIDs::openInIDE, true);
  107. openProjectButton.setButtonText (commandManager->getNameOfCommand (CommandIDs::openInIDE));
  108. saveAndOpenButton.setCommandToTrigger (commandManager, CommandIDs::saveAndOpenInIDE, true);
  109. saveAndOpenButton.setButtonText (commandManager->getNameOfCommand (CommandIDs::saveAndOpenInIDE));
  110. #else
  111. openProjectButton.setVisible (false);
  112. saveAndOpenButton.setVisible (false);
  113. #endif
  114. //[/UserPreSize]
  115. setSize (836, 427);
  116. //[Constructor] You can add your own custom stuff here..
  117. configTabBox.setOutline (1);
  118. configTabBox.setColour (TabbedComponent::outlineColourId, Colours::black.withAlpha (0.3f));
  119. editConfigsButton.setTriggeredOnMouseDown (true);
  120. project.addChangeListener (this);
  121. //[/Constructor]
  122. }
  123. ProjectInformationComponent::~ProjectInformationComponent()
  124. {
  125. //[Destructor_pre]. You can add your own custom destruction code here..
  126. project.removeChangeListener (this);
  127. //[/Destructor_pre]
  128. //[Destructor]. You can add your own custom destruction code here..
  129. //[/Destructor]
  130. }
  131. //==============================================================================
  132. void ProjectInformationComponent::resized()
  133. {
  134. //[Userresized_Pre]
  135. //[/Userresized_Pre]
  136. //[Userresized_Post]
  137. //[/Userresized_Post]
  138. }
  139. void ProjectInformationComponent::buttonClicked (Button* buttonThatWasClicked)
  140. {
  141. //[UserbuttonClicked_Pre]
  142. //[/UserbuttonClicked_Pre]
  143. if (buttonThatWasClicked == &editConfigsButton)
  144. {
  145. //[UserButtonCode_b6625dfcdb1f4755] -- add your button handler code here..
  146. showConfigMenu();
  147. //[/UserButtonCode_b6625dfcdb1f4755]
  148. }
  149. else if (buttonThatWasClicked == &openProjectButton)
  150. {
  151. //[UserButtonCode_a550a652e2666ee7] -- add your button handler code here..
  152. //[/UserButtonCode_a550a652e2666ee7]
  153. }
  154. else if (buttonThatWasClicked == &editExportersButton)
  155. {
  156. //[UserButtonCode_c1f6e5f9811b307e] -- add your button handler code here..
  157. showExporterMenu();
  158. //[/UserButtonCode_c1f6e5f9811b307e]
  159. }
  160. else if (buttonThatWasClicked == &saveAndOpenButton)
  161. {
  162. //[UserButtonCode_dRGMyYx] -- add your button handler code here..
  163. //[/UserButtonCode_dRGMyYx]
  164. }
  165. //[UserbuttonClicked_Post]
  166. //[/UserbuttonClicked_Post]
  167. }
  168. void ProjectInformationComponent::paint (Graphics& g)
  169. {
  170. //[UserPaint] Add your own custom painting code here..
  171. g.setTiledImageFill (ImageCache::getFromMemory (BinaryData::brushed_aluminium_png, BinaryData::brushed_aluminium_pngSize),
  172. 0, 0, 1.0f);
  173. g.fillAll();
  174. drawRecessedShadows (g, getWidth(), getHeight(), 14);
  175. //[/UserPaint]
  176. }
  177. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  178. void ProjectInformationComponent::rebuildConfigTabs()
  179. {
  180. configTabBox.clearTabs();
  181. int index = 0;
  182. PropertiesWithHelpComponent* panel = new PropertiesWithHelpComponent (project, index++);
  183. configTabBox.addTab ("Project Settings", Colours::lightslategrey, panel, true, -1);
  184. panel = new PropertiesWithHelpComponent (project, index++);
  185. configTabBox.addTab ("Juce Flags", Colours::lightblue, panel, true, -1);
  186. int i;
  187. for (i = 0; i < project.getNumConfigurations(); ++i)
  188. {
  189. panel = new PropertiesWithHelpComponent (project, index++);
  190. Project::BuildConfiguration config (project.getConfiguration (i));
  191. configTabBox.addTab (config.getName().toString(), Colour::greyLevel (0.65f), panel, true, -1);
  192. }
  193. for (i = 0; i < project.getNumExporters(); ++i)
  194. {
  195. ScopedPointer <ProjectExporter> exp (project.createExporter (i));
  196. if (exp != nullptr)
  197. {
  198. panel = new PropertiesWithHelpComponent (project, index++);
  199. configTabBox.addTab (exp->getName(), Colours::lightsteelblue, panel, true, -1);
  200. }
  201. }
  202. lastProjectType = project.getProjectTypeValue().getValue();
  203. }
  204. void ProjectInformationComponent::updateConfigTabs()
  205. {
  206. if (configTabBox.getNumTabs() != project.getNumConfigurations() + project.getNumExporters() + 2
  207. || lastProjectType != project.getProjectTypeValue().getValue())
  208. {
  209. rebuildConfigTabs();
  210. }
  211. else
  212. {
  213. for (int i = 0; i < project.getNumConfigurations(); ++i)
  214. {
  215. Project::BuildConfiguration config (project.getConfiguration (i));
  216. configTabBox.setTabName (i + 2, config.getName().toString());
  217. }
  218. }
  219. }
  220. void ProjectInformationComponent::showConfigMenu()
  221. {
  222. PopupMenu m;
  223. m.addItem (1, "Add a new empty configuration");
  224. PopupMenu createCopyMenu, removeMenu;
  225. for (int i = 0; i < project.getNumConfigurations(); ++i)
  226. {
  227. Project::BuildConfiguration config (project.getConfiguration (i));
  228. createCopyMenu.addItem (i + 10000, "Create a copy of '" + config.getName().toString() + "'");
  229. removeMenu.addItem (i + 20000, "Delete configuration '" + config.getName().toString() + "'");
  230. }
  231. m.addSubMenu ("Add a copy of an existing configuration", createCopyMenu);
  232. m.addSubMenu ("Remove configuration", removeMenu);
  233. const int r = m.showAt (&editConfigsButton);
  234. if (r >= 20000)
  235. {
  236. project.deleteConfiguration (r - 20000);
  237. }
  238. else if (r >= 10000)
  239. {
  240. Project::BuildConfiguration configToCopy (project.getConfiguration (r - 10000));
  241. project.addNewConfiguration (&configToCopy);
  242. }
  243. else if (r == 1)
  244. {
  245. project.addNewConfiguration (nullptr);
  246. }
  247. }
  248. void ProjectInformationComponent::showExporterMenu()
  249. {
  250. PopupMenu m;
  251. PopupMenu createMenu, removeMenu;
  252. int i;
  253. for (i = 0; i < project.getNumExporters(); ++i)
  254. {
  255. ScopedPointer<ProjectExporter> exp (project.createExporter (i));
  256. if (exp != nullptr)
  257. removeMenu.addItem (i + 20000, "Delete " + exp->getName());
  258. }
  259. StringArray exporters (ProjectExporter::getExporterNames());
  260. for (i = 0; i < exporters.size(); ++i)
  261. createMenu.addItem (i + 10000, "Create a new " + exporters[i] + " target");
  262. m.addSubMenu ("Create new export target", createMenu);
  263. m.addSubMenu ("Remove export target", removeMenu);
  264. const int r = m.showAt (&editExportersButton);
  265. if (r >= 20000)
  266. project.deleteExporter (r - 20000);
  267. else if (r >= 10000)
  268. project.addNewExporter (r - 10000);
  269. }
  270. void ProjectInformationComponent::changeListenerCallback (ChangeBroadcaster*)
  271. {
  272. updateConfigTabs();
  273. }
  274. //[/MiscUserCode]
  275. //==============================================================================
  276. //======================= Jucer Information Section ==========================
  277. //==============================================================================
  278. #if 0
  279. /* This section stores the Jucer's metadata - edit it at your own risk!
  280. JUCER_COMPONENT_METADATA_START
  281. <COMPONENT id="tO9EG1a" className="ProjectInformationComponent" width="836"
  282. height="427" background="f6f9ff" parentClasses="public Component, public ChangeListener"
  283. constructorParams="Project&amp; project_" memberInitialisers="project (project_)">
  284. <COMPONENTS>
  285. <TABBEDCOMPONENT id="962c1575c4142253" memberName="configTabBox" focusOrder="0"
  286. position="8, 0, this.left + parent.width - 16, this.top + parent.height - 36"/>
  287. <TEXTBUTTON id="b6625dfcdb1f4755" memberName="editConfigsButton" focusOrder="0"
  288. text="Add/Remove Configurations..." createCallback="1" radioGroup="0"
  289. connectedLeft="0" connectedRight="0" connectedTop="0" connectedBottom="0"
  290. backgroundColour="" textColour="" backgroundColourOn="" textColourOn=""
  291. position="8, parent.height - 30, this.left + 192, this.top + 22"/>
  292. <TEXTBUTTON id="a550a652e2666ee7" memberName="openProjectButton" focusOrder="0"
  293. text="Open Project in " createCallback="1" radioGroup="0" connectedLeft="0"
  294. connectedRight="0" connectedTop="0" connectedBottom="0" backgroundColour=""
  295. textColour="" backgroundColourOn="" textColourOn="" position="608, parent.height - 30, this.left + 208, this.top + 22"/>
  296. <TEXTBUTTON id="c1f6e5f9811b307e" memberName="editExportersButton" focusOrder="0"
  297. text="Add/Remove Exporters..." createCallback="1" radioGroup="0"
  298. connectedLeft="0" connectedRight="0" connectedTop="0" connectedBottom="0"
  299. backgroundColour="" textColour="" backgroundColourOn="" textColourOn=""
  300. position="208, parent.height - 30, this.left + 160, this.top + 22"/>
  301. <TEXTBUTTON id="dRGMyYx" name="" memberName="saveAndOpenButton" position="391, parent.height - 30, this.left + 208, this.top + 22"
  302. text="Save And Open in" createCallback="1" radioGroup="0" connectedLeft="0"
  303. connectedRight="0" connectedTop="0" connectedBottom="0"/>
  304. </COMPONENTS>
  305. <MARKERS_X/>
  306. <MARKERS_Y/>
  307. <METHODS/>
  308. </COMPONENT>
  309. JUCER_COMPONENT_METADATA_END
  310. */
  311. #endif