LMMS
Loading...
Searching...
No Matches
juce_DragAndDropContainer.h
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
29//==============================================================================
51{
52public:
53 //==============================================================================
59
62
63 //==============================================================================
95 void startDragging (const var& sourceDescription,
96 Component* sourceComponent,
97 const ScaledImage& dragImage = ScaledImage(),
98 bool allowDraggingToOtherJuceWindows = false,
99 const Point<int>* imageOffsetFromMouse = nullptr,
100 const MouseInputSource* inputSourceCausingDrag = nullptr);
101
102 [[deprecated ("This overload does not allow the image's scale to be specified. Use the other overload of startDragging instead.")]]
103 void startDragging (const var& sourceDescription,
104 Component* sourceComponent,
105 Image dragImage,
106 bool allowDraggingToOtherJuceWindows = false,
107 const Point<int>* imageOffsetFromMouse = nullptr,
108 const MouseInputSource* inputSourceCausingDrag = nullptr)
109 {
110 startDragging (sourceDescription,
111 sourceComponent,
112 ScaledImage (dragImage),
113 allowDraggingToOtherJuceWindows,
114 imageOffsetFromMouse,
115 inputSourceCausingDrag);
116 }
117
119 bool isDragAndDropActive() const;
120
122 int getNumCurrentDrags() const;
123
134 var getCurrentDragDescription() const;
135
140 var getDragDescriptionForIndex (int index) const;
141
149 void setCurrentDragImage (const ScaledImage& newImage);
150
151 [[deprecated ("This overload does not allow the image's scale to be specified. Use the other overload of setCurrentDragImage instead.")]]
152 void setCurrentDragImage (const Image& newImage) { setCurrentDragImage (ScaledImage (newImage)); }
153
158 void setDragImageForIndex (int index, const ScaledImage& newImage);
159
160 [[deprecated ("This overload does not allow the image's scale to be specified. Use the other overload of setDragImageForIndex instead.")]]
161 void setDragImageForIndex (int index, const Image& newImage) { setDragImageForIndex (index, ScaledImage (newImage)); }
162
173 static DragAndDropContainer* findParentDragContainerFor (Component* childComponent);
174
175
176 //==============================================================================
195 static bool performExternalDragDropOfFiles (const StringArray& files, bool canMoveFiles,
196 Component* sourceComponent = nullptr,
197 std::function<void()> callback = nullptr);
198
215 static bool performExternalDragDropOfText (const String& text, Component* sourceComponent = nullptr,
216 std::function<void()> callback = nullptr);
217
218protected:
232 virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
233 StringArray& files, bool& canMoveFiles);
234
246 virtual bool shouldDropTextWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
247 String& text);
248
250 virtual void dragOperationStarted (const DragAndDropTarget::SourceDetails&);
251
253 virtual void dragOperationEnded (const DragAndDropTarget::SourceDetails&);
254
255private:
256 //==============================================================================
257 class DragImageComponent;
259
260 const MouseInputSource* getMouseInputSourceForDrag (Component* sourceComponent, const MouseInputSource* inputSourceCausingDrag);
261 bool isAlreadyDragging (Component* sourceComponent) const noexcept;
262
264};
265
266} // namespace juce
Definition juce_Component.h:36
Definition juce_DragAndDropContainer.h:51
void startDragging(const var &sourceDescription, Component *sourceComponent, const ScaledImage &dragImage=ScaledImage(), bool allowDraggingToOtherJuceWindows=false, const Point< int > *imageOffsetFromMouse=nullptr, const MouseInputSource *inputSourceCausingDrag=nullptr)
Definition juce_DragAndDropContainer.cpp:403
void setCurrentDragImage(const Image &newImage)
Definition juce_DragAndDropContainer.h:152
void setDragImageForIndex(int index, const Image &newImage)
Definition juce_DragAndDropContainer.h:161
const MouseInputSource * getMouseInputSourceForDrag(Component *sourceComponent, const MouseInputSource *inputSourceCausingDrag)
Definition juce_DragAndDropContainer.cpp:565
OwnedArray< DragImageComponent > dragImageComponents
Definition juce_DragAndDropContainer.h:258
void startDragging(const var &sourceDescription, Component *sourceComponent, Image dragImage, bool allowDraggingToOtherJuceWindows=false, const Point< int > *imageOffsetFromMouse=nullptr, const MouseInputSource *inputSourceCausingDrag=nullptr)
Definition juce_DragAndDropContainer.h:103
bool isAlreadyDragging(Component *sourceComponent) const noexcept
Definition juce_DragAndDropContainer.cpp:597
Definition juce_DragAndDropTarget.h:54
Definition juce_Image.h:58
Definition juce_MouseInputSource.h:52
Definition juce_OwnedArray.h:51
Definition juce_Point.h:42
Definition juce_ScaledImage.h:45
Definition juce_StringArray.h:35
Definition juce_String.h:53
Definition juce_Variant.h:42
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
static char ** files
Definition misc.c:28
Definition carla_juce.cpp:31
const char * text
Definition swell-functions.h:167
RECT const char void(* callback)(const char *droppath))) SWELL_API_DEFINE(BOOL
Definition swell-functions.h:1004