1 #ifndef __DALI_DRAG_AND_DROP_DETECTOR_H__
2 #define __DALI_DRAG_AND_DROP_DETECTOR_H__
5 * Copyright (c) 2015 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>
29 namespace Internal DALI_INTERNAL
33 class DragAndDropDetector;
38 * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
40 * It provides signals for when the draggable object enters our window, moves around in our window,
41 * leaves our window and when it is finally dropped into our window.
43 * The basic usage is shown below:
49 * DragAndDropDetector detector( window::GetDragAndDropDetector() );
51 * // Get notifications when the draggable item enters our window
52 * detector.EnteredSignal().Connect( &OnEntered );
54 * // Get notifications when the draggable item leaves our window
55 * detector.ExitedSignal().Connect( &OnExited );
57 * // Get notifications when the draggable item is moved within our window
58 * detector.MovedSignal().Connect( &OnMoved );
60 * // Get notifications when the draggable item is dropped
61 * detector.DroppedSignal().Connect( &OnDropped );
64 * void OnEntered( DragAndDropDetector detector )
66 * // Change mode as required
69 * void OnExited( DragAndDropDetector detector )
71 * // Change mode as required
74 * void OnMoved( DragAndDropDetector detector )
76 * // Query the new values
77 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << std::endl;
80 * void OnDropped( DragAndDropDetector detector )
82 * // Query the new values
83 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << ", Content = " << detector.GetContent() << std::endl;
88 class DALI_IMPORT_API DragAndDropDetector : public BaseHandle
94 typedef Signal< void ( DragAndDropDetector ) > DragAndDropSignal; ///< Drag & Drop signal
97 * @brief Create an uninitialized handle.
99 * This can be initialized by calling getting the detector from Dali::Window.
101 DragAndDropDetector();
106 * This is non-virtual since derived Handle types must not contain data or virtual methods.
108 ~DragAndDropDetector();
111 * @brief Returns the dropped content.
113 * @return A reference to the string representing the dropped content.
115 const std::string& GetContent() const;
118 * @brief Returns the current position of the dragged object.
120 * This is the dropped position when an object is dropped.
121 * @return The current screen position.
123 Vector2 GetCurrentScreenPosition() const;
128 * @brief This is emitted when a dragged object enters a DALi window.
130 * A callback of the following type may be connected:
132 * void YourCallback( DragAndDropDetector detector );
134 * @return The signal to connect to.
136 DragAndDropSignal& EnteredSignal();
139 * @brief This is emitted when a dragged object leaves a DALi window.
141 * A callback of the following type may be connected:
143 * void YourCallback( DragAndDropDetector detector );
145 * @return The signal to connect to.
147 DragAndDropSignal& ExitedSignal();
150 * @brief This is emitted when a dragged object is moved within the DALi window.
152 * A callback of the following type may be connected:
154 * void YourCallback( DragAndDropDetector detector );
156 * @return The signal to connect to.
158 DragAndDropSignal& MovedSignal();
161 * @brief This is emitted when a dragged object is dropped within a DALi window.
163 * A callback of the following type may be connected:
165 * void YourCallback( DragAndDropDetector detector );
167 * @return The signal to connect to.
169 DragAndDropSignal& DroppedSignal();
171 public: // Not intended for application developers
174 * @brief This constructor is used by DragAndDropDetector::Get().
176 * @param[in] detector A pointer to the drag and drop detector.
178 explicit DALI_INTERNAL DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
183 #endif // __DALI_DRAG_AND_DROP_DETECTOR_H__