VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_gui_basics / mouse / juce_DragAndDropTarget.h
blob8a8ead1688eb3ca59bb1f186e87899fe2e63519b
1 /*
2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
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.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 /**
31 Components derived from this class can have things dropped onto them by a DragAndDropContainer.
33 To create a component that can receive things drag-and-dropped by a DragAndDropContainer,
34 derive your component from this class, and make sure that it is somewhere inside a
35 DragAndDropContainer component.
37 Note: If all that you need to do is to respond to files being drag-and-dropped from
38 the operating system onto your component, you don't need any of these classes: instead
39 see the FileDragAndDropTarget class.
41 @see DragAndDropContainer, FileDragAndDropTarget
43 @tags{GUI}
45 class JUCE_API DragAndDropTarget
47 public:
48 /** Destructor. */
49 virtual ~DragAndDropTarget() = default;
51 //==============================================================================
52 /** Contains details about the source of a drag-and-drop operation. */
53 class JUCE_API SourceDetails
55 public:
56 /** Creates a SourceDetails object from its various settings. */
57 SourceDetails (const var& description,
58 Component* sourceComponent,
59 Point<int> localPosition) noexcept;
61 /** A descriptor for the drag - this is set DragAndDropContainer::startDragging(). */
62 var description;
64 /** The component from the drag operation was started. */
65 WeakReference<Component> sourceComponent;
67 /** The local position of the mouse, relative to the target component.
68 Note that for calls such as isInterestedInDragSource(), this may be a null position.
70 Point<int> localPosition;
73 //==============================================================================
74 /** Callback to check whether this target is interested in the type of object being
75 dragged.
77 @param dragSourceDetails contains information about the source of the drag operation.
78 @returns true if this component wants to receive the other callbacks regarding this
79 type of object; if it returns false, no other callbacks will be made.
81 virtual bool isInterestedInDragSource (const SourceDetails& dragSourceDetails) = 0;
83 /** Callback to indicate that something is being dragged over this component.
85 This gets called when the user moves the mouse into this component while dragging
86 something.
88 Use this callback as a trigger to make your component repaint itself to give the
89 user feedback about whether the item can be dropped here or not.
91 @param dragSourceDetails contains information about the source of the drag operation.
92 @see itemDragExit
94 virtual void itemDragEnter (const SourceDetails& dragSourceDetails);
96 /** Callback to indicate that the user is dragging something over this component.
98 This gets called when the user moves the mouse over this component while dragging
99 something. Normally overriding itemDragEnter() and itemDragExit() are enough, but
100 this lets you know what happens in-between.
102 @param dragSourceDetails contains information about the source of the drag operation.
104 virtual void itemDragMove (const SourceDetails& dragSourceDetails);
106 /** Callback to indicate that something has been dragged off the edge of this component.
108 This gets called when the user moves the mouse out of this component while dragging
109 something.
111 If you've used itemDragEnter() to repaint your component and give feedback, use this
112 as a signal to repaint it in its normal state.
114 @param dragSourceDetails contains information about the source of the drag operation.
115 @see itemDragEnter
117 virtual void itemDragExit (const SourceDetails& dragSourceDetails);
119 /** Callback to indicate that the user has dropped something onto this component.
121 When the user drops an item this get called, and you can use the description to
122 work out whether your object wants to deal with it or not.
124 Note that after this is called, the itemDragExit method may not be called, so you should
125 clean up in here if there's anything you need to do when the drag finishes.
127 @param dragSourceDetails contains information about the source of the drag operation.
129 virtual void itemDropped (const SourceDetails& dragSourceDetails) = 0;
131 /** Overriding this allows the target to tell the drag container whether to
132 draw the drag image while the cursor is over it.
134 By default it returns true, but if you return false, then the normal drag
135 image will not be shown when the cursor is over this target.
137 virtual bool shouldDrawDragImageWhenOver();
140 } // namespace juce