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.

119 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  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& layout;
  50. private:
  51. class LayoutPropsPanel : public Component,
  52. private 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() override
  62. {
  63. layout.getSelectedSet().removeChangeListener (this);
  64. clear();
  65. }
  66. void resized() override
  67. {
  68. propsPanel.setBounds (4, 4, getWidth() - 8, getHeight() - 8);
  69. }
  70. void clear()
  71. {
  72. propsPanel.clear();
  73. }
  74. void updateList()
  75. {
  76. clear();
  77. auto numSelected = layout.getSelectedSet().getNumSelected();
  78. if (numSelected > 0) // xxx need to cope with multiple
  79. {
  80. if (auto* comp = layout.getSelectedSet().getSelectedItem (0))
  81. if (auto* type = ComponentTypeHandler::getHandlerFor (*comp))
  82. type->addPropertiesToPropertyPanel (comp, document, propsPanel, numSelected > 1);
  83. }
  84. }
  85. private:
  86. void changeListenerCallback (ChangeBroadcaster*) override
  87. {
  88. updateList();
  89. }
  90. JucerDocument& document;
  91. ComponentLayout& layout;
  92. PropertyPanel propsPanel;
  93. };
  94. };