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.

851 lines
32KB

  1. /*
  2. ==============================================================================
  3. This is an automatically generated file!
  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 v2.0.16
  8. ------------------------------------------------------------------------------
  9. JUCE is copyright 2004-11 by Raw Material Software ltd.
  10. ==============================================================================
  11. */
  12. //[CppHeaders] You can add your own extra header files here...
  13. #include "../Project Saving/jucer_ProjectExporter.h"
  14. #include "jucer_Module.h"
  15. #include "../Application/jucer_JuceUpdater.h"
  16. //[/CppHeaders]
  17. #include "jucer_ProjectInformationComponent.h"
  18. //[MiscUserDefs] You can add your own user definitions and misc code here...
  19. //==============================================================================
  20. class ModulesPanel : public PropertyComponent,
  21. public FilenameComponentListener,
  22. public ButtonListener
  23. {
  24. public:
  25. ModulesPanel (Project& project_)
  26. : PropertyComponent ("Modules", 500),
  27. project (project_),
  28. modulesLocation ("modules", ModuleList::getLocalModulesFolder (&project),
  29. true, true, false, "*", String::empty,
  30. "Select a folder containing your JUCE modules..."),
  31. modulesLabel (String::empty, "Module source folder:"),
  32. updateModulesButton ("Check for module updates..."),
  33. moduleListBox (moduleList)
  34. {
  35. moduleList.rescan (ModuleList::getLocalModulesFolder (&project));
  36. addAndMakeVisible (&modulesLocation);
  37. modulesLocation.setBounds ("150, 3, parent.width - 180, 28");
  38. modulesLocation.addListener (this);
  39. modulesLabel.attachToComponent (&modulesLocation, true);
  40. addAndMakeVisible (&updateModulesButton);
  41. updateModulesButton.setBounds ("parent.width - 175, 3, parent.width - 4, 28");
  42. updateModulesButton.addListener (this);
  43. moduleListBox.setOwner (this);
  44. addAndMakeVisible (&moduleListBox);
  45. moduleListBox.setBounds ("4, 31, parent.width / 2 - 4, parent.height - 3");
  46. }
  47. void filenameComponentChanged (FilenameComponent*)
  48. {
  49. moduleList.rescan (modulesLocation.getCurrentFile());
  50. modulesLocation.setCurrentFile (moduleList.getModulesFolder(), false, false);
  51. ModuleList::setLocalModulesFolder (moduleList.getModulesFolder());
  52. moduleListBox.refresh();
  53. }
  54. void buttonClicked (Button*)
  55. {
  56. JuceUpdater::show (moduleList, getTopLevelComponent(), "");
  57. filenameComponentChanged (nullptr);
  58. }
  59. bool isEnabled (const ModuleList::Module* m) const
  60. {
  61. return project.isModuleEnabled (m->uid);
  62. }
  63. void setEnabled (const ModuleList::Module* m, bool enable)
  64. {
  65. if (enable)
  66. project.addModule (m->uid, true);
  67. else
  68. project.removeModule (m->uid);
  69. refresh();
  70. }
  71. bool areDependenciesMissing (const ModuleList::Module* m)
  72. {
  73. return moduleList.getExtraDependenciesNeeded (project, *m).size() > 0;
  74. }
  75. void selectionChanged (const ModuleList::Module* selectedModule)
  76. {
  77. settings = nullptr;
  78. if (selectedModule != nullptr)
  79. addAndMakeVisible (settings = new ModuleSettingsPanel (project, moduleList, selectedModule->uid));
  80. }
  81. void refresh()
  82. {
  83. moduleListBox.refresh();
  84. if (settings != nullptr)
  85. settings->refreshAll();
  86. }
  87. void paint (Graphics& g) // (overridden to avoid drawing the name)
  88. {
  89. getLookAndFeel().drawPropertyComponentBackground (g, getWidth(), getHeight(), *this);
  90. }
  91. //==============================================================================
  92. class ModuleSelectionListBox : public ListBox,
  93. public ListBoxModel
  94. {
  95. public:
  96. ModuleSelectionListBox (ModuleList& list_)
  97. : list (list_), owner (nullptr)
  98. {
  99. setColour (ListBox::backgroundColourId, Colours::white.withAlpha (0.4f));
  100. setTooltip ("Use this list to select which modules should be included in your app.\n"
  101. "Any modules which have missing dependencies will be shown in red.");
  102. }
  103. void setOwner (ModulesPanel* owner_)
  104. {
  105. owner = owner_;
  106. setModel (this);
  107. }
  108. void refresh()
  109. {
  110. updateContent();
  111. repaint();
  112. }
  113. int getNumRows()
  114. {
  115. return list.modules.size();
  116. }
  117. void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected)
  118. {
  119. if (rowIsSelected)
  120. g.fillAll (findColour (TextEditor::highlightColourId));
  121. const ModuleList::Module* const m = list.modules [rowNumber];
  122. if (m != nullptr)
  123. {
  124. const float tickSize = height * 0.7f;
  125. getLookAndFeel().drawTickBox (g, *this, (height - tickSize) / 2, (height - tickSize) / 2, tickSize, tickSize,
  126. owner->isEnabled (m), true, false, false);
  127. if (owner->isEnabled (m) && owner->areDependenciesMissing (m))
  128. g.setColour (Colours::red);
  129. else
  130. g.setColour (Colours::black);
  131. g.setFont (height * 0.7f, Font::bold);
  132. g.drawFittedText (m->uid, height, 0, 200, height, Justification::centredLeft, 1);
  133. g.setFont (height * 0.55f, Font::italic);
  134. g.drawText (m->name, height + 200, 0, width - height - 200, height, Justification::centredLeft, true);
  135. }
  136. }
  137. void listBoxItemClicked (int row, const MouseEvent& e)
  138. {
  139. if (e.x < getRowHeight())
  140. flipRow (row);
  141. }
  142. void listBoxItemDoubleClicked (int row, const MouseEvent& e)
  143. {
  144. flipRow (row);
  145. }
  146. void returnKeyPressed (int row)
  147. {
  148. flipRow (row);
  149. }
  150. void selectedRowsChanged (int lastRowSelected)
  151. {
  152. owner->selectionChanged (list.modules [lastRowSelected]);
  153. }
  154. void flipRow (int row)
  155. {
  156. const ModuleList::Module* const m = list.modules [row];
  157. if (m != nullptr)
  158. owner->setEnabled (m, ! owner->isEnabled (m));
  159. }
  160. private:
  161. ModuleList& list;
  162. ModulesPanel* owner;
  163. };
  164. //==============================================================================
  165. class ModuleSettingsPanel : public PropertyPanel
  166. {
  167. public:
  168. ModuleSettingsPanel (Project& project_, ModuleList& moduleList_, const String& moduleID_)
  169. : project (project_), moduleList (moduleList_), moduleID (moduleID_)
  170. {
  171. setBounds ("parent.width / 2 + 1, 31, parent.width - 3, parent.height - 3");
  172. refreshAll();
  173. }
  174. void refreshAll()
  175. {
  176. setEnabled (project.isModuleEnabled (moduleID));
  177. clear();
  178. PropertyListBuilder props;
  179. ScopedPointer<LibraryModule> module (moduleList.loadModule (moduleID));
  180. if (module != nullptr)
  181. {
  182. props.add (new ModuleInfoComponent (project, moduleList, moduleID));
  183. if (project.isModuleEnabled (moduleID))
  184. {
  185. const ModuleList::Module* m = moduleList.findModuleInfo (moduleID);
  186. if (m != nullptr && moduleList.getExtraDependenciesNeeded (project, *m).size() > 0)
  187. props.add (new MissingDependenciesComponent (project, moduleList, moduleID));
  188. }
  189. props.add (new BooleanPropertyComponent (project.shouldShowAllModuleFilesInProject (moduleID),
  190. "Add source to project", "Make module files browsable in projects"),
  191. "If this is enabled, then the entire source tree from this module will be shown inside your project, "
  192. "making it easy to browse/edit the module's classes. If disabled, then only the minimum number of files "
  193. "required to compile it will appear inside your project.");
  194. props.add (new BooleanPropertyComponent (project.shouldCopyModuleFilesLocally (moduleID),
  195. "Create local copy", "Copy the module into the project folder"),
  196. "If this is enabled, then a local copy of the entire module will be made inside your project (in the auto-generated JuceLibraryFiles folder), "
  197. "so that your project will be self-contained, and won't need to contain any references to files in other folders. "
  198. "This also means that you can check the module into your source-control system to make sure it is always in sync with your own code.");
  199. StringArray possibleValues;
  200. possibleValues.add ("(Use Default)");
  201. possibleValues.add ("Enabled");
  202. possibleValues.add ("Disabled");
  203. Array<var> mappings;
  204. mappings.add (Project::configFlagDefault);
  205. mappings.add (Project::configFlagEnabled);
  206. mappings.add (Project::configFlagDisabled);
  207. OwnedArray <Project::ConfigFlag> flags;
  208. module->getConfigFlags (project, flags);
  209. for (int i = 0; i < flags.size(); ++i)
  210. {
  211. ChoicePropertyComponent* c = new ChoicePropertyComponent (flags[i]->value, flags[i]->symbol, possibleValues, mappings);
  212. c->setTooltip (flags[i]->description);
  213. c->setPreferredHeight (22);
  214. props.add (c);
  215. }
  216. }
  217. addProperties (props.components);
  218. }
  219. private:
  220. Project& project;
  221. ModuleList& moduleList;
  222. String moduleID;
  223. //==============================================================================
  224. class ModuleInfoComponent : public PropertyComponent
  225. {
  226. public:
  227. ModuleInfoComponent (Project& project_, ModuleList& moduleList_, const String& moduleID_)
  228. : PropertyComponent ("Module", 100), project (project_), moduleList (moduleList_), moduleID (moduleID_)
  229. {
  230. }
  231. void refresh() {}
  232. void paint (Graphics& g)
  233. {
  234. g.setColour (Colours::white.withAlpha (0.4f));
  235. g.fillRect (0, 0, getWidth(), getHeight() - 1);
  236. const ModuleList::Module* module = moduleList.findModuleInfo (moduleID);
  237. if (module != nullptr)
  238. {
  239. String text;
  240. text << module->name << newLine << "Version: " << module->version << newLine << newLine
  241. << module->description;
  242. GlyphArrangement ga;
  243. ga.addJustifiedText (Font (13.0f), text, 4.0f, 16.0f, getWidth() - 8.0f, Justification::topLeft);
  244. g.setColour (Colours::black);
  245. ga.draw (g);
  246. }
  247. }
  248. private:
  249. Project& project;
  250. ModuleList& moduleList;
  251. String moduleID;
  252. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ModuleInfoComponent);
  253. };
  254. //==============================================================================
  255. class MissingDependenciesComponent : public PropertyComponent,
  256. public ButtonListener
  257. {
  258. public:
  259. MissingDependenciesComponent (Project& project_, ModuleList& moduleList_, const String& moduleID_)
  260. : PropertyComponent ("Dependencies", 100),
  261. project (project_), moduleList (moduleList_), moduleID (moduleID_),
  262. fixButton ("Enable Required Modules")
  263. {
  264. const ModuleList::Module* module = moduleList.findModuleInfo (moduleID);
  265. if (module != nullptr)
  266. missingDependencies = moduleList.getExtraDependenciesNeeded (project, *module);
  267. addAndMakeVisible (&fixButton);
  268. fixButton.setColour (TextButton::buttonColourId, Colours::red);
  269. fixButton.setColour (TextButton::textColourOffId, Colours::white);
  270. fixButton.setBounds ("right - 160, parent.height - 26, parent.width - 8, top + 22");
  271. fixButton.addListener (this);
  272. }
  273. void refresh() {}
  274. void paint (Graphics& g)
  275. {
  276. g.setColour (Colours::white.withAlpha (0.4f));
  277. g.fillRect (0, 0, getWidth(), getHeight() - 1);
  278. String text ("This module requires the following dependencies:\n");
  279. text << missingDependencies.joinIntoString (", ");
  280. GlyphArrangement ga;
  281. ga.addJustifiedText (Font (13.0f), text, 4.0f, 16.0f, getWidth() - 8.0f, Justification::topLeft);
  282. g.setColour (Colours::red);
  283. ga.draw (g);
  284. }
  285. void buttonClicked (Button*)
  286. {
  287. bool isModuleCopiedLocally = project.shouldCopyModuleFilesLocally (moduleID).getValue();
  288. for (int i = missingDependencies.size(); --i >= 0;)
  289. project.addModule (missingDependencies[i], isModuleCopiedLocally);
  290. ModulesPanel* mp = findParentComponentOfClass ((ModulesPanel*) nullptr);
  291. if (mp != nullptr)
  292. mp->refresh();
  293. }
  294. private:
  295. Project& project;
  296. ModuleList& moduleList;
  297. String moduleID;
  298. StringArray missingDependencies;
  299. TextButton fixButton;
  300. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MissingDependenciesComponent);
  301. };
  302. };
  303. private:
  304. Project& project;
  305. ModuleList moduleList;
  306. FilenameComponent modulesLocation;
  307. Label modulesLabel;
  308. TextButton updateModulesButton;
  309. ModuleSelectionListBox moduleListBox;
  310. ScopedPointer<ModuleSettingsPanel> settings;
  311. };
  312. //==============================================================================
  313. class ProjectSettingsComponent : public Component
  314. {
  315. public:
  316. ProjectSettingsComponent (Project& project_)
  317. : project (project_),
  318. configs ("Configurations", "Add a New Configuration", false),
  319. exporters ("Export Targets", "Add a New Exporter...", true)
  320. {
  321. addAndMakeVisible (&mainProjectInfoPanel);
  322. addAndMakeVisible (&modulesPanelGroup);
  323. addAndMakeVisible (&configs);
  324. addAndMakeVisible (&exporters);
  325. PropertyListBuilder props;
  326. props.add (new ModulesPanel (project));
  327. modulesPanelGroup.setProperties (props);
  328. modulesPanelGroup.setName ("Modules");
  329. createItems();
  330. }
  331. void updateSize (int width)
  332. {
  333. width = jmax (550, width);
  334. int y = 0;
  335. y += mainProjectInfoPanel.updateSize (y, width);
  336. y += modulesPanelGroup.updateSize (y, width);
  337. y += configs.updateSize (y, width);
  338. y += exporters.updateSize (y, width);
  339. setSize (width, y);
  340. }
  341. void parentSizeChanged()
  342. {
  343. updateSize (getParentWidth());
  344. }
  345. void visibilityChanged()
  346. {
  347. if (isVisible())
  348. refreshAll();
  349. }
  350. void refreshAll()
  351. {
  352. {
  353. PropertyListBuilder props;
  354. project.createPropertyEditors (props);
  355. mainProjectInfoPanel.setProperties (props);
  356. mainProjectInfoPanel.setName ("Project Settings");
  357. }
  358. int i;
  359. for (i = configs.groups.size(); --i >= 0;)
  360. {
  361. PropertyGroup& pp = *configs.groups.getUnchecked(i);
  362. PropertyListBuilder props;
  363. project.getConfiguration (i).createPropertyEditors (props);
  364. pp.setProperties (props);
  365. }
  366. for (i = exporters.groups.size(); --i >= 0;)
  367. {
  368. PropertyGroup& pp = *exporters.groups.getUnchecked(i);
  369. PropertyListBuilder props;
  370. ScopedPointer <ProjectExporter> exp (project.createExporter (i));
  371. jassert (exp != nullptr);
  372. if (exp != nullptr)
  373. {
  374. exp->createPropertyEditors (props);
  375. pp.setProperties (props);
  376. }
  377. }
  378. refreshSectionNames();
  379. updateSize (getWidth());
  380. }
  381. void refreshSectionNames()
  382. {
  383. int i;
  384. for (i = configs.groups.size(); --i >= 0;)
  385. {
  386. PropertyGroup& pp = *configs.groups.getUnchecked(i);
  387. pp.setName (project.getConfiguration (i).getName().toString().quoted());
  388. pp.repaint();
  389. }
  390. for (i = exporters.groups.size(); --i >= 0;)
  391. {
  392. PropertyGroup& pp = *exporters.groups.getUnchecked(i);
  393. ScopedPointer <ProjectExporter> exp (project.createExporter (i));
  394. jassert (exp != nullptr);
  395. if (exp != nullptr)
  396. pp.setName (exp->getName());
  397. pp.repaint();
  398. }
  399. }
  400. void createItems()
  401. {
  402. configs.clear();
  403. exporters.clear();
  404. int i;
  405. for (i = 0; i < project.getNumConfigurations(); ++i)
  406. {
  407. PropertyGroup* p = configs.createGroup();
  408. if (project.getNumConfigurations() > 1)
  409. p->addDeleteButton ("config " + String (i), "Deletes this configuration.");
  410. }
  411. for (i = 0; i < project.getNumExporters(); ++i)
  412. {
  413. PropertyGroup* p = exporters.createGroup();
  414. p->addDeleteButton ("exporter " + String (i), "Deletes this export target.");
  415. }
  416. lastProjectType = project.getProjectTypeValue().getValue();
  417. refreshAll();
  418. }
  419. void update()
  420. {
  421. if (configs.groups.size() != project.getNumConfigurations()
  422. || exporters.groups.size() != project.getNumExporters()
  423. || lastProjectType != project.getProjectTypeValue().getValue())
  424. {
  425. createItems();
  426. }
  427. refreshSectionNames();
  428. }
  429. void deleteButtonClicked (const String& name)
  430. {
  431. if (name.startsWith ("config"))
  432. project.deleteConfiguration (name.getTrailingIntValue());
  433. else
  434. project.deleteExporter (name.getTrailingIntValue());
  435. }
  436. static void newExporterMenuItemChosen (int resultCode, ProjectSettingsComponent* settingsComp)
  437. {
  438. if (resultCode > 0 && settingsComp != nullptr)
  439. settingsComp->project.addNewExporter (ProjectExporter::getExporterNames() [resultCode - 1]);
  440. }
  441. void createNewExporter (TextButton& button)
  442. {
  443. PopupMenu menu;
  444. const StringArray exporters (ProjectExporter::getExporterNames());
  445. for (int i = 0; i < exporters.size(); ++i)
  446. menu.addItem (i + 1, "Create a new " + exporters[i] + " target");
  447. menu.showMenuAsync (PopupMenu::Options().withTargetComponent (&button),
  448. ModalCallbackFunction::forComponent (newExporterMenuItemChosen, this));
  449. }
  450. void createNewConfig()
  451. {
  452. project.addNewConfiguration (nullptr);
  453. }
  454. void newItemButtonClicked (TextButton& button)
  455. {
  456. if (button.getName().containsIgnoreCase ("export"))
  457. createNewExporter (button);
  458. else
  459. createNewConfig();
  460. }
  461. private:
  462. //==============================================================================
  463. class PropertyGroup : public Component,
  464. public ButtonListener
  465. {
  466. public:
  467. PropertyGroup()
  468. : deleteButton ("Delete")
  469. {
  470. deleteButton.addListener (this);
  471. }
  472. void addDeleteButton (const String& name, const String& tooltip)
  473. {
  474. addAndMakeVisible (&deleteButton);
  475. deleteButton.setBounds ("right - 55, 11, parent.width - 10, 26");
  476. deleteButton.setColour (TextButton::buttonColourId, Colour (0xa0fcbdbd));
  477. deleteButton.setColour (TextButton::textColourOffId, Colours::darkred);
  478. deleteButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight);
  479. deleteButton.setName (name);
  480. deleteButton.setTooltip (tooltip);
  481. }
  482. void setProperties (const PropertyListBuilder& newProps)
  483. {
  484. properties.clear();
  485. properties.addArray (newProps.components);
  486. for (int i = properties.size(); --i >= 0;)
  487. addAndMakeVisible (properties.getUnchecked(i));
  488. }
  489. int updateSize (int y, int width)
  490. {
  491. int height = 32;
  492. for (int i = 0; i < properties.size(); ++i)
  493. {
  494. PropertyComponent* pp = properties.getUnchecked(i);
  495. pp->setBounds (10, height, width - 20, pp->getPreferredHeight());
  496. height += pp->getHeight();
  497. }
  498. setBounds (0, y, width, height);
  499. return height;
  500. }
  501. void paint (Graphics& g)
  502. {
  503. g.setFont (14.0f, Font::bold);
  504. g.setColour (Colours::black);
  505. g.drawFittedText (getName(), 12, 0, getWidth() - 16, 28, Justification::bottomLeft, 1);
  506. }
  507. void buttonClicked (Button*)
  508. {
  509. ProjectSettingsComponent* psc = findParentComponentOfClass ((ProjectSettingsComponent*) nullptr);
  510. if (psc != nullptr)
  511. psc->deleteButtonClicked (deleteButton.getName());
  512. }
  513. private:
  514. OwnedArray<PropertyComponent> properties;
  515. TextButton deleteButton;
  516. };
  517. //==============================================================================
  518. class PropertyGroupList : public Component,
  519. public ButtonListener
  520. {
  521. public:
  522. PropertyGroupList (const String& title, const String& newButtonText, bool triggerOnMouseDown)
  523. : Component (title), createNewButton (newButtonText)
  524. {
  525. addAndMakeVisible (&createNewButton);
  526. createNewButton.setColour (TextButton::buttonColourId, Colours::lightgreen.withAlpha (0.5f));
  527. createNewButton.setBounds ("right - 140, 30, parent.width - 10, top + 20");
  528. createNewButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight);
  529. createNewButton.addListener (this);
  530. createNewButton.setTriggeredOnMouseDown (triggerOnMouseDown);
  531. }
  532. int updateSize (int ourY, int width)
  533. {
  534. int y = 55;
  535. for (int i = 0; i < groups.size(); ++i)
  536. y += groups.getUnchecked(i)->updateSize (y, width);
  537. y = jmax (y, 100);
  538. setBounds (0, ourY, width, y);
  539. return y;
  540. }
  541. void paint (Graphics& g)
  542. {
  543. g.setFont (17.0f, Font::bold);
  544. g.setColour (Colours::black);
  545. g.drawFittedText (getName(), 0, 30, getWidth(), 20, Justification::centred, 1);
  546. }
  547. void clear()
  548. {
  549. groups.clear();
  550. }
  551. PropertyGroup* createGroup()
  552. {
  553. PropertyGroup* p = new PropertyGroup();
  554. groups.add (p);
  555. addAndMakeVisible (p);
  556. return p;
  557. }
  558. void buttonClicked (Button*)
  559. {
  560. ProjectSettingsComponent* psc = findParentComponentOfClass ((ProjectSettingsComponent*) nullptr);
  561. if (psc != nullptr)
  562. psc->newItemButtonClicked (createNewButton);
  563. }
  564. OwnedArray<PropertyGroup> groups;
  565. TextButton createNewButton;
  566. };
  567. Project& project;
  568. var lastProjectType;
  569. PropertyGroup mainProjectInfoPanel, modulesPanelGroup;
  570. PropertyGroupList configs, exporters;
  571. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectSettingsComponent);
  572. };
  573. //[/MiscUserDefs]
  574. //==============================================================================
  575. ProjectInformationComponent::ProjectInformationComponent (Project& project_)
  576. : project (project_)
  577. {
  578. //[Constructor_pre]
  579. //[/Constructor_pre]
  580. addChildAndSetID (&viewport, "ykdBpb");
  581. addChildAndSetID (&openProjectButton, "a550a652e2666ee7");
  582. addChildAndSetID (&saveAndOpenButton, "dRGMyYx");
  583. addChildAndSetID (&rollover, "QqLJBF");
  584. initialiseComponentState();
  585. openProjectButton.addListener (this);
  586. saveAndOpenButton.addListener (this);
  587. //[UserPreSize]
  588. viewport.setViewedComponent (new ProjectSettingsComponent (project), true);
  589. #if JUCE_MAC || JUCE_WINDOWS
  590. openProjectButton.setCommandToTrigger (commandManager, CommandIDs::openInIDE, true);
  591. openProjectButton.setButtonText (commandManager->getNameOfCommand (CommandIDs::openInIDE));
  592. saveAndOpenButton.setCommandToTrigger (commandManager, CommandIDs::saveAndOpenInIDE, true);
  593. saveAndOpenButton.setButtonText (commandManager->getNameOfCommand (CommandIDs::saveAndOpenInIDE));
  594. #else
  595. openProjectButton.setVisible (false);
  596. saveAndOpenButton.setVisible (false);
  597. #endif
  598. //[/UserPreSize]
  599. setSize (808, 638);
  600. //[Constructor]
  601. project.addChangeListener (this);
  602. //[/Constructor]
  603. }
  604. ProjectInformationComponent::~ProjectInformationComponent()
  605. {
  606. //[Destructor]
  607. project.removeChangeListener (this);
  608. //[/Destructor]
  609. }
  610. //==============================================================================
  611. void ProjectInformationComponent::buttonClicked (Button* buttonThatWasClicked)
  612. {
  613. //[UserbuttonClicked_Pre]
  614. //[/UserbuttonClicked_Pre]
  615. if (buttonThatWasClicked == &openProjectButton)
  616. {
  617. //[UserButtonCode_openProjectButton] -- add your button handler code here..
  618. //[/UserButtonCode_openProjectButton]
  619. }
  620. else if (buttonThatWasClicked == &saveAndOpenButton)
  621. {
  622. //[UserButtonCode_saveAndOpenButton] -- add your button handler code here..
  623. //[/UserButtonCode_saveAndOpenButton]
  624. }
  625. //[UserbuttonClicked_Post]
  626. //[/UserbuttonClicked_Post]
  627. }
  628. void ProjectInformationComponent::paint (Graphics& g)
  629. {
  630. //[UserPaint]
  631. g.setTiledImageFill (ImageCache::getFromMemory (BinaryData::brushed_aluminium_png, BinaryData::brushed_aluminium_pngSize),
  632. 0, 0, 1.0f);
  633. g.fillAll();
  634. drawRecessedShadows (g, getWidth(), getHeight(), 14);
  635. //[/UserPaint]
  636. }
  637. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  638. void ProjectInformationComponent::changeListenerCallback (ChangeBroadcaster*)
  639. {
  640. dynamic_cast<ProjectSettingsComponent*> (viewport.getViewedComponent())->update();
  641. }
  642. //[/MiscUserCode]
  643. //==============================================================================
  644. //======================= Jucer Information Section ==========================
  645. //==============================================================================
  646. #if 0
  647. /* This section stores the metadata for this component - edit it at your own risk!
  648. JUCER_COMPONENT_METADATA_START
  649. <COMPONENT id="tO9EG1a" className="ProjectInformationComponent" width="808"
  650. height="638" background="f6f9ff" parentClasses="public Component, public ChangeListener"
  651. constructorParams="Project&amp; project_" memberInitialisers="project (project_)">
  652. <COMPONENTS>
  653. <VIEWPORT id="ykdBpb" memberName="viewport" position="8, 8, parent.width - 8, parent.height - 74"
  654. scrollBarV="1" scrollBarH="1" scrollbarWidth="16"/>
  655. <TEXTBUTTON id="a550a652e2666ee7" memberName="openProjectButton" focusOrder="0"
  656. text="Open Project in " createCallback="1" radioGroup="0" connectedLeft="0"
  657. connectedRight="0" connectedTop="0" connectedBottom="0" backgroundColour="FFDDDDFF"
  658. textColour="" backgroundColourOn="" textColourOn="" position="8, parent.height - 34, left + 227, top + 24"/>
  659. <TEXTBUTTON id="dRGMyYx" name="" memberName="saveAndOpenButton" position="8, parent.height - 65, left + 227, top + 24"
  660. text="Save And Open in" createCallback="1" radioGroup="0" connectedLeft="0"
  661. connectedRight="0" connectedTop="0" connectedBottom="0" backgroundColour="FFDDDDFF"/>
  662. <GENERICCOMPONENT id="QqLJBF" memberName="rollover" position="246, parent.height - 68, parent.width - 8, parent.height - 4"
  663. class="RolloverHelpComp" canBeAggregated="1" constructorParams=""/>
  664. </COMPONENTS>
  665. <MARKERS_X/>
  666. <MARKERS_Y/>
  667. <METHODS paint="1"/>
  668. </COMPONENT>
  669. JUCER_COMPONENT_METADATA_END
  670. */
  671. #endif
  672. void ProjectInformationComponent::initialiseComponentState()
  673. {
  674. BinaryData::ImageProvider imageProvider;
  675. ComponentBuilder::initialiseFromValueTree (*this, getComponentState(), &imageProvider);
  676. }
  677. ValueTree ProjectInformationComponent::getComponentState()
  678. {
  679. const unsigned char data[] =
  680. "COMPONENT\0\x01\x08id\0\x01\t\x05tO9EG1a\0""className\0\x01\x1d\x05ProjectInformationComponent\0width\0\x01\x05\x05""808\0height\0\x01\x05\x05""638\0""background\0\x01\x08\x05""f6f9ff\0parentClasses\0\x01)\x05public Component, public ChangeListener\0"
  681. "constructorParams\0\x01\x13\x05Project& project_\0memberInitialisers\0\x01\x14\x05project (project_)\0\x01\x04""COMPONENTS\0\0\x01\x04VIEWPORT\0\x01\x06id\0\x01\x08\x05ykdBpb\0memberName\0\x01\n\x05viewport\0position\0\x01,\x05""8, 8, parent.width - "
  682. "8, parent.height - 74\0scrollBarV\0\x01\x03\x05""1\0scrollBarH\0\x01\x03\x05""1\0scrollbarWidth\0\x01\x04\x05""16\0\0TEXTBUTTON\0\x01\x0fid\0\x01\x12\x05""a550a652e2666ee7\0memberName\0\x01\x13\x05openProjectButton\0""focusOrder\0\x01\x03\x05""0\0tex"
  683. "t\0\x01\x12\x05Open Project in \0""createCallback\0\x01\x03\x05""1\0radioGroup\0\x01\x03\x05""0\0""connectedLeft\0\x01\x03\x05""0\0""connectedRight\0\x01\x03\x05""0\0""connectedTop\0\x01\x03\x05""0\0""connectedBottom\0\x01\x03\x05""0\0""backgroundCol"
  684. "our\0\x01\n\x05""FFDDDDFF\0textColour\0\x01\x02\x05\0""backgroundColourOn\0\x01\x02\x05\0textColourOn\0\x01\x02\x05\0position\0\x01-\x05""8, parent.height - 34, left + 227, top + 24\0\0TEXTBUTTON\0\x01\x0cid\0\x01\t\x05""dRGMyYx\0name\0\x01\x02\x05\0"
  685. "memberName\0\x01\x13\x05saveAndOpenButton\0position\0\x01-\x05""8, parent.height - 65, left + 227, top + 24\0text\0\x01\x12\x05Save And Open in\0""createCallback\0\x01\x03\x05""1\0radioGroup\0\x01\x03\x05""0\0""connectedLeft\0\x01\x03\x05""0\0""conne"
  686. "ctedRight\0\x01\x03\x05""0\0""connectedTop\0\x01\x03\x05""0\0""connectedBottom\0\x01\x03\x05""0\0""backgroundColour\0\x01\n\x05""FFDDDDFF\0\0GENERICCOMPONENT\0\x01\x06id\0\x01\x08\x05QqLJBF\0memberName\0\x01\n\x05rollover\0position\0\x01>\x05""246, p"
  687. "arent.height - 68, parent.width - 8, parent.height - 4\0""class\0\x01\x12\x05RolloverHelpComp\0""canBeAggregated\0\x01\x03\x05""1\0""constructorParams\0\x01\x02\x05\0\0MARKERS_X\0\0\0MARKERS_Y\0\0\0METHODS\0\x01\x01paint\0\x01\x03\x05""1\0\0";
  688. return ValueTree::readFromData (data, sizeof (data));
  689. }