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.

93 lines
3.1KB

  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. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. Base class for Component::Positioners that are based upon relative coordinates.
  24. */
  25. class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner,
  26. public ComponentListener,
  27. public MarkerList::Listener
  28. {
  29. public:
  30. RelativeCoordinatePositionerBase (Component&);
  31. ~RelativeCoordinatePositionerBase();
  32. void componentMovedOrResized (Component&, bool, bool);
  33. void componentParentHierarchyChanged (Component&);
  34. void componentChildrenChanged (Component&);
  35. void componentBeingDeleted (Component&);
  36. void markersChanged (MarkerList*);
  37. void markerListBeingDeleted (MarkerList*);
  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. // Suppress a VS2013 compiler warning
  48. ComponentScope& operator= (const ComponentScope&) = delete;
  49. Expression getSymbolValue (const String& symbol) const;
  50. void visitRelativeScope (const String& scopeName, Visitor&) const;
  51. String getScopeUID() const;
  52. protected:
  53. Component& component;
  54. Component* findSiblingComponent (const String& componentID) const;
  55. };
  56. protected:
  57. virtual bool registerCoordinates() = 0;
  58. virtual void applyToComponentBounds() = 0;
  59. private:
  60. class DependencyFinderScope;
  61. friend class DependencyFinderScope;
  62. Array<Component*> sourceComponents;
  63. Array<MarkerList*> sourceMarkerLists;
  64. bool registeredOk;
  65. void registerComponentListener (Component&);
  66. void registerMarkerListListener (MarkerList*);
  67. void unregisterListeners();
  68. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase)
  69. };
  70. } // namespace juce