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.

375 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/Project/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. 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 (0),
  87. editConfigsButton (0),
  88. openProjectButton (0),
  89. editExportersButton (0)
  90. {
  91. addAndMakeVisible (configTabBox = new TabbedComponent (TabbedButtonBar::TabsAtTop));
  92. configTabBox->setTabBarDepth (30);
  93. configTabBox->setCurrentTabIndex (-1);
  94. addAndMakeVisible (editConfigsButton = new TextButton (String::empty));
  95. editConfigsButton->setButtonText ("Add/Remove Configurations...");
  96. editConfigsButton->addButtonListener (this);
  97. addAndMakeVisible (openProjectButton = new TextButton (String::empty));
  98. openProjectButton->setButtonText ("Open Project in ");
  99. openProjectButton->addButtonListener (this);
  100. addAndMakeVisible (editExportersButton = new TextButton (String::empty));
  101. editExportersButton->setButtonText ("Add/Remove Exporters...");
  102. editExportersButton->addButtonListener (this);
  103. //[UserPreSize]
  104. rebuildConfigTabs();
  105. #if JUCE_MAC || JUCE_WINDOWS
  106. openProjectButton->setCommandToTrigger (commandManager, CommandIDs::openProjectInIDE, true);
  107. openProjectButton->setButtonText (commandManager->getNameOfCommand (CommandIDs::openProjectInIDE));
  108. #else
  109. openProjectButton->setVisible (false);
  110. #endif
  111. //[/UserPreSize]
  112. setSize (600, 400);
  113. //[Constructor] You can add your own custom stuff here..
  114. configTabBox->setOutline (1);
  115. configTabBox->setColour (TabbedComponent::outlineColourId, Colours::black);
  116. editConfigsButton->setTriggeredOnMouseDown (true);
  117. project.addChangeListener (this);
  118. //[/Constructor]
  119. }
  120. ProjectInformationComponent::~ProjectInformationComponent()
  121. {
  122. //[Destructor_pre]. You can add your own custom destruction code here..
  123. project.removeChangeListener (this);
  124. //[/Destructor_pre]
  125. deleteAndZero (configTabBox);
  126. deleteAndZero (editConfigsButton);
  127. deleteAndZero (openProjectButton);
  128. deleteAndZero (editExportersButton);
  129. //[Destructor]. You can add your own custom destruction code here..
  130. //[/Destructor]
  131. }
  132. //==============================================================================
  133. void ProjectInformationComponent::paint (Graphics& g)
  134. {
  135. //[UserPrePaint] Add your own custom painting code here..
  136. //[/UserPrePaint]
  137. //[UserPaint] Add your own custom painting code here..
  138. //[/UserPaint]
  139. }
  140. void ProjectInformationComponent::resized()
  141. {
  142. configTabBox->setBounds (8, 0, getWidth() - 16, getHeight() - 36);
  143. editConfigsButton->setBounds (8, getHeight() - 26, 192, 22);
  144. openProjectButton->setBounds (384, getHeight() - 26, 208, 22);
  145. editExportersButton->setBounds (208, getHeight() - 26, 160, 22);
  146. //[UserResized] Add your own custom resize handling here..
  147. //[/UserResized]
  148. }
  149. void ProjectInformationComponent::buttonClicked (Button* buttonThatWasClicked)
  150. {
  151. //[UserbuttonClicked_Pre]
  152. //[/UserbuttonClicked_Pre]
  153. if (buttonThatWasClicked == editConfigsButton)
  154. {
  155. //[UserButtonCode_editConfigsButton] -- add your button handler code here..
  156. showConfigMenu();
  157. //[/UserButtonCode_editConfigsButton]
  158. }
  159. else if (buttonThatWasClicked == openProjectButton)
  160. {
  161. //[UserButtonCode_openProjectButton] -- add your button handler code here..
  162. //[/UserButtonCode_openProjectButton]
  163. }
  164. else if (buttonThatWasClicked == editExportersButton)
  165. {
  166. //[UserButtonCode_editExportersButton] -- add your button handler code here..
  167. showExporterMenu();
  168. //[/UserButtonCode_editExportersButton]
  169. }
  170. //[UserbuttonClicked_Post]
  171. //[/UserbuttonClicked_Post]
  172. }
  173. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  174. void ProjectInformationComponent::rebuildConfigTabs()
  175. {
  176. configTabBox->clearTabs();
  177. int index = 0;
  178. PropertiesWithHelpComponent* panel = new PropertiesWithHelpComponent (project, index++);
  179. configTabBox->addTab ("Project Settings", Colours::lightslategrey, panel, true, -1);
  180. panel = new PropertiesWithHelpComponent (project, index++);
  181. configTabBox->addTab ("Juce Flags", Colours::lightblue, panel, true, -1);
  182. int i;
  183. for (i = 0; i < project.getNumConfigurations(); ++i)
  184. {
  185. panel = new PropertiesWithHelpComponent (project, index++);
  186. Project::BuildConfiguration config (project.getConfiguration (i));
  187. configTabBox->addTab (config.getName().toString(), Colour::greyLevel (0.65f), panel, true, -1);
  188. }
  189. for (i = 0; i < project.getNumExporters(); ++i)
  190. {
  191. ScopedPointer <ProjectExporter> exp (project.createExporter (i));
  192. if (exp != 0)
  193. {
  194. panel = new PropertiesWithHelpComponent (project, index++);
  195. configTabBox->addTab (exp->getName(), Colours::lightsteelblue, panel, true, -1);
  196. }
  197. }
  198. lastProjectType = (Project::ProjectType) (int) project.getProjectType().getValue();
  199. }
  200. void ProjectInformationComponent::updateConfigTabs()
  201. {
  202. if (configTabBox->getNumTabs() != project.getNumConfigurations() + project.getNumExporters() + 2
  203. || lastProjectType != (Project::ProjectType) (int) project.getProjectType().getValue())
  204. {
  205. rebuildConfigTabs();
  206. }
  207. else
  208. {
  209. for (int i = 0; i < project.getNumConfigurations(); ++i)
  210. {
  211. Project::BuildConfiguration config (project.getConfiguration (i));
  212. configTabBox->setTabName (i + 2, config.getName().toString());
  213. }
  214. }
  215. }
  216. void ProjectInformationComponent::showConfigMenu()
  217. {
  218. PopupMenu m;
  219. m.addItem (1, "Add a new empty configuration");
  220. PopupMenu createCopyMenu, removeMenu;
  221. for (int i = 0; i < project.getNumConfigurations(); ++i)
  222. {
  223. Project::BuildConfiguration config (project.getConfiguration (i));
  224. createCopyMenu.addItem (i + 10000, "Create a copy of '" + config.getName().toString() + "'");
  225. removeMenu.addItem (i + 20000, "Delete configuration '" + config.getName().toString() + "'");
  226. }
  227. m.addSubMenu ("Add a copy of an existing configuration", createCopyMenu);
  228. m.addSubMenu ("Remove configuration", removeMenu);
  229. const int r = m.showAt (editConfigsButton);
  230. if (r >= 20000)
  231. {
  232. project.deleteConfiguration (r - 20000);
  233. }
  234. else if (r >= 10000)
  235. {
  236. Project::BuildConfiguration configToCopy (project.getConfiguration (r - 10000));
  237. project.addNewConfiguration (&configToCopy);
  238. }
  239. else if (r == 1)
  240. {
  241. project.addNewConfiguration (0);
  242. }
  243. }
  244. void ProjectInformationComponent::showExporterMenu()
  245. {
  246. PopupMenu m;
  247. PopupMenu createMenu, removeMenu;
  248. int i;
  249. for (i = 0; i < project.getNumExporters(); ++i)
  250. {
  251. ScopedPointer<ProjectExporter> exp (project.createExporter (i));
  252. if (exp != 0)
  253. removeMenu.addItem (i + 20000, "Delete " + exp->getName());
  254. }
  255. StringArray exporters (ProjectExporter::getExporterNames());
  256. for (i = 0; i < exporters.size(); ++i)
  257. createMenu.addItem (i + 10000, "Create a new " + exporters[i] + " target");
  258. m.addSubMenu ("Create new export target", createMenu);
  259. m.addSubMenu ("Remove export target", removeMenu);
  260. const int r = m.showAt (editExportersButton);
  261. if (r >= 20000)
  262. project.deleteExporter (r - 20000);
  263. else if (r >= 10000)
  264. project.addNewExporter (r - 10000);
  265. }
  266. void ProjectInformationComponent::changeListenerCallback (void*)
  267. {
  268. updateConfigTabs();
  269. }
  270. //[/MiscUserCode]
  271. //==============================================================================
  272. #if 0
  273. /* -- Jucer information section --
  274. This is where the Jucer puts all of its metadata, so don't change anything in here!
  275. BEGIN_JUCER_METADATA
  276. <JUCER_COMPONENT documentType="Component" className="ProjectInformationComponent"
  277. componentName="" parentClasses="public Component, public ChangeListener"
  278. constructorParams="Project&amp; project_" variableInitialisers="project (project_)"
  279. snapPixels="8" snapActive="1" snapShown="0" overlayOpacity="0.330000013"
  280. fixedSize="0" initialWidth="600" initialHeight="400">
  281. <BACKGROUND backgroundColour="f6f9ff"/>
  282. <TABBEDCOMPONENT name="" id="962c1575c4142253" memberName="configTabBox" virtualName=""
  283. explicitFocusOrder="0" pos="8 0 16M 36M" orientation="top" tabBarDepth="30"
  284. initialTab="-1"/>
  285. <TEXTBUTTON name="" id="b6625dfcdb1f4755" memberName="editConfigsButton"
  286. virtualName="" explicitFocusOrder="0" pos="8 26R 192 22" buttonText="Add/Remove Configurations..."
  287. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  288. <TEXTBUTTON name="" id="a550a652e2666ee7" memberName="openProjectButton"
  289. virtualName="" explicitFocusOrder="0" pos="384 26R 208 22" buttonText="Open Project in "
  290. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  291. <TEXTBUTTON name="" id="c1f6e5f9811b307e" memberName="editExportersButton"
  292. virtualName="" explicitFocusOrder="0" pos="208 26R 160 22" buttonText="Add/Remove Exporters..."
  293. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  294. </JUCER_COMPONENT>
  295. END_JUCER_METADATA
  296. */
  297. #endif