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.

159 lines
5.0KB

  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 = 38;
  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. const Colour bkg (findColour (mainBackgroundColourId));
  52. g.setColour (Colours::white.withAlpha (0.35f));
  53. g.fillRect (0, 30, getWidth(), getHeight() - 38);
  54. g.setFont (Font (15.0f, Font::bold));
  55. g.setColour (bkg.contrasting (0.7f));
  56. g.drawFittedText (getName(), 12, 0, getWidth() - 16, 25, Justification::bottomLeft, 1);
  57. }
  58. OwnedArray<PropertyComponent> properties;
  59. private:
  60. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyGroup);
  61. };
  62. //==============================================================================
  63. class PropertyPanelViewport : public Component
  64. {
  65. public:
  66. PropertyPanelViewport (Component* content)
  67. {
  68. addAndMakeVisible (&viewport);
  69. addAndMakeVisible (&rolloverHelp);
  70. viewport.setViewedComponent (content, true);
  71. }
  72. void paint (Graphics& g)
  73. {
  74. IntrojucerLookAndFeel::fillWithBackgroundTexture (*this, g);
  75. }
  76. void resized()
  77. {
  78. Rectangle<int> r (getLocalBounds());
  79. rolloverHelp.setBounds (r.removeFromBottom (70).reduced (10, 0));
  80. viewport.setBounds (r);
  81. }
  82. Viewport viewport;
  83. RolloverHelpComp rolloverHelp;
  84. private:
  85. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyPanelViewport);
  86. };
  87. //==============================================================================
  88. class SettingsTreeViewItemBase : public JucerTreeViewBase,
  89. public ValueTree::Listener
  90. {
  91. public:
  92. SettingsTreeViewItemBase() {}
  93. void showSettingsPage (Component* content);
  94. void closeSettingsPage();
  95. void deleteAllSelectedItems()
  96. {
  97. TreeView* const tree = getOwnerView();
  98. jassert (tree->getNumSelectedItems() <= 1); // multi-select should be disabled
  99. if (SettingsTreeViewItemBase* s = dynamic_cast <SettingsTreeViewItemBase*> (tree->getSelectedItem (0)))
  100. s->deleteItem();
  101. }
  102. void itemOpennessChanged (bool isNowOpen)
  103. {
  104. if (isNowOpen)
  105. refreshSubItems();
  106. }
  107. void valueTreePropertyChanged (ValueTree&, const Identifier&) {}
  108. void valueTreeChildAdded (ValueTree&, ValueTree&) {}
  109. void valueTreeChildRemoved (ValueTree&, ValueTree&) {}
  110. void valueTreeChildOrderChanged (ValueTree&) {}
  111. void valueTreeParentChanged (ValueTree&) {}
  112. static void updateSize (Component& comp, PropertyGroup& group)
  113. {
  114. const int width = jmax (550, comp.getParentWidth() - 20);
  115. int y = 0;
  116. y += group.updateSize (12, y, width - 12);
  117. comp.setSize (width, y);
  118. }
  119. };
  120. #endif // __JUCER_PROJECTINFORMATIONCOMPONENT_H_30FFCD07__