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.

124 lines
3.6KB

  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_COMPONENTLAYOUTPANEL_JUCEHEADER__
  18. #define __JUCER_COMPONENTLAYOUTPANEL_JUCEHEADER__
  19. #include "jucer_ComponentLayoutEditor.h"
  20. #include "jucer_EditingPanelBase.h"
  21. //==============================================================================
  22. class ComponentLayoutPanel : public EditingPanelBase
  23. {
  24. public:
  25. //==============================================================================
  26. ComponentLayoutPanel (JucerDocument& doc, ComponentLayout& l)
  27. : EditingPanelBase (doc,
  28. new LayoutPropsPanel (doc, l),
  29. new ComponentLayoutEditor (doc, l)),
  30. layout (l)
  31. {
  32. }
  33. ~ComponentLayoutPanel()
  34. {
  35. deleteAllChildren();
  36. }
  37. void updatePropertiesList()
  38. {
  39. ((LayoutPropsPanel*) propsPanel)->updateList();
  40. }
  41. Rectangle<int> getComponentArea() const
  42. {
  43. return ((ComponentLayoutEditor*) editor)->getComponentArea();
  44. }
  45. Image createComponentSnapshot() const
  46. {
  47. return ((ComponentLayoutEditor*) editor)->createComponentLayerSnapshot();
  48. }
  49. ComponentLayout& getLayout() const noexcept { return layout;}
  50. private:
  51. class LayoutPropsPanel : public Component,
  52. public ChangeListener
  53. {
  54. public:
  55. LayoutPropsPanel (JucerDocument& doc, ComponentLayout& l)
  56. : document (doc), layout (l)
  57. {
  58. layout.getSelectedSet().addChangeListener (this);
  59. addAndMakeVisible (&propsPanel);
  60. }
  61. ~LayoutPropsPanel()
  62. {
  63. layout.getSelectedSet().removeChangeListener (this);
  64. clear();
  65. }
  66. void resized()
  67. {
  68. propsPanel.setBounds (4, 4, getWidth() - 8, getHeight() - 8);
  69. }
  70. void changeListenerCallback (ChangeBroadcaster*)
  71. {
  72. updateList();
  73. }
  74. void clear()
  75. {
  76. propsPanel.clear();
  77. }
  78. void updateList()
  79. {
  80. clear();
  81. if (layout.getSelectedSet().getNumSelected() == 1) // xxx need to cope with multiple
  82. {
  83. if (Component* comp = layout.getSelectedSet().getSelectedItem (0))
  84. if (ComponentTypeHandler* const type = ComponentTypeHandler::getHandlerFor (*comp))
  85. type->addPropertiesToPropertyPanel (comp, document, propsPanel);
  86. }
  87. }
  88. private:
  89. JucerDocument& document;
  90. ComponentLayout& layout;
  91. PropertyPanel propsPanel;
  92. };
  93. ComponentLayout& layout;
  94. };
  95. #endif // __JUCER_COMPONENTLAYOUTPANEL_JUCEHEADER__