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.

84 lines
2.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. /**
  17. Base class for Component::Positioners that are based upon relative coordinates.
  18. @tags{GUI}
  19. */
  20. class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner,
  21. public ComponentListener,
  22. public MarkerList::Listener
  23. {
  24. public:
  25. RelativeCoordinatePositionerBase (Component&);
  26. ~RelativeCoordinatePositionerBase() override;
  27. void componentMovedOrResized (Component&, bool, bool) override;
  28. void componentParentHierarchyChanged (Component&) override;
  29. void componentChildrenChanged (Component&) override;
  30. void componentBeingDeleted (Component&) override;
  31. void markersChanged (MarkerList*) override;
  32. void markerListBeingDeleted (MarkerList*) override;
  33. void apply();
  34. bool addCoordinate (const RelativeCoordinate&);
  35. bool addPoint (const RelativePoint&);
  36. //==============================================================================
  37. /** Used for resolving a RelativeCoordinate expression in the context of a component. */
  38. class ComponentScope : public Expression::Scope
  39. {
  40. public:
  41. ComponentScope (Component&);
  42. Expression getSymbolValue (const String& symbol) const override;
  43. void visitRelativeScope (const String& scopeName, Visitor&) const override;
  44. String getScopeUID() const override;
  45. protected:
  46. Component& component;
  47. Component* findSiblingComponent (const String& componentID) const;
  48. };
  49. protected:
  50. virtual bool registerCoordinates() = 0;
  51. virtual void applyToComponentBounds() = 0;
  52. private:
  53. class DependencyFinderScope;
  54. friend class DependencyFinderScope;
  55. Array<Component*> sourceComponents;
  56. Array<MarkerList*> sourceMarkerLists;
  57. bool registeredOk;
  58. void registerComponentListener (Component&);
  59. void registerMarkerListListener (MarkerList*);
  60. void unregisterListeners();
  61. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase)
  62. };
  63. } // namespace juce