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.

164 lines
5.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCER_PROJECTINFORMATIONCOMPONENT_H_30FFCD07__
  19. #define __JUCER_PROJECTINFORMATIONCOMPONENT_H_30FFCD07__
  20. #include "jucer_Project.h"
  21. #include "../Utility/jucer_JucerTreeViewBase.h"
  22. //==============================================================================
  23. JucerTreeViewBase* createProjectConfigTreeViewRoot (Project& project);
  24. //==============================================================================
  25. class PropertyGroup : public Component
  26. {
  27. public:
  28. PropertyGroup() {}
  29. void setProperties (const PropertyListBuilder& newProps)
  30. {
  31. properties.clear();
  32. properties.addArray (newProps.components);
  33. for (int i = properties.size(); --i >= 0;)
  34. addAndMakeVisible (properties.getUnchecked(i));
  35. }
  36. int updateSize (int x, int y, int width)
  37. {
  38. int height = 36;
  39. for (int i = 0; i < properties.size(); ++i)
  40. {
  41. PropertyComponent* pp = properties.getUnchecked(i);
  42. pp->setBounds (10, height, width - 20, pp->getPreferredHeight());
  43. height += pp->getHeight();
  44. }
  45. height += 16;
  46. setBounds (x, y, width, height);
  47. return height;
  48. }
  49. void paint (Graphics& g)
  50. {
  51. g.setColour (Colours::white.withAlpha (0.3f));
  52. g.fillRect (0, 28, getWidth(), getHeight() - 38);
  53. g.setColour (Colours::black.withAlpha (0.4f));
  54. g.drawRect (0, 28, getWidth(), getHeight() - 38);
  55. g.setFont (Font (14.0f, Font::bold));
  56. g.setColour (Colours::black);
  57. g.drawFittedText (getName(), 12, 0, getWidth() - 16, 26, Justification::bottomLeft, 1);
  58. }
  59. OwnedArray<PropertyComponent> properties;
  60. private:
  61. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyGroup);
  62. };
  63. //==============================================================================
  64. class PropertyPanelViewport : public Component
  65. {
  66. public:
  67. PropertyPanelViewport (Component* content)
  68. {
  69. addAndMakeVisible (&viewport);
  70. addAndMakeVisible (&rolloverHelp);
  71. viewport.setViewedComponent (content, true);
  72. }
  73. void paint (Graphics& g)
  74. {
  75. g.setTiledImageFill (ImageCache::getFromMemory (BinaryData::brushed_aluminium_png,
  76. BinaryData::brushed_aluminium_pngSize),
  77. 0, 0, 1.0f);
  78. g.fillAll();
  79. drawRecessedShadows (g, getWidth(), getHeight(), 14);
  80. }
  81. void resized()
  82. {
  83. Rectangle<int> r (getLocalBounds());
  84. rolloverHelp.setBounds (r.removeFromBottom (70).reduced (10, 0));
  85. viewport.setBounds (r);
  86. }
  87. Viewport viewport;
  88. RolloverHelpComp rolloverHelp;
  89. private:
  90. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyPanelViewport);
  91. };
  92. //==============================================================================
  93. class SettingsTreeViewItemBase : public JucerTreeViewBase,
  94. public ValueTree::Listener
  95. {
  96. public:
  97. SettingsTreeViewItemBase() {}
  98. void showSettingsPage (Component* content);
  99. void closeSettingsPage();
  100. void deleteAllSelectedItems()
  101. {
  102. TreeView* const tree = getOwnerView();
  103. jassert (tree->getNumSelectedItems() <= 1); // multi-select should be disabled
  104. if (SettingsTreeViewItemBase* s = dynamic_cast <SettingsTreeViewItemBase*> (tree->getSelectedItem (0)))
  105. s->deleteItem();
  106. }
  107. void itemOpennessChanged (bool isNowOpen)
  108. {
  109. if (isNowOpen)
  110. refreshSubItems();
  111. }
  112. void valueTreePropertyChanged (ValueTree&, const Identifier&) {}
  113. void valueTreeChildAdded (ValueTree&, ValueTree&) {}
  114. void valueTreeChildRemoved (ValueTree&, ValueTree&) {}
  115. void valueTreeChildOrderChanged (ValueTree&) {}
  116. void valueTreeParentChanged (ValueTree&) {}
  117. static void updateSize (Component& comp, PropertyGroup& group)
  118. {
  119. const int width = jmax (550, comp.getParentWidth() - 20);
  120. int y = 0;
  121. y += group.updateSize (12, y, width - 12);
  122. comp.setSize (width, y);
  123. }
  124. };
  125. #endif // __JUCER_PROJECTINFORMATIONCOMPONENT_H_30FFCD07__