1 #ifndef __DALI_DRAG_AND_DROP_DETECTOR_H__
2 #define __DALI_DRAG_AND_DROP_DETECTOR_H__
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/signals/dali-signal.h>
27 #include <dali/public-api/dali-adaptor-common.h>
32 namespace Internal DALI_INTERNAL
36 class DragAndDropDetector;
41 * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
43 * It provides signals for when the draggable object enters our window, moves around in our window,
44 * leaves our window and when it is finally dropped into our window.
46 * The basic usage is shown below:
52 * DragAndDropDetector detector( window::GetDragAndDropDetector() );
54 * // Get notifications when the draggable item enters our window
55 * detector.EnteredSignal().Connect( &OnEntered );
57 * // Get notifications when the draggable item leaves our window
58 * detector.ExitedSignal().Connect( &OnExited );
60 * // Get notifications when the draggable item is moved within our window
61 * detector.MovedSignal().Connect( &OnMoved );
63 * // Get notifications when the draggable item is dropped
64 * detector.DroppedSignal().Connect( &OnDropped );
67 * void OnEntered( DragAndDropDetector detector )
69 * // Change mode as required
72 * void OnExited( DragAndDropDetector detector )
74 * // Change mode as required
77 * void OnMoved( DragAndDropDetector detector )
79 * // Query the new values
80 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << std::endl;
83 * void OnDropped( DragAndDropDetector detector )
85 * // Query the new values
86 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << ", Content = " << detector.GetContent() << std::endl;
91 class DALI_ADAPTOR_API DragAndDropDetector : public BaseHandle
97 typedef Signal< void ( DragAndDropDetector ) > DragAndDropSignal; ///< Drag & Drop signal
100 * @brief Create an uninitialized handle.
102 * This can be initialized by calling getting the detector from Dali::Window.
104 DragAndDropDetector();
109 * This is non-virtual since derived Handle types must not contain data or virtual methods.
111 ~DragAndDropDetector();
114 * @brief Returns the dropped content.
116 * @return A reference to the string representing the dropped content.
118 const std::string& GetContent() const;
121 * @brief Returns the current position of the dragged object.
123 * This is the dropped position when an object is dropped.
124 * @return The current screen position.
126 Vector2 GetCurrentScreenPosition() const;
131 * @brief This is emitted when a dragged object enters a DALi window.
133 * A callback of the following type may be connected:
135 * void YourCallback( DragAndDropDetector detector );
137 * @return The signal to connect to.
139 DragAndDropSignal& EnteredSignal();
142 * @brief This is emitted when a dragged object leaves a DALi window.
144 * A callback of the following type may be connected:
146 * void YourCallback( DragAndDropDetector detector );
148 * @return The signal to connect to.
150 DragAndDropSignal& ExitedSignal();
153 * @brief This is emitted when a dragged object is moved within the DALi window.
155 * A callback of the following type may be connected:
157 * void YourCallback( DragAndDropDetector detector );
159 * @return The signal to connect to.
161 DragAndDropSignal& MovedSignal();
164 * @brief This is emitted when a dragged object is dropped within a DALi window.
166 * A callback of the following type may be connected:
168 * void YourCallback( DragAndDropDetector detector );
170 * @return The signal to connect to.
172 DragAndDropSignal& DroppedSignal();
174 public: // Not intended for application developers
177 * @brief This constructor is used by DragAndDropDetector::Get().
179 * @param[in] detector A pointer to the drag and drop detector.
181 explicit DALI_INTERNAL DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
186 #endif // __DALI_DRAG_AND_DROP_DETECTOR_H__