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.

97 lines
3.4KB

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