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.

juce_RelativeCoordinatePositioner.h 3.2KB

9 years ago
9 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_RELATIVECOORDINATEPOSITIONER_H_INCLUDED
  18. #define JUCE_RELATIVECOORDINATEPOSITIONER_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. Base class for Component::Positioners that are based upon relative coordinates.
  22. */
  23. class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner,
  24. public ComponentListener,
  25. public MarkerList::Listener
  26. {
  27. public:
  28. RelativeCoordinatePositionerBase (Component& component);
  29. ~RelativeCoordinatePositionerBase();
  30. void componentMovedOrResized (Component&, bool, bool);
  31. void componentParentHierarchyChanged (Component&);
  32. void componentChildrenChanged (Component&);
  33. void componentBeingDeleted (Component&);
  34. void markersChanged (MarkerList*);
  35. void markerListBeingDeleted (MarkerList* markerList);
  36. void apply();
  37. bool addCoordinate (const RelativeCoordinate& coord);
  38. bool addPoint (const RelativePoint& point);
  39. //==============================================================================
  40. /** Used for resolving a RelativeCoordinate expression in the context of a component. */
  41. class ComponentScope : public Expression::Scope
  42. {
  43. public:
  44. ComponentScope (Component& component);
  45. Expression getSymbolValue (const String& symbol) const;
  46. void visitRelativeScope (const String& scopeName, Visitor& visitor) const;
  47. String getScopeUID() const;
  48. protected:
  49. Component& component;
  50. Component* findSiblingComponent (const String& componentID) const;
  51. private:
  52. JUCE_DECLARE_NON_COPYABLE (ComponentScope)
  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& comp);
  64. void registerMarkerListListener (MarkerList* const list);
  65. void unregisterListeners();
  66. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase)
  67. };
  68. #endif // JUCE_RELATIVECOORDINATEPOSITIONER_H_INCLUDED