35 jassert (componentToDrag !=
nullptr);
38 if (componentToDrag !=
nullptr)
45 jassert (componentToDrag !=
nullptr);
48 if (componentToDrag !=
nullptr)
50 auto bounds = componentToDrag->
getBounds();
60 if (constrainer !=
nullptr)
A class that imposes restrictions on a Component's size or position.
void setBoundsForComponent(Component *component, Rectangle< int > bounds, bool isStretchingTop, bool isStretchingLeft, bool isStretchingBottom, bool isStretchingRight)
Checks the given bounds, and then sets the component to the corrected size.
ComponentDragger()
Creates a ComponentDragger.
void dragComponent(Component *componentToDrag, const MouseEvent &e, ComponentBoundsConstrainer *constrainer)
Call this from your mouseDrag() callback to move the component.
void startDraggingComponent(Component *componentToDrag, const MouseEvent &e)
Call this from your component's mouseDown() method, to prepare for dragging.
virtual ~ComponentDragger()
Destructor.
The base class for all JUCE user-interface objects.
Point< int > getLocalPoint(const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Converts a point to be relative to this component's coordinate space.
Rectangle< int > getBounds() const noexcept
Returns this component's bounding box.
bool isOnDesktop() const noexcept
Returns true if this component is currently showing on the desktop.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
bool isAnyMouseButtonDown() const noexcept
Tests for any of the mouse-button flags.
Contains position and status information about a mouse event.
const ModifierKeys mods
The key modifiers associated with the event.
MouseInputSource source
The source device that generated this event.
Point< int > getPosition() const noexcept
The position of the mouse when the event occurred.
Point< int > getMouseDownPosition() const noexcept
Returns the coordinates of the last place that a mouse was pressed.
MouseEvent getEventRelativeTo(Component *newComponent) const noexcept
Creates a version of this event that is relative to a different component.
constexpr Point< int > roundToInt() const noexcept
Casts this point to a Point<int> object using roundToInt() to convert the values.