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 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.
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/public-api/math/vector2.h>
28 #include <drag-and-drop-detector.h>
39 typedef IntrusivePtr< DragAndDropDetector > DragAndDropDetectorPtr;
42 * This class listens to Drag & Drop events.
44 class DragAndDropDetector : public Dali::BaseObject
48 typedef Dali::DragAndDropDetector::DragAndDropSignal DragAndDropSignal;
53 * Create a DragAndDropDetector.
54 * This should only be called once by the Window class.
55 * @return A newly allocated drag-and-drop-detector.
57 static Dali::DragAndDropDetector New();
62 * @copydoc Dali::DragAndDropDetector::GetContent() const
64 const std::string& GetContent() const;
67 * @copydoc Dali::DragAndDropDetector::GetCurrentScreenPosition() const
69 Vector2 GetCurrentScreenPosition() const;
71 // Called by Drag & Drop Event Handler
74 * Queries whether drag & drop behaviour is really required.
75 * @return true if drag & drop required, false otherwise.
77 bool IsEnabled() const;
80 * Sets the dragged content.
81 * @param[in] content A string that represents the content that has been dropped.
83 void SetContent( const std::string& content );
86 * Clears the stored content.
91 * Sets the position the drop occurred.
93 void SetPosition( Vector2 screenPosition );
96 * Called when a draggable object enters our window.
98 void EmitEnteredSignal();
101 * Called when a draggable object leaves our window.
103 void EmitExitedSignal();
106 * Called when a draggable object leaves our window.
108 void EmitMovedSignal();
111 * Is called when a drop actually occurs.
113 void EmitDroppedSignal();
118 * @copydoc Dali::DragAndDropDetector::EnteredSignal
120 DragAndDropSignal& EnteredSignal()
122 return mEnteredSignal;
126 * @copydoc Dali::DragAndDropDetector::ExitedSignal
128 DragAndDropSignal& ExitedSignal()
130 return mExitedSignal;
134 * @copydoc Dali::DragAndDropDetector::MovedSignal
136 DragAndDropSignal& MovedSignal()
142 * @copydoc Dali::DragAndDropDetector::DroppedSignal
144 DragAndDropSignal& DroppedSignal()
146 return mDroppedSignal;
151 // Construction & Destruction
156 DragAndDropDetector();
161 virtual ~DragAndDropDetector();
164 DragAndDropDetector( const DragAndDropDetector& );
165 DragAndDropDetector& operator=( DragAndDropDetector& );
169 std::string mContent; ///< The current Drag & drop content.
170 Vector2 mScreenPosition; ///< The screen position of the drop location.
172 DragAndDropSignal mEnteredSignal;
173 DragAndDropSignal mExitedSignal;
174 DragAndDropSignal mMovedSignal;
175 DragAndDropSignal mDroppedSignal;
178 } // namespace Adaptor
180 } // namespace Internal
182 // Helpers for public-api forwarding methods
184 inline Internal::Adaptor::DragAndDropDetector& GetImplementation(Dali::DragAndDropDetector& detector)
186 DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
188 BaseObject& handle = detector.GetBaseObject();
190 return static_cast<Internal::Adaptor::DragAndDropDetector&>(handle);
193 inline const Internal::Adaptor::DragAndDropDetector& GetImplementation(const Dali::DragAndDropDetector& detector)
195 DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
197 const BaseObject& handle = detector.GetBaseObject();
199 return static_cast<const Internal::Adaptor::DragAndDropDetector&>(handle);
204 #endif // __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__