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.

84 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 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_RelativeCoordinate.h"
  21. #include "juce_MarkerList.h"
  22. #include "../juce_Component.h"
  23. //==============================================================================
  24. /**
  25. Base class for Component::Positioners that are based upon relative coordinates.
  26. */
  27. class RelativeCoordinatePositionerBase : public Component::Positioner,
  28. public ComponentListener,
  29. public MarkerList::Listener,
  30. public Expression::EvaluationContext
  31. {
  32. public:
  33. RelativeCoordinatePositionerBase (Component& component_);
  34. ~RelativeCoordinatePositionerBase();
  35. const Expression getSymbolValue (const String& objectName, const String& member) const;
  36. void componentMovedOrResized (Component&, bool, bool);
  37. void componentParentHierarchyChanged (Component&);
  38. void componentBeingDeleted (Component& component);
  39. void markersChanged (MarkerList*);
  40. void markerListBeingDeleted (MarkerList* markerList);
  41. void apply();
  42. protected:
  43. bool addCoordinate (const RelativeCoordinate& coord);
  44. virtual bool registerCoordinates() = 0;
  45. virtual void applyToComponentBounds() = 0;
  46. private:
  47. Array <Component*> sourceComponents;
  48. Array <MarkerList*> sourceMarkerLists;
  49. bool registeredOk;
  50. bool registerListeners (const Expression& e);
  51. bool registerComponent (const String& componentID);
  52. bool registerMarker (const String markerName);
  53. void registerComponentListener (Component* const comp);
  54. void registerMarkerListListener (MarkerList* const list);
  55. void unregisterListeners();
  56. Component* findComponent (const String& componentID) const;
  57. Component* getSourceComponent (const String& objectName) const;
  58. const Expression xToExpression (const Component* const source, const int x) const;
  59. const Expression yToExpression (const Component* const source, const int y) const;
  60. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase);
  61. };
  62. #endif // __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__