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.

382 lines
13KB

  1. /*
  2. ==============================================================================
  3. This is an automatically generated file created by the Jucer!
  4. Creation date: 10 May 2010 7:13:27pm
  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 "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 ("(Use default from juce_Config.h)");
  45. possibleValues.add ("Enabled");
  46. possibleValues.add ("Disabled");
  47. Array<var> mappings;
  48. mappings.add (Project::configFlagDefault);
  49. mappings.add (Project::configFlagEnabled);
  50. mappings.add (Project::configFlagDisabled);
  51. for (int i = 0; i < flags.size(); ++i)
  52. {
  53. ChoicePropertyComponent* c = new ChoicePropertyComponent (flags[i]->value, flags[i]->symbol, possibleValues, mappings);
  54. c->setTooltip (flags[i]->description);
  55. c->setPreferredHeight (22);
  56. props.add (c);
  57. }
  58. }
  59. else if (tabIndex < 2 + project.getNumConfigurations())
  60. {
  61. // A config tab..
  62. project.getConfiguration (tabIndex - 2).createPropertyEditors (props);
  63. }
  64. else
  65. {
  66. // An export tab..
  67. ScopedPointer <ProjectExporter> exp (project.createExporter (tabIndex - (2 + project.getNumConfigurations())));
  68. if (exp != 0)
  69. exp->createPropertyEditors (props);
  70. for (int i = props.size(); --i >= 0;)
  71. props.getUnchecked(i)->setPreferredHeight (22);
  72. }
  73. getPanel()->addProperties (props);
  74. }
  75. void visibilityChanged()
  76. {
  77. if (isVisible())
  78. rebuildProperties();
  79. }
  80. private:
  81. Project& project;
  82. int tabIndex;
  83. };
  84. //[/MiscUserDefs]
  85. //==============================================================================
  86. ProjectInformationComponent::ProjectInformationComponent (Project& project_)
  87. : project (project_),
  88. configTabBox (0),
  89. editConfigsButton (0),
  90. openProjectButton (0),
  91. editExportersButton (0)
  92. {
  93. addAndMakeVisible (configTabBox = new TabbedComponent (TabbedButtonBar::TabsAtTop));
  94. configTabBox->setTabBarDepth (30);
  95. configTabBox->setCurrentTabIndex (-1);
  96. addAndMakeVisible (editConfigsButton = new TextButton (String::empty));
  97. editConfigsButton->setButtonText (T("Add/Remove Configurations..."));
  98. editConfigsButton->addButtonListener (this);
  99. addAndMakeVisible (openProjectButton = new TextButton (String::empty));
  100. openProjectButton->setButtonText (T("Open Project in "));
  101. openProjectButton->addButtonListener (this);
  102. addAndMakeVisible (editExportersButton = new TextButton (String::empty));
  103. editExportersButton->setButtonText (T("Add/Remove Exporters..."));
  104. editExportersButton->addButtonListener (this);
  105. //[UserPreSize]
  106. rebuildConfigTabs();
  107. #if JUCE_MAC || JUCE_WINDOWS
  108. openProjectButton->setCommandToTrigger (commandManager, CommandIDs::openProjectInIDE, true);
  109. openProjectButton->setButtonText (commandManager->getNameOfCommand (CommandIDs::openProjectInIDE));
  110. #else
  111. openProjectButton->setVisible (false);
  112. #endif
  113. //[/UserPreSize]
  114. setOpaque (true);
  115. setSize (600, 400);
  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. deleteAndZero (configTabBox);
  129. deleteAndZero (editConfigsButton);
  130. deleteAndZero (openProjectButton);
  131. deleteAndZero (editExportersButton);
  132. //[Destructor]. You can add your own custom destruction code here..
  133. //[/Destructor]
  134. }
  135. //==============================================================================
  136. void ProjectInformationComponent::paint (Graphics& g)
  137. {
  138. //[UserPrePaint] Add your own custom painting code here..
  139. g.setTiledImageFill (ImageCache::getFromMemory (BinaryData::brushed_aluminium_png, BinaryData::brushed_aluminium_pngSize),
  140. 0, 0, 1.0f);
  141. g.fillAll();
  142. drawRecessedShadows (g, getWidth(), getHeight(), 14);
  143. //[/UserPrePaint]
  144. //[UserPaint] Add your own custom painting code here..
  145. //[/UserPaint]
  146. }
  147. void ProjectInformationComponent::resized()
  148. {
  149. configTabBox->setBounds (8, 0, getWidth() - 16, getHeight() - 36);
  150. editConfigsButton->setBounds (8, getHeight() - 30, 192, 22);
  151. openProjectButton->setBounds (384, getHeight() - 30, 208, 22);
  152. editExportersButton->setBounds (208, getHeight() - 30, 160, 22);
  153. //[UserResized] Add your own custom resize handling here..
  154. //[/UserResized]
  155. }
  156. void ProjectInformationComponent::buttonClicked (Button* buttonThatWasClicked)
  157. {
  158. //[UserbuttonClicked_Pre]
  159. //[/UserbuttonClicked_Pre]
  160. if (buttonThatWasClicked == editConfigsButton)
  161. {
  162. //[UserButtonCode_editConfigsButton] -- add your button handler code here..
  163. showConfigMenu();
  164. //[/UserButtonCode_editConfigsButton]
  165. }
  166. else if (buttonThatWasClicked == openProjectButton)
  167. {
  168. //[UserButtonCode_openProjectButton] -- add your button handler code here..
  169. //[/UserButtonCode_openProjectButton]
  170. }
  171. else if (buttonThatWasClicked == editExportersButton)
  172. {
  173. //[UserButtonCode_editExportersButton] -- add your button handler code here..
  174. showExporterMenu();
  175. //[/UserButtonCode_editExportersButton]
  176. }
  177. //[UserbuttonClicked_Post]
  178. //[/UserbuttonClicked_Post]
  179. }
  180. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  181. void ProjectInformationComponent::rebuildConfigTabs()
  182. {
  183. configTabBox->clearTabs();
  184. int index = 0;
  185. PropertiesWithHelpComponent* panel = new PropertiesWithHelpComponent (project, index++);
  186. configTabBox->addTab ("Project Settings", Colours::lightslategrey, panel, true, -1);
  187. panel = new PropertiesWithHelpComponent (project, index++);
  188. configTabBox->addTab ("Juce Flags", Colours::lightblue, panel, true, -1);
  189. int i;
  190. for (i = 0; i < project.getNumConfigurations(); ++i)
  191. {
  192. panel = new PropertiesWithHelpComponent (project, index++);
  193. Project::BuildConfiguration config (project.getConfiguration (i));
  194. configTabBox->addTab (config.getName().toString(), Colour::greyLevel (0.65f), panel, true, -1);
  195. }
  196. for (i = 0; i < project.getNumExporters(); ++i)
  197. {
  198. ScopedPointer <ProjectExporter> exp (project.createExporter (i));
  199. if (exp != 0)
  200. {
  201. panel = new PropertiesWithHelpComponent (project, index++);
  202. configTabBox->addTab (exp->getName(), Colours::lightsteelblue, panel, true, -1);
  203. }
  204. }
  205. lastProjectType = project.getProjectType().getValue();
  206. }
  207. void ProjectInformationComponent::updateConfigTabs()
  208. {
  209. if (configTabBox->getNumTabs() != project.getNumConfigurations() + project.getNumExporters() + 2
  210. || lastProjectType != project.getProjectType().getValue())
  211. {
  212. rebuildConfigTabs();
  213. }
  214. else
  215. {
  216. for (int i = 0; i < project.getNumConfigurations(); ++i)
  217. {
  218. Project::BuildConfiguration config (project.getConfiguration (i));
  219. configTabBox->setTabName (i + 2, config.getName().toString());
  220. }
  221. }
  222. }
  223. void ProjectInformationComponent::showConfigMenu()
  224. {
  225. PopupMenu m;
  226. m.addItem (1, "Add a new empty configuration");
  227. PopupMenu createCopyMenu, removeMenu;
  228. for (int i = 0; i < project.getNumConfigurations(); ++i)
  229. {
  230. Project::BuildConfiguration config (project.getConfiguration (i));
  231. createCopyMenu.addItem (i + 10000, "Create a copy of '" + config.getName().toString() + "'");
  232. removeMenu.addItem (i + 20000, "Delete configuration '" + config.getName().toString() + "'");
  233. }
  234. m.addSubMenu ("Add a copy of an existing configuration", createCopyMenu);
  235. m.addSubMenu ("Remove configuration", removeMenu);
  236. const int r = m.showAt (editConfigsButton);
  237. if (r >= 20000)
  238. {
  239. project.deleteConfiguration (r - 20000);
  240. }
  241. else if (r >= 10000)
  242. {
  243. Project::BuildConfiguration configToCopy (project.getConfiguration (r - 10000));
  244. project.addNewConfiguration (&configToCopy);
  245. }
  246. else if (r == 1)
  247. {
  248. project.addNewConfiguration (0);
  249. }
  250. }
  251. void ProjectInformationComponent::showExporterMenu()
  252. {
  253. PopupMenu m;
  254. PopupMenu createMenu, removeMenu;
  255. int i;
  256. for (i = 0; i < project.getNumExporters(); ++i)
  257. {
  258. ScopedPointer<ProjectExporter> exp (project.createExporter (i));
  259. if (exp != 0)
  260. removeMenu.addItem (i + 20000, "Delete " + exp->getName());
  261. }
  262. StringArray exporters (ProjectExporter::getExporterNames());
  263. for (i = 0; i < exporters.size(); ++i)
  264. createMenu.addItem (i + 10000, "Create a new " + exporters[i] + " target");
  265. m.addSubMenu ("Create new export target", createMenu);
  266. m.addSubMenu ("Remove export target", removeMenu);
  267. const int r = m.showAt (editExportersButton);
  268. if (r >= 20000)
  269. project.deleteExporter (r - 20000);
  270. else if (r >= 10000)
  271. project.addNewExporter (r - 10000);
  272. }
  273. void ProjectInformationComponent::changeListenerCallback (void*)
  274. {
  275. updateConfigTabs();
  276. }
  277. //[/MiscUserCode]
  278. //==============================================================================
  279. #if 0
  280. /* -- Jucer information section --
  281. This is where the Jucer puts all of its metadata, so don't change anything in here!
  282. BEGIN_JUCER_METADATA
  283. <JUCER_COMPONENT documentType="Component" className="ProjectInformationComponent"
  284. componentName="" parentClasses="public Component, public ChangeListener"
  285. constructorParams="Project&amp; project_" variableInitialisers="project (project_)"
  286. snapPixels="8" snapActive="1" snapShown="0" overlayOpacity="0.330000013"
  287. fixedSize="0" initialWidth="600" initialHeight="400">
  288. <BACKGROUND backgroundColour="f6f9ff"/>
  289. <TABBEDCOMPONENT name="" id="962c1575c4142253" memberName="configTabBox" virtualName=""
  290. explicitFocusOrder="0" pos="8 0 16M 36M" orientation="top" tabBarDepth="30"
  291. initialTab="-1"/>
  292. <TEXTBUTTON name="" id="b6625dfcdb1f4755" memberName="editConfigsButton"
  293. virtualName="" explicitFocusOrder="0" pos="8 30R 192 22" buttonText="Add/Remove Configurations..."
  294. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  295. <TEXTBUTTON name="" id="a550a652e2666ee7" memberName="openProjectButton"
  296. virtualName="" explicitFocusOrder="0" pos="384 30R 208 22" buttonText="Open Project in "
  297. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  298. <TEXTBUTTON name="" id="c1f6e5f9811b307e" memberName="editExportersButton"
  299. virtualName="" explicitFocusOrder="0" pos="208 30R 160 22" buttonText="Add/Remove Exporters..."
  300. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  301. </JUCER_COMPONENT>
  302. END_JUCER_METADATA
  303. */
  304. #endif