Controls no longer have property names.
[platform/core/uifw/dali-toolkit.git] / capi / dali-toolkit / public-api / controls / popup / popup.h
1 #ifndef __DALI_TOOLKIT_POPUP_H__
2 #define __DALI_TOOLKIT_POPUP_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 /**
21  * @addtogroup CAPI_DALI_FRAMEWORK
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/control.h>
27 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
28
29 namespace Dali DALI_IMPORT_API
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Internal DALI_INTERNAL
36 {
37 class Popup;
38 }
39
40 class Button;
41
42 /**
43  * Popup contains content that can come into focus when
44  * activated, and out of focus when deactivated.
45  *
46  * Content:
47  *
48  * The content within a popup consists of:
49  *
50  * 1. Title
51  * 2. Buttons
52  * 3. Background/Frame (i.e. Scale-9 image)
53  * 4. Custom Content (Actors)
54  *
55  * All of which are optional.
56  *
57  * States:
58  *
59  * A popup can be in a number of states:
60  *
61  * 1. HIDE (invisible)
62  * 2. SHOW (visible at normal size)
63  * 3. SHOW_MAXIMIZED (visible occupying full parent size)
64  * 4. Or custom defined.
65  *
66  * Transition Effects:
67  *
68  * A popup can use various custom transition effects e.g.
69  *
70  * Alpha fade, Scaling transition, position/rotation, shader effects.
71  *
72  */
73 class Popup : public Control
74 {
75
76 public:
77
78   //Signal Names
79   static const char* const SIGNAL_TOUCHED_OUTSIDE;
80   static const char* const SIGNAL_HIDDEN;
81
82   /**
83    * Current popup state
84    */
85   enum PopupState
86   {
87     POPUP_NONE,               ///< Init status
88     POPUP_HIDE,               ///< Hidden (not visible)
89     POPUP_SHOW,               ///< Shown (visible in default size)
90   };
91
92   typedef SignalV2< void () > TouchedOutsideSignalV2;
93   typedef SignalV2< void () > HiddenSignalV2;
94
95   /**
96    * Signal emitted when user has touched outside of the Dialog.
97    */
98   TouchedOutsideSignalV2& OutsideTouchedSignal();
99
100   /**
101    * Signal emitted when popup has been hidden.
102    */
103   HiddenSignalV2& HiddenSignal();
104
105 public:
106
107   /**
108    * Creates an empty Popup handle
109    */
110   Popup();
111
112   /**
113    * Copy constructor. Creates another handle that points to the same real object
114    */
115   Popup( const Popup& handle );
116
117   /**
118    * Assignment operator. Changes this handle to point to another real object
119    */
120   Popup& operator=( const Popup& handle );
121
122   /**
123    * Virtual destructor.
124    * Dali::Object derived classes typically do not contain member data.
125    */
126   virtual ~Popup();
127
128   /**
129    * Create the Poup control
130    * @return A handle to the Popup control.
131    */
132   static Popup New();
133
134   /**
135    * Downcast an Object handle to Popup. If handle points to a Popup the
136    * downcast produces valid handle. If not the returned handle is left uninitialized.
137    * @param[in] handle Handle to an object
138    * @return handle to a Popup or an uninitialized handle
139    */
140   static Popup DownCast( BaseHandle handle );
141
142 public:
143
144   /**
145    * Sets the background image for this Popup.
146    *
147    * The background is resized (stretched according to scale settings),
148    * to the size of the Popup.
149    *
150    * @param[in] image The Background ImageActor to cover background
151    */
152   void SetBackgroundImage( Actor image );
153
154   /**
155    * Sets a title for this Popup.
156    *
157    * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
158    *
159    * @param[in] text The text to appear as the heading for this Popup
160    */
161   void SetTitle( const std::string& text );
162
163   /**
164    * Sets a title for this Popup.
165    *
166    * @param[in] titleActor The TextView to appear as the heading for this Popup
167    */
168   void SetTitle( TextView titleActor );
169
170   /**
171    * Gets the text (TextView) for this Popup.
172    *
173    * @return The TextView representing this popup is returned.
174    */
175   TextView GetTitle() const;
176
177   /**
178    * Adds a button to this Popup.
179    *
180    * Buttons are added to the bottom of the Popup and Centered.
181    *
182    * By default the first button added will have the focus, and the focus will
183    * shift to other buttons based on the sequence in which they are added to the popup.
184    *
185    * @param[in] button The button to be added to this Popup
186    */
187   void AddButton( Button button );
188
189   /**
190    * Sets state of Popup, such as HIDE, and SHOW.
191    *
192    * The Popup will instantaneously jump to this state.
193    *
194    * @param[in] state The state of the popup
195    */
196   void SetState( PopupState state );
197
198   /**
199    * Sets state of Popup, such as HIDE, and SHOW.
200    *
201    * The Popup will smoothly animate to this state.
202    *
203    * @param[in] state The state of the popup
204    * @param[in] duration The time to animate to this new state.
205    */
206   void SetState( PopupState state, float duration );
207
208   /**
209    * Gets the state of the popup.
210    * @return The state of the popup.
211    */
212   PopupState GetState() const;
213
214   /**
215    * Shows the popup.
216    *
217    * The Popup will animate to the SHOW state
218    */
219   void Show();
220
221   /**
222    * Hides the popup.
223    *
224    * The Popup will animate to the HIDE state
225    */
226   void Hide();
227
228   /**
229    * Shows the tail.
230    *
231    * The tail position is specified relative to it's Parent.
232    * To display at top center for instace, pass:
233    *
234    * ParentOrigin::TOP_CENTER
235    *
236    * @note The tail images are defined inside PopupStyle as
237    * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
238    *
239    * @param[in] position A position around the perimeter of the Parent.
240    */
241   void ShowTail(const Vector3& position);
242
243   /**
244    * Hides the tail.
245    */
246   void HideTail();
247
248 public: // Not intended for application developers
249
250   /**
251    * Creates a handle using the Toolkit::Internal implementation.
252    * @param[in]  implementation  The Control implementation.
253    */
254   Popup(Internal::Popup& implementation);
255
256   /**
257    * Allows the creation of this Control from an Internal::CustomActor pointer.
258    * @param[in]  internal  A pointer to the internal CustomActor.
259    */
260   Popup( Dali::Internal::CustomActor* internal );
261 };
262
263 } // namespace Toolkit
264
265 } // namespace Dali
266
267 /**
268  * @}
269  */
270 #endif // __DALI_TOOLKIT_POPUP_H__