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.

98 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__
  19. #define __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__
  20. #include "juce_RelativePoint.h"
  21. #include "juce_MarkerList.h"
  22. #include "../components/juce_Component.h"
  23. //==============================================================================
  24. /**
  25. Base class for Component::Positioners that are based upon relative coordinates.
  26. */
  27. class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner,
  28. public ComponentListener,
  29. public MarkerList::Listener
  30. {
  31. public:
  32. RelativeCoordinatePositionerBase (Component& component_);
  33. ~RelativeCoordinatePositionerBase();
  34. void componentMovedOrResized (Component&, bool, bool);
  35. void componentParentHierarchyChanged (Component&);
  36. void componentChildrenChanged (Component& component);
  37. void componentBeingDeleted (Component& component);
  38. void markersChanged (MarkerList*);
  39. void markerListBeingDeleted (MarkerList* markerList);
  40. void apply();
  41. bool addCoordinate (const RelativeCoordinate& coord);
  42. bool addPoint (const RelativePoint& point);
  43. //==============================================================================
  44. /** Used for resolving a RelativeCoordinate expression in the context of a component. */
  45. class ComponentScope : public Expression::Scope
  46. {
  47. public:
  48. ComponentScope (Component& component_);
  49. Expression getSymbolValue (const String& symbol) const;
  50. void visitRelativeScope (const String& scopeName, Visitor& visitor) const;
  51. String getScopeUID() const;
  52. protected:
  53. Component& component;
  54. Component* findSiblingComponent (const String& componentID) const;
  55. private:
  56. JUCE_DECLARE_NON_COPYABLE (ComponentScope);
  57. };
  58. protected:
  59. virtual bool registerCoordinates() = 0;
  60. virtual void applyToComponentBounds() = 0;
  61. private:
  62. class DependencyFinderScope;
  63. friend class DependencyFinderScope;
  64. Array <Component*> sourceComponents;
  65. Array <MarkerList*> sourceMarkerLists;
  66. bool registeredOk;
  67. void registerComponentListener (Component& comp);
  68. void registerMarkerListListener (MarkerList* const list);
  69. void unregisterListeners();
  70. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase);
  71. };
  72. #endif // __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__