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.

125 lines
3.8KB

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