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.

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