Adaptor refactor
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / drag-and-drop-detector.h
1 #ifndef __DALI_DRAG_AND_DROP_DETECTOR_H__
2 #define __DALI_DRAG_AND_DROP_DETECTOR_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
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
21
22 // EXTERNAL INCLUDES
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/signals/dali-signal.h>
25
26 namespace Dali
27 {
28
29 namespace Internal DALI_INTERNAL
30 {
31 namespace Adaptor
32 {
33 class DragAndDropDetector;
34 }
35 }
36
37 /**
38  * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
39  *
40  * It provides signals for when the draggable object enters our window, moves around in our window,
41  * leaves our window and when it is finally dropped into our window.
42  *
43  * The basic usage is shown below:
44  *
45  * @code
46  *
47  *  void Example()
48  *  {
49  *    DragAndDropDetector detector( window::GetDragAndDropDetector() );
50  *
51  *    // Get notifications when the draggable item enters our window
52  *    detector.EnteredSignal().Connect( &OnEntered );
53  *
54  *    // Get notifications when the draggable item leaves our window
55  *    detector.ExitedSignal().Connect( &OnExited );
56  *
57  *    // Get notifications when the draggable item is moved within our window
58  *    detector.MovedSignal().Connect( &OnMoved );
59  *
60  *    // Get notifications when the draggable item is dropped
61  *    detector.DroppedSignal().Connect( &OnDropped );
62  *  }
63  *
64  *  void OnEntered( DragAndDropDetector detector )
65  *  {
66  *    // Change mode as required
67  *  }
68  *
69  *  void OnExited( DragAndDropDetector detector )
70  *  {
71  *    // Change mode as required
72  *  }
73  *
74  *  void OnMoved( DragAndDropDetector detector )
75  *  {
76  *    // Query the new values
77  *    std::cout << "Position = " << detector.GetCurrentScreenPosition() << std::endl;
78  *  }
79  *
80  *  void OnDropped( DragAndDropDetector detector )
81  *  {
82  *    // Query the new values
83  *    std::cout << "Position = " << detector.GetCurrentScreenPosition() << ", Content = " << detector.GetContent() << std::endl;
84  *  }
85  *
86  * @endcode
87  */
88 class DALI_IMPORT_API DragAndDropDetector : public BaseHandle
89 {
90 public:
91
92   // Typedefs
93
94   typedef Signal< void ( DragAndDropDetector ) > DragAndDropSignal; ///< Drag & Drop signal
95
96   /**
97    * @brief Create an uninitialized handle.
98    *
99    * This can be initialized by calling getting the detector from Dali::Window.
100    */
101   DragAndDropDetector();
102
103   /**
104    * @brief Destructor
105    *
106    * This is non-virtual since derived Handle types must not contain data or virtual methods.
107    */
108   ~DragAndDropDetector();
109
110   /**
111    * @brief Returns the dropped content.
112    *
113    * @return A reference to the string representing the dropped content.
114    */
115   const std::string& GetContent() const;
116
117   /**
118    * @brief Returns the current position of the dragged object.
119    *
120    * This is the dropped position when an object is dropped.
121    * @return The current screen position.
122    */
123   Vector2 GetCurrentScreenPosition() const;
124
125   // Signals
126
127   /**
128    * @brief This is emitted when a dragged object enters a DALi window.
129    *
130    * A callback of the following type may be connected:
131    * @code
132    *   void YourCallback( DragAndDropDetector detector );
133    * @endcode
134    * @return The signal to connect to.
135    */
136   DragAndDropSignal& EnteredSignal();
137
138   /**
139    * @brief This is emitted when a dragged object leaves a DALi window.
140    *
141    * A callback of the following type may be connected:
142    * @code
143    *   void YourCallback( DragAndDropDetector detector );
144    * @endcode
145    * @return The signal to connect to.
146    */
147   DragAndDropSignal& ExitedSignal();
148
149   /**
150    * @brief This is emitted when a dragged object is moved within the DALi window.
151    *
152    * A callback of the following type may be connected:
153    * @code
154    *   void YourCallback( DragAndDropDetector detector );
155    * @endcode
156    * @return The signal to connect to.
157    */
158   DragAndDropSignal& MovedSignal();
159
160   /**
161    * @brief This is emitted when a dragged object is dropped within a DALi window.
162    *
163    * A callback of the following type may be connected:
164    * @code
165    *   void YourCallback( DragAndDropDetector detector );
166    * @endcode
167    * @return The signal to connect to.
168    */
169   DragAndDropSignal& DroppedSignal();
170
171 public: // Not intended for application developers
172
173   /**
174    * @brief This constructor is used by DragAndDropDetector::Get().
175    *
176    * @param[in] detector A pointer to the drag and drop detector.
177    */
178   explicit DALI_INTERNAL DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
179 };
180
181 } // namespace Dali
182
183 #endif // __DALI_DRAG_AND_DROP_DETECTOR_H__