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