1 #ifndef __DALI_DRAG_AND_DROP_DETECTOR_H__
2 #define __DALI_DRAG_AND_DROP_DETECTOR_H__
5 * Copyright (c) 2014 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 <boost/function.hpp>
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/signals/dali-signal-v2.h>
28 namespace Dali DALI_IMPORT_API
31 namespace Internal DALI_INTERNAL
35 class DragAndDropDetector;
40 * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
41 * It provides signals for when the draggable object enters our window, moves around in our window,
42 * 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 DragAndDropDetector : public BaseHandle
95 * @brief Drag & Drop signal.
97 typedef SignalV2< void ( DragAndDropDetector ) > DragAndDropSignalV2;
100 static const char* const SIGNAL_ENTERED;///< name "drag-and-drop-entered"
101 static const char* const SIGNAL_EXITED; ///< name "drag-and-drop-exited"
102 static const char* const SIGNAL_MOVED; ///< name "drag-and-drop-moved"
103 static const char* const SIGNAL_DROPPED;///< name "drag-and-drop-dropped"
106 * @brief Create an uninitialized handle.
108 * This can be initialized by calling getting the detector from Dali::Window.
110 DragAndDropDetector();
115 * This is non-virtual since derived Handle types must not contain data or virtual methods.
117 ~DragAndDropDetector();
120 * @brief Returns the dropped content.
122 * @return A reference to the string representing the dropped content.
124 const std::string& GetContent() const;
127 * @brief Returns the current position of the dragged object.
129 * This is the dropped position when an object is dropped.
130 * @return The current screen position.
132 Vector2 GetCurrentScreenPosition() const;
137 * @brief This is emitted when a dragged object enters a DALi window.
139 * A callback of the following type may be connected:
141 * void YourCallback( DragAndDropDetector detector );
143 * @return The signal to connect to.
145 DragAndDropSignalV2& EnteredSignal();
148 * @brief This is emitted when a dragged object leaves a DALi window.
150 * A callback of the following type may be connected:
152 * void YourCallback( DragAndDropDetector detector );
154 * @return The signal to connect to.
156 DragAndDropSignalV2& ExitedSignal();
159 * @brief This is emitted when a dragged object is moved within the DALi window.
161 * A callback of the following type may be connected:
163 * void YourCallback( DragAndDropDetector detector );
165 * This will be replaced by a property notification system once that is in place.
166 * @return The signal to connect to.
168 DragAndDropSignalV2& MovedSignal();
171 * @brief This is emitted when a dragged object is dropped within a DALi window.
173 * A callback of the following type may be connected:
175 * void YourCallback( DragAndDropDetector detector );
177 * @return The signal to connect to.
179 DragAndDropSignalV2& DroppedSignal();
181 public: // Not intended for application developers
184 * @brief This constructor is used by DragAndDropDetector::Get().
186 * @param[in] detector A pointer to the drag and drop detector.
188 DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
193 #endif // __DALI_DRAG_AND_DROP_DETECTOR_H__