JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_DragAndDropContainer.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29bool juce_performDragDropFiles (const StringArray&, const bool copyFiles, bool& shouldStop);
30bool juce_performDragDropText (const String&, bool& shouldStop);
31
32
33//==============================================================================
35 private Timer
36{
37public:
39 const var& desc,
40 Component* const sourceComponent,
43 Point<int> offset)
44 : sourceDetails (desc, sourceComponent, Point<int>()),
45 image (im),
46 owner (ddc),
47 mouseDragSource (draggingSource->getComponentUnderMouse()),
48 imageOffset (transformOffsetCoordinates (sourceComponent, offset)),
49 originalInputSourceIndex (draggingSource->getIndex()),
50 originalInputSourceType (draggingSource->getType())
51 {
52 updateSize();
53
54 if (mouseDragSource == nullptr)
55 mouseDragSource = sourceComponent;
56
57 mouseDragSource->addMouseListener (this, false);
58
59 startTimer (200);
60
61 setInterceptsMouseClicks (false, false);
63 setAlwaysOnTop (true);
64 }
65
66 ~DragImageComponent() override
67 {
68 owner.dragImageComponents.remove (owner.dragImageComponents.indexOf (this), false);
69
70 if (mouseDragSource != nullptr)
71 {
72 mouseDragSource->removeMouseListener (this);
73
74 if (auto* current = getCurrentlyOver())
75 if (current->isInterestedInDragSource (sourceDetails))
76 current->itemDragExit (sourceDetails);
77 }
78
79 owner.dragOperationEnded (sourceDetails);
80 }
81
82 void paint (Graphics& g) override
83 {
84 if (isOpaque())
85 g.fillAll (Colours::white);
86
87 g.setOpacity (1.0f);
88 g.drawImage (image.getImage(), getLocalBounds().toFloat());
89 }
90
91 void mouseUp (const MouseEvent& e) override
92 {
93 if (e.originalComponent != this && isOriginalInputSource (e.source))
94 {
95 if (mouseDragSource != nullptr)
96 mouseDragSource->removeMouseListener (this);
97
98 // (note: use a local copy of this in case the callback runs
99 // a modal loop and deletes this object before the method completes)
100 auto details = sourceDetails;
101
102 auto wasVisible = isVisible();
103 setVisible (false);
104 const auto [finalTarget, unused, localPosition] = findTarget (e.getScreenPosition());
106 details.localPosition = localPosition;
107
108 if (wasVisible) // fade the component and remove it - it'll be deleted later by the timer callback
109 dismissWithAnimation (finalTarget == nullptr);
110
111 if (auto* parent = getParentComponent())
112 parent->removeChildComponent (this);
113
114 if (finalTarget != nullptr)
115 {
116 currentlyOverComp = nullptr;
117 finalTarget->itemDropped (details);
118 }
119
120 // careful - this object could now be deleted..
121 }
122 }
123
124 void mouseDrag (const MouseEvent& e) override
125 {
126 if (e.originalComponent != this && isOriginalInputSource (e.source))
127 updateLocation (true, e.getScreenPosition());
128 }
129
130 void updateLocation (const bool canDoExternalDrag, Point<int> screenPos)
131 {
132 auto details = sourceDetails;
133
134 setNewScreenPos (screenPos);
135
136 const auto [newTarget, newTargetComp, localPosition] = findTarget (screenPos);
137 details.localPosition = localPosition;
138
139 setVisible (newTarget == nullptr || newTarget->shouldDrawDragImageWhenOver());
140
141 maintainKeyboardFocusWhenPossible();
142
143 if (newTargetComp != currentlyOverComp)
144 {
145 if (auto* lastTarget = getCurrentlyOver())
146 if (details.sourceComponent != nullptr && lastTarget->isInterestedInDragSource (details))
147 lastTarget->itemDragExit (details);
148
149 currentlyOverComp = newTargetComp;
150
151 if (newTarget != nullptr
152 && newTarget->isInterestedInDragSource (details))
153 newTarget->itemDragEnter (details);
154 }
155
156 sendDragMove (details);
157
159 {
160 auto now = Time::getCurrentTime();
161
162 if (getCurrentlyOver() != nullptr)
163 lastTimeOverTarget = now;
164 else if (now > lastTimeOverTarget + RelativeTime::milliseconds (700))
165 checkForExternalDrag (details, screenPos);
166 }
167
168 forceMouseCursorUpdate();
169 }
170
171 void updateImage (const ScaledImage& newImage)
172 {
173 image = newImage;
174 updateSize();
175 repaint();
176 }
177
178 void timerCallback() override
179 {
180 forceMouseCursorUpdate();
181
182 if (sourceDetails.sourceComponent == nullptr)
183 {
184 deleteSelf();
185 }
186 else
187 {
188 for (auto& s : Desktop::getInstance().getMouseSources())
189 {
190 if (isOriginalInputSource (s) && ! s.isDragging())
191 {
192 if (mouseDragSource != nullptr)
193 mouseDragSource->removeMouseListener (this);
194
195 deleteSelf();
196 break;
197 }
198 }
199 }
200 }
201
202 bool keyPressed (const KeyPress& key) override
203 {
204 if (key == KeyPress::escapeKey)
205 {
206 const auto wasVisible = isVisible();
207 setVisible (false);
208
209 if (wasVisible)
210 dismissWithAnimation (true);
211
212 deleteSelf();
213 return true;
214 }
215
216 return false;
217 }
218
219 bool canModalEventBeSentToComponent (const Component* targetComponent) override
220 {
221 return targetComponent == mouseDragSource;
222 }
223
224 // (overridden to avoid beeps when dragging)
225 void inputAttemptWhenModal() override {}
226
228
229private:
230 ScaledImage image;
232 WeakReference<Component> mouseDragSource, currentlyOverComp;
233 const Point<int> imageOffset;
234 bool hasCheckedForExternalDrag = false;
235 Time lastTimeOverTarget;
236 int originalInputSourceIndex;
237 MouseInputSource::InputSourceType originalInputSourceType;
238 bool canHaveKeyboardFocus = false;
239
240 void maintainKeyboardFocusWhenPossible()
241 {
242 const auto newCanHaveKeyboardFocus = isVisible();
243
245 if (canHaveKeyboardFocus)
247 }
248
249 void updateSize()
250 {
251 const auto bounds = image.getScaledBounds().toNearestInt();
252 setSize (bounds.getWidth(), bounds.getHeight());
253 }
254
255 void forceMouseCursorUpdate()
256 {
258 }
259
260 DragAndDropTarget* getCurrentlyOver() const noexcept
261 {
262 return dynamic_cast<DragAndDropTarget*> (currentlyOverComp.get());
263 }
264
265 static Component* findDesktopComponentBelow (Point<int> screenPos)
266 {
268
269 for (auto i = desktop.getNumComponents(); --i >= 0;)
270 {
271 auto* desktopComponent = desktop.getComponent (i);
272 auto dPoint = desktopComponent->getLocalPoint (nullptr, screenPos);
273
274 if (auto* c = desktopComponent->getComponentAt (dPoint))
275 {
276 auto cPoint = c->getLocalPoint (desktopComponent, dPoint);
277
278 if (c->hitTest (cPoint.getX(), cPoint.getY()))
279 return c;
280 }
281 }
282
283 return nullptr;
284 }
285
286 Point<int> transformOffsetCoordinates (const Component* const sourceComponent, Point<int> offsetInSource) const
287 {
288 return getLocalPoint (sourceComponent, offsetInSource) - getLocalPoint (sourceComponent, Point<int>());
289 }
290
292 {
293 auto* hit = getParentComponent();
294
295 if (hit == nullptr)
296 hit = findDesktopComponentBelow (screenPos);
297 else
298 hit = hit->getComponentAt (hit->getLocalPoint (nullptr, screenPos));
299
300 // (note: use a local copy of this in case the callback runs
301 // a modal loop and deletes this object before the method completes)
302 auto details = sourceDetails;
303
304 while (hit != nullptr)
305 {
306 if (auto* ddt = dynamic_cast<DragAndDropTarget*> (hit))
307 if (ddt->isInterestedInDragSource (details))
308 return std::tuple (ddt, hit, hit->getLocalPoint (nullptr, screenPos));
309
310 hit = hit->getParentComponent();
311 }
312
313 return {};
314 }
315
316 void setNewScreenPos (Point<int> screenPos)
317 {
318 auto newPos = screenPos - imageOffset;
319
320 if (auto* p = getParentComponent())
321 newPos = p->getLocalPoint (nullptr, newPos);
322
324 }
325
326 void sendDragMove (DragAndDropTarget::SourceDetails& details) const
327 {
328 if (auto* target = getCurrentlyOver())
329 if (target->isInterestedInDragSource (details))
330 target->itemDragMove (details);
331 }
332
333 void checkForExternalDrag (DragAndDropTarget::SourceDetails& details, Point<int> screenPos)
334 {
335 if (! hasCheckedForExternalDrag)
336 {
337 if (Desktop::getInstance().findComponentAt (screenPos) == nullptr)
338 {
339 hasCheckedForExternalDrag = true;
340
341 if (ComponentPeer::getCurrentModifiersRealtime().isAnyMouseButtonDown())
342 {
343 StringArray files;
344 auto canMoveFiles = false;
345
346 if (owner.shouldDropFilesWhenDraggedExternally (details, files, canMoveFiles) && ! files.isEmpty())
347 {
349 deleteSelf();
350 return;
351 }
352
353 String text;
354
355 if (owner.shouldDropTextWhenDraggedExternally (details, text) && text.isNotEmpty())
356 {
358 deleteSelf();
359 return;
360 }
361 }
362 }
363 }
364 }
365
366 void deleteSelf()
367 {
368 delete this;
369 }
370
371 void dismissWithAnimation (const bool shouldSnapBack)
372 {
373 setVisible (true);
374 auto& animator = Desktop::getInstance().getAnimator();
375
376 if (shouldSnapBack && sourceDetails.sourceComponent != nullptr)
377 {
378 auto target = sourceDetails.sourceComponent->localPointToGlobal (sourceDetails.sourceComponent->getLocalBounds().getCentre());
379 auto ourCentre = localPointToGlobal (getLocalBounds().getCentre());
380
381 animator.animateComponent (this,
382 getBounds() + (target - ourCentre),
383 0.0f, 120,
384 true, 1.0, 1.0);
385 }
386 else
387 {
388 animator.fadeOut (this, 120);
389 }
390 }
391
392 bool isOriginalInputSource (const MouseInputSource& sourceToCheck)
393 {
394 return (sourceToCheck.getType() == originalInputSourceType
395 && sourceToCheck.getIndex() == originalInputSourceIndex);
396 }
397
398 JUCE_DECLARE_NON_COPYABLE (DragImageComponent)
399};
400
401
402//==============================================================================
404
406
408 Component* sourceComponent,
409 const ScaledImage& dragImage,
413{
414 if (isAlreadyDragging (sourceComponent))
415 return;
416
417 auto* draggingSource = getMouseInputSourceForDrag (sourceComponent, inputSourceCausingDrag);
418
419 if (draggingSource == nullptr || ! draggingSource->isDragging())
420 {
421 jassertfalse; // You must call startDragging() from within a mouseDown or mouseDrag callback!
422 return;
423 }
424
425 const auto lastMouseDown = draggingSource->getLastMouseDownPosition().roundToInt();
426
427 struct ImageAndOffset
428 {
429 ScaledImage image;
430 Point<double> offset;
431 };
432
433 const auto imageToUse = [&]() -> ImageAndOffset
434 {
435 if (! dragImage.getImage().isNull())
436 return { dragImage, imageOffsetFromMouse != nullptr ? dragImage.getScaledBounds().getConstrainedPoint (-imageOffsetFromMouse->toDouble())
437 : dragImage.getScaledBounds().getCentre() };
438
439 const auto scaleFactor = 2.0;
440 auto image = sourceComponent->createComponentSnapshot (sourceComponent->getLocalBounds(), true, (float) scaleFactor)
442 image.multiplyAllAlphas (0.6f);
443
444 const auto relPos = sourceComponent->getLocalPoint (nullptr, lastMouseDown).toDouble();
445 const auto clipped = (image.getBounds().toDouble() / scaleFactor).getConstrainedPoint (relPos);
446
447 Image fade (Image::SingleChannel, image.getWidth(), image.getHeight(), true);
449
450 ColourGradient gradient;
451 gradient.isRadial = true;
452 gradient.point1 = clipped.toFloat() * scaleFactor;
453 gradient.point2 = gradient.point1 + Point<float> (0.0f, scaleFactor * 400.0f);
454 gradient.addColour (0.0, Colours::white);
455 gradient.addColour (0.375, Colours::white);
456 gradient.addColour (1.0, Colours::transparentWhite);
457
458 fadeContext.setGradientFill (gradient);
459 fadeContext.fillAll();
460
461 Image composite (Image::ARGB, image.getWidth(), image.getHeight(), true);
463
464 compositeContext.reduceClipRegion (fade, {});
465 compositeContext.drawImageAt (image, 0, 0);
466
467 return { ScaledImage (composite, scaleFactor), clipped };
468 }();
469
470 auto* dragImageComponent = dragImageComponents.add (new DragImageComponent (imageToUse.image, sourceDescription, sourceComponent,
471 draggingSource, *this, imageToUse.offset.roundToInt()));
472
474 {
476 dragImageComponent->setOpaque (true);
477
480 }
481 else
482 {
483 if (auto* thisComp = dynamic_cast<Component*> (this))
484 {
485 thisComp->addChildComponent (dragImageComponent);
486 }
487 else
488 {
489 jassertfalse; // Your DragAndDropContainer needs to be a Component!
490 return;
491 }
492 }
493
494 dragImageComponent->sourceDetails.localPosition = sourceComponent->getLocalPoint (nullptr, lastMouseDown);
495 dragImageComponent->updateLocation (false, lastMouseDown);
496
497 #if JUCE_WINDOWS
498 // Under heavy load, the layered window's paint callback can often be lost by the OS,
499 // so forcing a repaint at least once makes sure that the window becomes visible..
500 if (auto* peer = dragImageComponent->getPeer())
501 peer->performAnyPendingRepaintsNow();
502 #endif
503
505}
506
508{
509 return dragImageComponents.size() > 0;
510}
511
513{
514 return dragImageComponents.size();
515}
516
518{
519 // If you are performing drag and drop in a multi-touch environment then
520 // you should use the getDragDescriptionForIndex() method instead!
521 jassert (dragImageComponents.size() < 2);
522
523 return dragImageComponents.size() != 0 ? dragImageComponents[0]->sourceDetails.description
524 : var();
525}
526
528{
529 if (! isPositiveAndBelow (index, dragImageComponents.size()))
530 return {};
531
532 return dragImageComponents.getUnchecked (index)->sourceDetails.description;
533}
534
536{
537 // If you are performing drag and drop in a multi-touch environment then
538 // you should use the setDragImageForIndex() method instead!
539 jassert (dragImageComponents.size() < 2);
540
541 dragImageComponents[0]->updateImage (newImage);
542}
543
545{
546 if (isPositiveAndBelow (index, dragImageComponents.size()))
547 dragImageComponents.getUnchecked (index)->updateImage (newImage);
548}
549
554
559
564
567
568const MouseInputSource* DragAndDropContainer::getMouseInputSourceForDrag (Component* sourceComponent,
570{
571 if (inputSourceCausingDrag == nullptr)
572 {
575
576 auto centrePoint = sourceComponent ? sourceComponent->getScreenBounds().getCentre().toFloat() : Point<float>();
577 auto numDragging = desktop.getNumDraggingMouseSources();
578
579 for (auto i = 0; i < numDragging; ++i)
580 {
581 if (auto* ms = desktop.getDraggingMouseSource (i))
582 {
583 auto distance = ms->getScreenPosition().getDistanceSquaredFrom (centrePoint);
584
585 if (distance < minDistance)
586 {
587 minDistance = distance;
589 }
590 }
591 }
592 }
593
594 // You must call startDragging() from within a mouseDown or mouseDrag callback!
595 jassert (inputSourceCausingDrag != nullptr && inputSourceCausingDrag->isDragging());
596
598}
599
600bool DragAndDropContainer::isAlreadyDragging (Component* component) const noexcept
601{
602 for (auto* dragImageComp : dragImageComponents)
603 {
604 if (dragImageComp->sourceDetails.sourceComponent == component)
605 return true;
606 }
607
608 return false;
609}
610
611//==============================================================================
613 : description (desc),
614 sourceComponent (comp),
615 localPosition (pos)
616{
617}
618
623
624//==============================================================================
628
632
633} // namespace juce
Describes the layout and colours that should be used to paint a colour gradient.
bool isRadial
If true, the gradient should be filled circularly, centred around point1, with point2 defining a poin...
int addColour(double proportionAlongGradient, Colour colour)
Adds a colour at a point along the length of the gradient.
static ModifierKeys getCurrentModifiersRealtime() noexcept
On desktop platforms this method will check all the mouse and key states and return a ModifierKeys ob...
@ windowIsTemporary
Indicates that the window is a temporary popup, like a menu, tooltip, etc.
@ windowIgnoresMouseClicks
Indicates that the window should let mouse clicks pass through it (may not be possible on some platfo...
The base class for all JUCE user-interface objects.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
bool isVisible() const noexcept
Tests whether the component is visible or not.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
Image createComponentSnapshot(Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
Generates a snapshot of part of this component.
bool isOpaque() const noexcept
Returns true if no parts of this component are transparent.
void grabKeyboardFocus()
Tries to give keyboard focus to this component.
Point< int > getLocalPoint(const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Converts a point to be relative to this component's coordinate space.
void setAlwaysOnTop(bool shouldStayOnTop)
Sets whether the component should always be kept at the front of its siblings.
Rectangle< int > getBounds() const noexcept
Returns this component's bounding box.
void repaint()
Marks the whole component as needing to be redrawn.
Component() noexcept
Creates a component.
Rectangle< int > getScreenBounds() const
Returns the bounds of this component, relative to the screen's top-left.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
TargetClass * findParentComponentOfClass() const
Searches the parent components for a component of a specified class.
void setWantsKeyboardFocus(bool wantsFocus) noexcept
Sets a flag to indicate whether this component wants keyboard focus or not.
Point< int > localPointToGlobal(Point< int > localPoint) const
Converts a point relative to this component's top-left into a screen coordinate.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
void setTopLeftPosition(int x, int y)
Moves the component to a new position.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
MouseInputSource getMainMouseSource() const noexcept
Returns the main mouse input device that the system is using.
ComponentAnimator & getAnimator() noexcept
The Desktop object has a ComponentAnimator instance which can be used for performing your animations.
static Desktop &JUCE_CALLTYPE getInstance()
There's only one desktop object, and this method will return it.
const Array< MouseInputSource > & getMouseSources() const noexcept
Provides access to the array of mouse sources, for iteration.
static bool canUseSemiTransparentWindows() noexcept
True if the OS supports semitransparent windows.
void mouseDrag(const MouseEvent &e) override
Called when the mouse is moved while a button is held down.
void paint(Graphics &g) override
Components can override this method to draw their content.
bool canModalEventBeSentToComponent(const Component *targetComponent) override
When a component is modal, this callback allows it to choose which other components can still receive...
void timerCallback() override
The user-defined callback routine that actually gets called periodically.
void inputAttemptWhenModal() override
Called when the user tries to click on a component that is blocked by another modal component.
bool keyPressed(const KeyPress &key) override
Called when a key is pressed.
void mouseUp(const MouseEvent &e) override
Called when a mouse button is released.
Enables drag-and-drop behaviour for a component and all its sub-components.
DragAndDropContainer()
Creates a DragAndDropContainer.
var getCurrentDragDescription() const
Returns the description of the thing that's currently being dragged.
void startDragging(const var &sourceDescription, Component *sourceComponent, const ScaledImage &dragImage=ScaledImage(), bool allowDraggingToOtherJuceWindows=false, const Point< int > *imageOffsetFromMouse=nullptr, const MouseInputSource *inputSourceCausingDrag=nullptr)
Begins a drag-and-drop operation.
var getDragDescriptionForIndex(int index) const
Same as the getCurrentDragDescription() method but takes a touch index parameter.
bool isDragAndDropActive() const
Returns true if something is currently being dragged.
virtual ~DragAndDropContainer()
Destructor.
virtual void dragOperationStarted(const DragAndDropTarget::SourceDetails &)
Subclasses can override this to be told when a drag starts.
static bool performExternalDragDropOfText(const String &text, Component *sourceComponent=nullptr, std::function< void()> callback=nullptr)
This performs an asynchronous drag-and-drop of a block of text to some external application.
virtual bool shouldDropTextWhenDraggedExternally(const DragAndDropTarget::SourceDetails &sourceDetails, String &text)
Override this if you want to be able to perform an external drag of text when the user drags outside ...
virtual void dragOperationEnded(const DragAndDropTarget::SourceDetails &)
Subclasses can override this to be told when a drag finishes.
virtual bool shouldDropFilesWhenDraggedExternally(const DragAndDropTarget::SourceDetails &sourceDetails, StringArray &files, bool &canMoveFiles)
Override this if you want to be able to perform an external drag of a set of files when the user drag...
int getNumCurrentDrags() const
Returns the number of things currently being dragged.
static DragAndDropContainer * findParentDragContainerFor(Component *childComponent)
Utility to find the DragAndDropContainer for a given Component.
static bool performExternalDragDropOfFiles(const StringArray &files, bool canMoveFiles, Component *sourceComponent=nullptr, std::function< void()> callback=nullptr)
This performs an asynchronous drag-and-drop of a set of files to some external application.
void setDragImageForIndex(int index, const ScaledImage &newImage)
Same as the setCurrentDragImage() method but takes a touch index parameter.
void setCurrentDragImage(const ScaledImage &newImage)
If a drag is in progress, this allows the image being shown to be dynamically updated.
Contains details about the source of a drag-and-drop operation.
WeakReference< Component > sourceComponent
The component from the drag operation was started.
SourceDetails(const var &description, Component *sourceComponent, Point< int > localPosition) noexcept
Creates a SourceDetails object from its various settings.
virtual void itemDragEnter(const SourceDetails &dragSourceDetails)
Callback to indicate that something is being dragged over this component.
virtual void itemDragExit(const SourceDetails &dragSourceDetails)
Callback to indicate that something has been dragged off the edge of this component.
virtual void itemDragMove(const SourceDetails &dragSourceDetails)
Callback to indicate that the user is dragging something over this component.
virtual bool shouldDrawDragImageWhenOver()
Overriding this allows the target to tell the drag container whether to draw the drag image while the...
virtual void fileDragEnter(const StringArray &files, int x, int y)
Callback to indicate that some files are being dragged over this component.
virtual void fileDragExit(const StringArray &files)
Callback to indicate that the mouse has moved away from this component.
virtual void fileDragMove(const StringArray &files, int x, int y)
Callback to indicate that the user is dragging some files over this component.
A graphics context, used for drawing a component or image.
void drawImage(const Image &imageToDraw, int destX, int destY, int destWidth, int destHeight, int sourceX, int sourceY, int sourceWidth, int sourceHeight, bool fillAlphaChannelWithCurrentBrush=false) const
Draws part of an image, rescaling it to fit in a given target region.
void setOpacity(float newOpacity)
Changes the opacity to use with the current colour.
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
Image convertedToFormat(PixelFormat newFormat) const
Returns a version of this image with a different image format.
@ SingleChannel
< each pixel is a 1-byte alpha channel value.
Definition juce_Image.h:68
@ ARGB
< each pixel is a 4-byte ARGB premultiplied colour value.
Definition juce_Image.h:67
Represents a key press, including any modifier keys that are needed.
static const int escapeKey
key-code for the escape key
static bool callAsync(std::function< void()> functionToCall)
Asynchronously invokes a function or C++11 lambda on the message thread.
Contains position and status information about a mouse event.
MouseInputSource source
The source device that generated this event.
Point< int > getScreenPosition() const
Returns the mouse position of this event, in global screen coordinates.
Component *const originalComponent
The component that the event first occurred on.
Represents a linear source of mouse events from a mouse device or individual finger in a multi-touch ...
void forceMouseCursorUpdate()
Forces an update of the mouse cursor for whatever component it's currently over.
InputSourceType
Possible mouse input sources.
A pair of (x, y) coordinates.
Definition juce_Point.h:42
constexpr Point< float > toFloat() const noexcept
Casts this point to a Point<float> object.
Definition juce_Point.h:239
constexpr Point< double > toDouble() const noexcept
Casts this point to a Point<double> object.
Definition juce_Point.h:242
Point< ValueType > getCentre() const noexcept
Returns the centre point of the rectangle.
static RelativeTime milliseconds(int milliseconds) noexcept
Creates a new RelativeTime object representing a number of milliseconds.
An image that will be resampled before it is drawn.
Image getImage() const
Returns the image at its original dimensions.
A special array for holding a list of strings.
The JUCE String class!
Definition juce_String.h:53
virtual void textDragEnter(const String &text, int x, int y)
Callback to indicate that some text is being dragged over this component.
virtual void textDragMove(const String &text, int x, int y)
Callback to indicate that the user is dragging some text over this component.
virtual void textDragExit(const String &text)
Callback to indicate that the mouse has moved away from this component.
Holds an absolute date and time.
Definition juce_Time.h:37
static Time JUCE_CALLTYPE getCurrentTime() noexcept
Returns a Time object that is set to the current system time.
Makes repeated callbacks to a virtual method at a specified time interval.
Definition juce_Timer.h:52
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
This class acts as a pointer which will automatically become null if the object to which it points is...
ObjectType * get() const noexcept
Returns the object that this pointer refers to, or null if the object no longer exists.
A variant class, that can be used to hold a range of primitive values.
T exchange(T... args)
#define jassert(expression)
Platform-independent assertion macro.
#define JUCE_DECLARE_NON_COPYABLE(className)
This is a shorthand macro for deleting a class's copy constructor and copy assignment operator.
#define jassertfalse
This will always cause an assertion failure.
T max(T... args)
JUCE Namespace.
void ignoreUnused(Types &&...) noexcept
Handy function for avoiding unused variables warning.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.