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.

372 lines
12KB

  1. /*
  2. ==============================================================================
  3. This is an automatically generated file created by the Jucer!
  4. Creation date: 14 Feb 2010 3:06:06 pm
  5. Be careful when adding custom code to these files, as only the code within
  6. the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  7. and re-saved.
  8. Jucer version: 1.12
  9. ------------------------------------------------------------------------------
  10. The Jucer is part of the JUCE library - "Jules' Utility Class Extensions"
  11. Copyright 2004-6 by Raw Material Software ltd.
  12. ==============================================================================
  13. */
  14. //[Headers] You can add your own extra header files here...
  15. #include "../model/jucer_ProjectExporter.h"
  16. //[/Headers]
  17. #include "jucer_ProjectInformationComponent.h"
  18. //[MiscUserDefs] You can add your own user definitions and misc code here...
  19. class PropertiesWithHelpComponent : public PropertyPanelWithTooltips
  20. {
  21. public:
  22. PropertiesWithHelpComponent (Project& project_, int tabIndex_)
  23. : project (project_), tabIndex (tabIndex_)
  24. {
  25. }
  26. ~PropertiesWithHelpComponent()
  27. {
  28. }
  29. void rebuildProperties()
  30. {
  31. getPanel()->clear();
  32. Array <PropertyComponent*> props;
  33. if (tabIndex == 0)
  34. {
  35. // The main project tab...
  36. project.createPropertyEditors (props);
  37. }
  38. else if (tabIndex == 1)
  39. {
  40. // The Juce options tab...
  41. OwnedArray <Project::JuceConfigFlag> flags;
  42. project.getJuceConfigFlags (flags);
  43. StringArray possibleValues;
  44. possibleValues.add ("Enabled");
  45. possibleValues.add ("Disabled");
  46. possibleValues.add ("(Use default from juce_Config.h)");
  47. for (int i = 0; i < flags.size(); ++i)
  48. {
  49. if ((int) flags[i]->value.getValue() == 0)
  50. flags[i]->value = 3;
  51. ChoicePropertyComponent* c = new ChoicePropertyComponent (flags[i]->value, flags[i]->symbol, possibleValues);
  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. }
  69. getPanel()->addProperties (props);
  70. }
  71. void visibilityChanged()
  72. {
  73. if (isVisible())
  74. rebuildProperties();
  75. }
  76. private:
  77. Project& project;
  78. int tabIndex;
  79. };
  80. //[/MiscUserDefs]
  81. //==============================================================================
  82. ProjectInformationComponent::ProjectInformationComponent (Project& project_)
  83. : project (project_),
  84. configTabBox (0),
  85. editConfigsButton (0),
  86. openProjectButton (0),
  87. editExportersButton (0)
  88. {
  89. addAndMakeVisible (configTabBox = new TabbedComponent (TabbedButtonBar::TabsAtTop));
  90. configTabBox->setTabBarDepth (30);
  91. configTabBox->setCurrentTabIndex (-1);
  92. addAndMakeVisible (editConfigsButton = new TextButton (String::empty));
  93. editConfigsButton->setButtonText ("Add/Remove Configurations...");
  94. editConfigsButton->addButtonListener (this);
  95. addAndMakeVisible (openProjectButton = new TextButton (String::empty));
  96. openProjectButton->setButtonText ("Open Project in ");
  97. openProjectButton->addButtonListener (this);
  98. addAndMakeVisible (editExportersButton = new TextButton (String::empty));
  99. editExportersButton->setButtonText ("Add/Remove Exporters...");
  100. editExportersButton->addButtonListener (this);
  101. //[UserPreSize]
  102. rebuildConfigTabs();
  103. #if JUCE_MAC || JUCE_WINDOWS
  104. openProjectButton->setCommandToTrigger (commandManager, CommandIDs::openProjectInIDE, true);
  105. openProjectButton->setButtonText (commandManager->getNameOfCommand (CommandIDs::openProjectInIDE));
  106. #else
  107. openProjectButton->setVisible (false);
  108. #endif
  109. //[/UserPreSize]
  110. setSize (600, 400);
  111. //[Constructor] You can add your own custom stuff here..
  112. configTabBox->setOutline (1);
  113. configTabBox->setColour (TabbedComponent::outlineColourId, Colours::black);
  114. editConfigsButton->setTriggeredOnMouseDown (true);
  115. project.addChangeListener (this);
  116. //[/Constructor]
  117. }
  118. ProjectInformationComponent::~ProjectInformationComponent()
  119. {
  120. //[Destructor_pre]. You can add your own custom destruction code here..
  121. project.removeChangeListener (this);
  122. //[/Destructor_pre]
  123. deleteAndZero (configTabBox);
  124. deleteAndZero (editConfigsButton);
  125. deleteAndZero (openProjectButton);
  126. deleteAndZero (editExportersButton);
  127. //[Destructor]. You can add your own custom destruction code here..
  128. //[/Destructor]
  129. }
  130. //==============================================================================
  131. void ProjectInformationComponent::paint (Graphics& g)
  132. {
  133. //[UserPrePaint] Add your own custom painting code here..
  134. //[/UserPrePaint]
  135. //[UserPaint] Add your own custom painting code here..
  136. //[/UserPaint]
  137. }
  138. void ProjectInformationComponent::resized()
  139. {
  140. configTabBox->setBounds (8, 0, getWidth() - 16, getHeight() - 36);
  141. editConfigsButton->setBounds (8, getHeight() - 26, 192, 22);
  142. openProjectButton->setBounds (384, getHeight() - 26, 208, 22);
  143. editExportersButton->setBounds (208, getHeight() - 26, 160, 22);
  144. //[UserResized] Add your own custom resize handling here..
  145. //[/UserResized]
  146. }
  147. void ProjectInformationComponent::buttonClicked (Button* buttonThatWasClicked)
  148. {
  149. //[UserbuttonClicked_Pre]
  150. //[/UserbuttonClicked_Pre]
  151. if (buttonThatWasClicked == editConfigsButton)
  152. {
  153. //[UserButtonCode_editConfigsButton] -- add your button handler code here..
  154. showConfigMenu();
  155. //[/UserButtonCode_editConfigsButton]
  156. }
  157. else if (buttonThatWasClicked == openProjectButton)
  158. {
  159. //[UserButtonCode_openProjectButton] -- add your button handler code here..
  160. //[/UserButtonCode_openProjectButton]
  161. }
  162. else if (buttonThatWasClicked == editExportersButton)
  163. {
  164. //[UserButtonCode_editExportersButton] -- add your button handler code here..
  165. showExporterMenu();
  166. //[/UserButtonCode_editExportersButton]
  167. }
  168. //[UserbuttonClicked_Post]
  169. //[/UserbuttonClicked_Post]
  170. }
  171. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  172. void ProjectInformationComponent::rebuildConfigTabs()
  173. {
  174. configTabBox->clearTabs();
  175. int index = 0;
  176. PropertiesWithHelpComponent* panel = new PropertiesWithHelpComponent (project, index++);
  177. configTabBox->addTab ("Project Settings", Colours::lightslategrey, panel, true, -1);
  178. panel = new PropertiesWithHelpComponent (project, index++);
  179. configTabBox->addTab ("Juce Flags", Colours::lightblue, panel, true, -1);
  180. int i;
  181. for (i = 0; i < project.getNumConfigurations(); ++i)
  182. {
  183. panel = new PropertiesWithHelpComponent (project, index++);
  184. Project::BuildConfiguration config (project.getConfiguration (i));
  185. configTabBox->addTab (config.getName().toString(), Colour::greyLevel (0.65f), panel, true, -1);
  186. }
  187. for (i = 0; i < project.getNumExporters(); ++i)
  188. {
  189. ScopedPointer <ProjectExporter> exp (project.createExporter (i));
  190. if (exp != 0)
  191. {
  192. panel = new PropertiesWithHelpComponent (project, index++);
  193. configTabBox->addTab (exp->getName(), Colours::lightsteelblue, panel, true, -1);
  194. }
  195. }
  196. lastProjectType = (Project::ProjectType) (int) project.getProjectType().getValue();
  197. }
  198. void ProjectInformationComponent::updateConfigTabs()
  199. {
  200. if (configTabBox->getNumTabs() != project.getNumConfigurations() + project.getNumExporters() + 2
  201. || lastProjectType != (Project::ProjectType) (int) project.getProjectType().getValue())
  202. {
  203. rebuildConfigTabs();
  204. }
  205. else
  206. {
  207. for (int i = 0; i < project.getNumConfigurations(); ++i)
  208. {
  209. Project::BuildConfiguration config (project.getConfiguration (i));
  210. configTabBox->setTabName (i + 2, config.getName().toString());
  211. }
  212. }
  213. }
  214. void ProjectInformationComponent::showConfigMenu()
  215. {
  216. PopupMenu m;
  217. m.addItem (1, "Add a new empty configuration");
  218. PopupMenu createCopyMenu, removeMenu;
  219. for (int i = 0; i < project.getNumConfigurations(); ++i)
  220. {
  221. Project::BuildConfiguration config (project.getConfiguration (i));
  222. createCopyMenu.addItem (i + 10000, "Create a copy of '" + config.getName().toString() + "'");
  223. removeMenu.addItem (i + 20000, "Delete configuration '" + config.getName().toString() + "'");
  224. }
  225. m.addSubMenu ("Add a copy of an existing configuration", createCopyMenu);
  226. m.addSubMenu ("Remove configuration", removeMenu);
  227. const int r = m.showAt (editConfigsButton);
  228. if (r >= 20000)
  229. {
  230. project.deleteConfiguration (r - 20000);
  231. }
  232. else if (r >= 10000)
  233. {
  234. Project::BuildConfiguration configToCopy (project.getConfiguration (r - 10000));
  235. project.addNewConfiguration (&configToCopy);
  236. }
  237. else if (r == 1)
  238. {
  239. project.addNewConfiguration (0);
  240. }
  241. }
  242. void ProjectInformationComponent::showExporterMenu()
  243. {
  244. PopupMenu m;
  245. PopupMenu createMenu, removeMenu;
  246. int i;
  247. for (i = 0; i < project.getNumExporters(); ++i)
  248. {
  249. ScopedPointer<ProjectExporter> exp (project.createExporter (i));
  250. if (exp != 0)
  251. removeMenu.addItem (i + 20000, "Delete " + exp->getName());
  252. }
  253. StringArray exporters (ProjectExporter::getExporterNames());
  254. for (i = 0; i < exporters.size(); ++i)
  255. createMenu.addItem (i + 10000, "Create a new " + exporters[i] + " target");
  256. m.addSubMenu ("Create new export target", createMenu);
  257. m.addSubMenu ("Remove export target", removeMenu);
  258. const int r = m.showAt (editExportersButton);
  259. if (r >= 20000)
  260. project.deleteExporter (r - 20000);
  261. else if (r >= 10000)
  262. project.addNewExporter (r - 10000);
  263. }
  264. void ProjectInformationComponent::changeListenerCallback (void*)
  265. {
  266. updateConfigTabs();
  267. }
  268. //[/MiscUserCode]
  269. //==============================================================================
  270. #if 0
  271. /* -- Jucer information section --
  272. This is where the Jucer puts all of its metadata, so don't change anything in here!
  273. BEGIN_JUCER_METADATA
  274. <JUCER_COMPONENT documentType="Component" className="ProjectInformationComponent"
  275. componentName="" parentClasses="public Component, public ChangeListener"
  276. constructorParams="Project&amp; project_" variableInitialisers="project (project_)"
  277. snapPixels="8" snapActive="1" snapShown="0" overlayOpacity="0.330000013"
  278. fixedSize="0" initialWidth="600" initialHeight="400">
  279. <BACKGROUND backgroundColour="f6f9ff"/>
  280. <TABBEDCOMPONENT name="" id="962c1575c4142253" memberName="configTabBox" virtualName=""
  281. explicitFocusOrder="0" pos="8 0 16M 36M" orientation="top" tabBarDepth="30"
  282. initialTab="-1"/>
  283. <TEXTBUTTON name="" id="b6625dfcdb1f4755" memberName="editConfigsButton"
  284. virtualName="" explicitFocusOrder="0" pos="8 26R 192 22" buttonText="Add/Remove Configurations..."
  285. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  286. <TEXTBUTTON name="" id="a550a652e2666ee7" memberName="openProjectButton"
  287. virtualName="" explicitFocusOrder="0" pos="384 26R 208 22" buttonText="Open Project in "
  288. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  289. <TEXTBUTTON name="" id="c1f6e5f9811b307e" memberName="editExportersButton"
  290. virtualName="" explicitFocusOrder="0" pos="208 26R 160 22" buttonText="Add/Remove Exporters..."
  291. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  292. </JUCER_COMPONENT>
  293. END_JUCER_METADATA
  294. */
  295. #endif