Audio plugin host https://kx.studio/carla
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.

91 lines
3.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. Base class for Component::Positioners that are based upon relative coordinates.
  23. @tags{GUI}
  24. */
  25. class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner,
  26. public ComponentListener,
  27. public MarkerList::Listener
  28. {
  29. public:
  30. RelativeCoordinatePositionerBase (Component&);
  31. ~RelativeCoordinatePositionerBase() override;
  32. void componentMovedOrResized (Component&, bool, bool) override;
  33. void componentParentHierarchyChanged (Component&) override;
  34. void componentChildrenChanged (Component&) override;
  35. void componentBeingDeleted (Component&) override;
  36. void markersChanged (MarkerList*) override;
  37. void markerListBeingDeleted (MarkerList*) override;
  38. void apply();
  39. bool addCoordinate (const RelativeCoordinate&);
  40. bool addPoint (const RelativePoint&);
  41. //==============================================================================
  42. /** Used for resolving a RelativeCoordinate expression in the context of a component. */
  43. class ComponentScope : public Expression::Scope
  44. {
  45. public:
  46. ComponentScope (Component&);
  47. Expression getSymbolValue (const String& symbol) const override;
  48. void visitRelativeScope (const String& scopeName, Visitor&) const override;
  49. String getScopeUID() const override;
  50. protected:
  51. Component& component;
  52. Component* findSiblingComponent (const String& componentID) const;
  53. };
  54. protected:
  55. virtual bool registerCoordinates() = 0;
  56. virtual void applyToComponentBounds() = 0;
  57. private:
  58. class DependencyFinderScope;
  59. friend class DependencyFinderScope;
  60. Array<Component*> sourceComponents;
  61. Array<MarkerList*> sourceMarkerLists;
  62. bool registeredOk;
  63. void registerComponentListener (Component&);
  64. void registerMarkerListListener (MarkerList*);
  65. void unregisterListeners();
  66. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase)
  67. };
  68. } // namespace juce