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.

120 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  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& 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. auto numSelected = layout.getSelectedSet().getNumSelected();
  83. if (numSelected > 0) // xxx need to cope with multiple
  84. {
  85. if (auto* comp = layout.getSelectedSet().getSelectedItem (0))
  86. if (auto* type = ComponentTypeHandler::getHandlerFor (*comp))
  87. type->addPropertiesToPropertyPanel (comp, document, propsPanel, numSelected > 1);
  88. }
  89. }
  90. private:
  91. JucerDocument& document;
  92. ComponentLayout& layout;
  93. PropertyPanel propsPanel;
  94. };
  95. };