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.

117 lines
3.4KB

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