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