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.

158 lines
4.9KB

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