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.

89 lines
3.1KB

  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. #pragma once
  18. //==============================================================================
  19. /**
  20. Base class for Component::Positioners that are based upon relative coordinates.
  21. */
  22. class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner,
  23. public ComponentListener,
  24. public MarkerList::Listener
  25. {
  26. public:
  27. RelativeCoordinatePositionerBase (Component& component);
  28. ~RelativeCoordinatePositionerBase();
  29. void componentMovedOrResized (Component&, bool, bool);
  30. void componentParentHierarchyChanged (Component&);
  31. void componentChildrenChanged (Component&);
  32. void componentBeingDeleted (Component&);
  33. void markersChanged (MarkerList*);
  34. void markerListBeingDeleted (MarkerList* markerList);
  35. void apply();
  36. bool addCoordinate (const RelativeCoordinate& coord);
  37. bool addPoint (const RelativePoint& point);
  38. //==============================================================================
  39. /** Used for resolving a RelativeCoordinate expression in the context of a component. */
  40. class ComponentScope : public Expression::Scope
  41. {
  42. public:
  43. ComponentScope (Component& component);
  44. Expression getSymbolValue (const String& symbol) const;
  45. void visitRelativeScope (const String& scopeName, Visitor& visitor) const;
  46. String getScopeUID() const;
  47. protected:
  48. Component& component;
  49. Component* findSiblingComponent (const String& componentID) const;
  50. private:
  51. JUCE_DECLARE_NON_COPYABLE (ComponentScope)
  52. };
  53. protected:
  54. virtual bool registerCoordinates() = 0;
  55. virtual void applyToComponentBounds() = 0;
  56. private:
  57. class DependencyFinderScope;
  58. friend class DependencyFinderScope;
  59. Array <Component*> sourceComponents;
  60. Array <MarkerList*> sourceMarkerLists;
  61. bool registeredOk;
  62. void registerComponentListener (Component& comp);
  63. void registerMarkerListListener (MarkerList* const list);
  64. void unregisterListeners();
  65. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase)
  66. };