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.

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