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.h>
31 namespace Internal DALI_INTERNAL
35 class DragAndDropDetector;
40 * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
42 * It provides signals for when the draggable object enters our window, moves around in our window,
43 * leaves our window and when it is finally dropped into our window.
45 * The basic usage is shown below:
51 * DragAndDropDetector detector( window::GetDragAndDropDetector() );
53 * // Get notifications when the draggable item enters our window
54 * detector.EnteredSignal().Connect( &OnEntered );
56 * // Get notifications when the draggable item leaves our window
57 * detector.ExitedSignal().Connect( &OnExited );
59 * // Get notifications when the draggable item is moved within our window
60 * detector.MovedSignal().Connect( &OnMoved );
62 * // Get notifications when the draggable item is dropped
63 * detector.DroppedSignal().Connect( &OnDropped );
66 * void OnEntered( DragAndDropDetector detector )
68 * // Change mode as required
71 * void OnExited( DragAndDropDetector detector )
73 * // Change mode as required
76 * void OnMoved( DragAndDropDetector detector )
78 * // Query the new values
79 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << std::endl;
82 * void OnDropped( DragAndDropDetector detector )
84 * // Query the new values
85 * std::cout << "Position = " << detector.GetCurrentScreenPosition() << ", Content = " << detector.GetContent() << std::endl;
90 class DALI_IMPORT_API DragAndDropDetector : public BaseHandle
96 typedef Signal< void ( DragAndDropDetector ) > DragAndDropSignal; ///< Drag & Drop signal
99 * @brief Create an uninitialized handle.
101 * This can be initialized by calling getting the detector from Dali::Window.
103 DragAndDropDetector();
108 * This is non-virtual since derived Handle types must not contain data or virtual methods.
110 ~DragAndDropDetector();
113 * @brief Returns the dropped content.
115 * @return A reference to the string representing the dropped content.
117 const std::string& GetContent() const;
120 * @brief Returns the current position of the dragged object.
122 * This is the dropped position when an object is dropped.
123 * @return The current screen position.
125 Vector2 GetCurrentScreenPosition() const;
130 * @brief This is emitted when a dragged object enters a DALi window.
132 * A callback of the following type may be connected:
134 * void YourCallback( DragAndDropDetector detector );
136 * @return The signal to connect to.
138 DragAndDropSignal& EnteredSignal();
141 * @brief This is emitted when a dragged object leaves a DALi window.
143 * A callback of the following type may be connected:
145 * void YourCallback( DragAndDropDetector detector );
147 * @return The signal to connect to.
149 DragAndDropSignal& ExitedSignal();
152 * @brief This is emitted when a dragged object is moved within the DALi window.
154 * A callback of the following type may be connected:
156 * void YourCallback( DragAndDropDetector detector );
158 * @return The signal to connect to.
160 DragAndDropSignal& MovedSignal();
163 * @brief This is emitted when a dragged object is dropped within a DALi window.
165 * A callback of the following type may be connected:
167 * void YourCallback( DragAndDropDetector detector );
169 * @return The signal to connect to.
171 DragAndDropSignal& DroppedSignal();
173 public: // Not intended for application developers
176 * @brief This constructor is used by DragAndDropDetector::Get().
178 * @param[in] detector A pointer to the drag and drop detector.
180 explicit DALI_INTERNAL DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
185 #endif // __DALI_DRAG_AND_DROP_DETECTOR_H__