7fb7d2d4924bf9745796b390e5c02464d5e56de1
[platform/core/uifw/dali-adaptor.git] / adaptors / tizen / internal / common / drag-and-drop-detector-impl.h
1 #ifndef __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
2 #define __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
12 //
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.
18 //
19
20 // EXTERNAL INCLUDES
21 #include <string>
22
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>
26
27 // INTERNAL INCLUDES
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37
38 typedef IntrusivePtr< DragAndDropDetector > DragAndDropDetectorPtr;
39
40 /**
41  * This class listens to Drag & Drop events.
42  */
43 class DragAndDropDetector : public Dali::BaseObject
44 {
45 public:
46
47   typedef Dali::DragAndDropDetector::DragAndDropSignalV2 DragAndDropSignalV2;
48
49   // Creation
50
51   /**
52    * Create a DragAndDropDetector.
53    * This should only be called once by the Window class.
54    * @return A newly allocated drag-and-drop-detector.
55    */
56   static Dali::DragAndDropDetector New();
57
58   // Public API
59
60   /**
61    * @copydoc Dali::DragAndDropDetector::GetContent() const
62    */
63   const std::string& GetContent() const;
64
65   /**
66    * @copydoc Dali::DragAndDropDetector::GetCurrentScreenPosition() const
67    */
68   Vector2 GetCurrentScreenPosition() const;
69
70   // Called by Drag & Drop Event Handler
71
72   /**
73    * Queries whether drag & drop behaviour is really required.
74    * @return true if drag & drop required, false otherwise.
75    */
76   bool IsEnabled() const;
77
78   /**
79    * Sets the dragged content.
80    * @param[in] content  A string that represents the content that has been dropped.
81    */
82   void SetContent( const std::string& content );
83
84   /**
85    * Clears the stored content.
86    */
87   void ClearContent();
88
89   /**
90    * Sets the position the drop occurred.
91    */
92   void SetPosition( Vector2 screenPosition );
93
94   /**
95    * Called when a draggable object enters our window.
96    */
97   void EmitEnteredSignal();
98
99   /**
100    * Called when a draggable object leaves our window.
101    */
102   void EmitExitedSignal();
103
104   /**
105    * Called when a draggable object leaves our window.
106    */
107   void EmitMovedSignal();
108
109   /**
110    * Is called when a drop actually occurs.
111    */
112   void EmitDroppedSignal();
113
114 public: // Signals
115
116   /**
117    * @copydoc Dali::DragAndDropDetector::EnteredSignal
118    */
119   DragAndDropSignalV2& EnteredSignal()
120   {
121     return mEnteredSignalV2;
122   }
123
124   /**
125    * @copydoc Dali::DragAndDropDetector::ExitedSignal
126    */
127   DragAndDropSignalV2& ExitedSignal()
128   {
129     return mExitedSignalV2;
130   }
131
132   /**
133    * @copydoc Dali::DragAndDropDetector::MovedSignal
134    */
135   DragAndDropSignalV2& MovedSignal()
136   {
137     return mMovedSignalV2;
138   }
139
140   /**
141    * @copydoc Dali::DragAndDropDetector::DroppedSignal
142    */
143   DragAndDropSignalV2& DroppedSignal()
144   {
145     return mDroppedSignalV2;
146   }
147
148 private:
149
150   // Construction & Destruction
151
152   /**
153    * Constructor.
154    */
155   DragAndDropDetector();
156
157   /**
158    * Destructor.
159    */
160   virtual ~DragAndDropDetector();
161
162   // Undefined
163   DragAndDropDetector( const DragAndDropDetector& );
164   DragAndDropDetector& operator=( DragAndDropDetector& );
165
166 private:
167
168   std::string mContent;    ///< The current Drag & drop content.
169   Vector2 mScreenPosition; ///< The screen position of the drop location.
170
171   DragAndDropSignalV2 mEnteredSignalV2;
172   DragAndDropSignalV2 mExitedSignalV2;
173   DragAndDropSignalV2 mMovedSignalV2;
174   DragAndDropSignalV2 mDroppedSignalV2;
175 };
176
177 } // namespace Adaptor
178
179 } // namespace Internal
180
181 // Helpers for public-api forwarding methods
182
183 inline Internal::Adaptor::DragAndDropDetector& GetImplementation(Dali::DragAndDropDetector& detector)
184 {
185   DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
186
187   BaseObject& handle = detector.GetBaseObject();
188
189   return static_cast<Internal::Adaptor::DragAndDropDetector&>(handle);
190 }
191
192 inline const Internal::Adaptor::DragAndDropDetector& GetImplementation(const Dali::DragAndDropDetector& detector)
193 {
194   DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
195
196   const BaseObject& handle = detector.GetBaseObject();
197
198   return static_cast<const Internal::Adaptor::DragAndDropDetector&>(handle);
199 }
200
201 } // namespace Dali
202
203 #endif // __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__