Public API headers are installed in the correct folder
[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-v2.h>
27
28 namespace Dali DALI_IMPORT_API
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  * It provides signals for when the draggable object enters our window, moves around in our window,
42  * leaves our window and when it is finally dropped into our window.
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 DragAndDropDetector : public BaseHandle
89 {
90 public:
91
92   // Typedefs
93
94   /**
95    * @brief Drag & Drop signal.
96    */
97   typedef SignalV2< void ( DragAndDropDetector ) > DragAndDropSignalV2;
98
99   // Signal Names
100   static const char* const SIGNAL_ENTERED;///< name "drag-and-drop-entered"
101   static const char* const SIGNAL_EXITED; ///< name "drag-and-drop-exited"
102   static const char* const SIGNAL_MOVED;  ///< name "drag-and-drop-moved"
103   static const char* const SIGNAL_DROPPED;///< name "drag-and-drop-dropped"
104
105   /**
106    * @brief Create an uninitialized handle.
107    *
108    * This can be initialized by calling getting the detector from Dali::Window.
109    */
110   DragAndDropDetector();
111
112   /**
113    * @brief Destructor
114    *
115    * This is non-virtual since derived Handle types must not contain data or virtual methods.
116    */
117   ~DragAndDropDetector();
118
119   /**
120    * @brief Returns the dropped content.
121    *
122    * @return A reference to the string representing the dropped content.
123    */
124   const std::string& GetContent() const;
125
126   /**
127    * @brief Returns the current position of the dragged object.
128    *
129    * This is the dropped position when an object is dropped.
130    * @return The current screen position.
131    */
132   Vector2 GetCurrentScreenPosition() const;
133
134 public:  // Signals
135
136   /**
137    * @brief This is emitted when a dragged object enters a DALi window.
138    *
139    * A callback of the following type may be connected:
140    * @code
141    *   void YourCallback( DragAndDropDetector detector );
142    * @endcode
143    * @return The signal to connect to.
144    */
145   DragAndDropSignalV2& EnteredSignal();
146
147   /**
148    * @brief This is emitted when a dragged object leaves a DALi window.
149    *
150    * A callback of the following type may be connected:
151    * @code
152    *   void YourCallback( DragAndDropDetector detector );
153    * @endcode
154    * @return The signal to connect to.
155    */
156   DragAndDropSignalV2& ExitedSignal();
157
158   /**
159    * @brief This is emitted when a dragged object is moved within the DALi window.
160    *
161    * A callback of the following type may be connected:
162    * @code
163    *   void YourCallback( DragAndDropDetector detector );
164    * @endcode
165    * This will be replaced by a property notification system once that is in place.
166    * @return The signal to connect to.
167    */
168   DragAndDropSignalV2& MovedSignal();
169
170   /**
171    * @brief This is emitted when a dragged object is dropped within a DALi window.
172    *
173    * A callback of the following type may be connected:
174    * @code
175    *   void YourCallback( DragAndDropDetector detector );
176    * @endcode
177    * @return The signal to connect to.
178    */
179   DragAndDropSignalV2& DroppedSignal();
180
181 public: // Not intended for application developers
182
183   /**
184    * @brief This constructor is used by DragAndDropDetector::Get().
185    *
186    * @param[in] detector A pointer to the drag and drop detector.
187    */
188   DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
189 };
190
191 } // namespace Dali
192
193 #endif // __DALI_DRAG_AND_DROP_DETECTOR_H__