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 * @addtogroup CAPI_DALI_ADAPTOR_MODULE
28 #include <boost/function.hpp>
30 #include <dali/public-api/object/base-handle.h>
31 #include <dali/public-api/signals/dali-signal-v2.h>
33 namespace Dali DALI_IMPORT_API
36 namespace Internal DALI_INTERNAL
40 class DragAndDropDetector;
45 * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
46 * It provides signals for when the draggable object enters our window, moves around in our window,
47 * leaves our window and when it is finally dropped into our window.
48 * The basic usage is shown below:
54 * DragAndDropDetector detector( window::GetDragAndDropDetector() );
56 * // Get notifications when the draggable item enters our window
57 * detector.EnteredSignal().Connect( &OnEntered );
59 * // Get notifications when the draggable item leaves our window
60 * detector.ExitedSignal().Connect( &OnExited );
62 * // Get notifications when the draggable item is moved within our window
63 * detector.MovedSignal().Connect( &OnMoved );
65 * // Get notifications when the draggable item is dropped
66 * detector.DroppedSignal().Connect( &OnDropped );
69 * void OnEntered( DragAndDropDetector detector )
71 * // Change mode as required
74 * void OnExited( DragAndDropDetector detector )
76 * // Change mode as required
79 * void OnMoved( DragAndDropDetector detector )
81 * // Query the new values
82 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << std::endl;
85 * void OnDropped( DragAndDropDetector detector )
87 * // Query the new values
88 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << ", Content = " << detector.GetContent() << std::endl;
93 class DragAndDropDetector : public BaseHandle
100 * @brief Drag & Drop signal.
102 typedef SignalV2< void ( DragAndDropDetector ) > DragAndDropSignalV2;
105 static const char* const SIGNAL_ENTERED;///< name "drag-and-drop-entered"
106 static const char* const SIGNAL_EXITED; ///< name "drag-and-drop-exited"
107 static const char* const SIGNAL_MOVED; ///< name "drag-and-drop-moved"
108 static const char* const SIGNAL_DROPPED;///< name "drag-and-drop-dropped"
111 * @brief Create an uninitialized handle.
113 * This can be initialized by calling getting the detector from Dali::Window.
115 DragAndDropDetector();
120 * This is non-virtual since derived Handle types must not contain data or virtual methods.
122 ~DragAndDropDetector();
125 * @brief Returns the dropped content.
127 * @return A reference to the string representing the dropped content.
129 const std::string& GetContent() const;
132 * @brief Returns the current position of the dragged object.
134 * This is the dropped position when an object is dropped.
135 * @return The current screen position.
137 Vector2 GetCurrentScreenPosition() const;
142 * @brief This is emitted when a dragged object enters 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 DragAndDropSignalV2& EnteredSignal();
153 * @brief This is emitted when a dragged object leaves a 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 DragAndDropSignalV2& ExitedSignal();
164 * @brief This is emitted when a dragged object is moved within the DALi window.
166 * A callback of the following type may be connected:
168 * void YourCallback( DragAndDropDetector detector );
170 * This will be replaced by a property notification system once that is in place.
171 * @return The signal to connect to.
173 DragAndDropSignalV2& MovedSignal();
176 * @brief This is emitted when a dragged object is dropped within a DALi window.
178 * A callback of the following type may be connected:
180 * void YourCallback( DragAndDropDetector detector );
182 * @return The signal to connect to.
184 DragAndDropSignalV2& DroppedSignal();
186 public: // Not intended for application developers
189 * @brief This constructor is used by DragAndDropDetector::Get().
191 * @param[in] detector A pointer to the drag and drop detector.
193 DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
201 #endif // __DALI_DRAG_AND_DROP_DETECTOR_H__