1 #ifndef __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
2 #define __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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-object.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/adaptor-framework/common/drag-and-drop-detector.h>
38 typedef IntrusivePtr< DragAndDropDetector > DragAndDropDetectorPtr;
41 * This class listens to Drag & Drop events.
43 class DragAndDropDetector : public Dali::BaseObject
47 typedef Dali::DragAndDropDetector::DragAndDropSignalV2 DragAndDropSignalV2;
52 * Create a DragAndDropDetector.
53 * This should only be called once by the Window class.
54 * @return A newly allocated drag-and-drop-detector.
56 static Dali::DragAndDropDetector New();
61 * @copydoc Dali::DragAndDropDetector::GetContent() const
63 const std::string& GetContent() const;
66 * @copydoc Dali::DragAndDropDetector::GetCurrentScreenPosition() const
68 Vector2 GetCurrentScreenPosition() const;
70 // Called by Drag & Drop Event Handler
73 * Queries whether drag & drop behaviour is really required.
74 * @return true if drag & drop required, false otherwise.
76 bool IsEnabled() const;
79 * Sets the dragged content.
80 * @param[in] content A string that represents the content that has been dropped.
82 void SetContent( const std::string& content );
85 * Clears the stored content.
90 * Sets the position the drop occurred.
92 void SetPosition( Vector2 screenPosition );
95 * Called when a draggable object enters our window.
97 void EmitEnteredSignal();
100 * Called when a draggable object leaves our window.
102 void EmitExitedSignal();
105 * Called when a draggable object leaves our window.
107 void EmitMovedSignal();
110 * Is called when a drop actually occurs.
112 void EmitDroppedSignal();
117 * @copydoc Dali::DragAndDropDetector::EnteredSignal
119 DragAndDropSignalV2& EnteredSignal()
121 return mEnteredSignalV2;
125 * @copydoc Dali::DragAndDropDetector::ExitedSignal
127 DragAndDropSignalV2& ExitedSignal()
129 return mExitedSignalV2;
133 * @copydoc Dali::DragAndDropDetector::MovedSignal
135 DragAndDropSignalV2& MovedSignal()
137 return mMovedSignalV2;
141 * @copydoc Dali::DragAndDropDetector::DroppedSignal
143 DragAndDropSignalV2& DroppedSignal()
145 return mDroppedSignalV2;
150 // Construction & Destruction
155 DragAndDropDetector();
160 virtual ~DragAndDropDetector();
163 DragAndDropDetector( const DragAndDropDetector& );
164 DragAndDropDetector& operator=( DragAndDropDetector& );
168 std::string mContent; ///< The current Drag & drop content.
169 Vector2 mScreenPosition; ///< The screen position of the drop location.
171 DragAndDropSignalV2 mEnteredSignalV2;
172 DragAndDropSignalV2 mExitedSignalV2;
173 DragAndDropSignalV2 mMovedSignalV2;
174 DragAndDropSignalV2 mDroppedSignalV2;
177 } // namespace Adaptor
179 } // namespace Internal
181 // Helpers for public-api forwarding methods
183 inline Internal::Adaptor::DragAndDropDetector& GetImplementation(Dali::DragAndDropDetector& detector)
185 DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
187 BaseObject& handle = detector.GetBaseObject();
189 return static_cast<Internal::Adaptor::DragAndDropDetector&>(handle);
192 inline const Internal::Adaptor::DragAndDropDetector& GetImplementation(const Dali::DragAndDropDetector& detector)
194 DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
196 const BaseObject& handle = detector.GetBaseObject();
198 return static_cast<const Internal::Adaptor::DragAndDropDetector&>(handle);
203 #endif // __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__