[SRUK] Initial copy from Tizen 2.2 version
[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    * The names of custom properties installed by this control.
84    */
85   // Property Names
86   static const char* const PROPERTY_TITLE;     ///< name "title", type string.
87   static const char* const PROPERTY_STATE;     ///< name "state", type string.
88
89   /**
90    * Current popup state
91    */
92   enum PopupState
93   {
94     POPUP_NONE,               ///< Init status
95     POPUP_HIDE,               ///< Hidden (not visible)
96     POPUP_SHOW,               ///< Shown (visible in default size)
97   };
98
99   typedef SignalV2< void () > TouchedOutsideSignalV2;
100   typedef SignalV2< void () > HiddenSignalV2;
101
102   /**
103    * Signal emitted when user has touched outside of the Dialog.
104    */
105   TouchedOutsideSignalV2& OutsideTouchedSignal();
106
107   /**
108    * Signal emitted when popup has been hidden.
109    */
110   HiddenSignalV2& HiddenSignal();
111
112 public:
113
114   /**
115    * Creates an empty Popup handle
116    */
117   Popup();
118
119   /**
120    * Copy constructor. Creates another handle that points to the same real object
121    */
122   Popup( const Popup& handle );
123
124   /**
125    * Assignment operator. Changes this handle to point to another real object
126    */
127   Popup& operator=( const Popup& handle );
128
129   /**
130    * Virtual destructor.
131    * Dali::Object derived classes typically do not contain member data.
132    */
133   virtual ~Popup();
134
135   /**
136    * Create the Poup control
137    * @return A handle to the Popup control.
138    */
139   static Popup New();
140
141   /**
142    * Downcast an Object handle to Popup. If handle points to a Popup the
143    * downcast produces valid handle. If not the returned handle is left uninitialized.
144    * @param[in] handle Handle to an object
145    * @return handle to a Popup or an uninitialized handle
146    */
147   static Popup DownCast( BaseHandle handle );
148
149 public:
150
151   /**
152    * Sets the background image for this Popup.
153    *
154    * The background is resized (stretched according to scale settings),
155    * to the size of the Popup.
156    *
157    * @param[in] image The Background ImageActor to cover background
158    */
159   void SetBackgroundImage( Actor image );
160
161   /**
162    * Sets a title for this Popup.
163    *
164    * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
165    *
166    * @param[in] text The text to appear as the heading for this Popup
167    */
168   void SetTitle( const std::string& text );
169
170   /**
171    * Sets a title for this Popup.
172    *
173    * @param[in] titleActor The TextView to appear as the heading for this Popup
174    */
175   void SetTitle( TextView titleActor );
176
177   /**
178    * Gets the text (TextView) for this Popup.
179    *
180    * @return The TextView representing this popup is returned.
181    */
182   TextView GetTitle() const;
183
184   /**
185    * Adds a button to this Popup.
186    *
187    * Buttons are added to the bottom of the Popup and Centered.
188    *
189    * By default the first button added will have the focus, and the focus will
190    * shift to other buttons based on the sequence in which they are added to the popup.
191    *
192    * @param[in] button The button to be added to this Popup
193    */
194   void AddButton( Button button );
195
196   /**
197    * Sets state of Popup, such as HIDE, and SHOW.
198    *
199    * The Popup will instantaneously jump to this state.
200    *
201    * @param[in] state The state of the popup
202    */
203   void SetState( PopupState state );
204
205   /**
206    * Sets state of Popup, such as HIDE, and SHOW.
207    *
208    * The Popup will smoothly animate to this state.
209    *
210    * @param[in] state The state of the popup
211    * @param[in] duration The time to animate to this new state.
212    */
213   void SetState( PopupState state, float duration );
214
215   /**
216    * Gets the state of the popup.
217    * @return The state of the popup.
218    */
219   PopupState GetState() const;
220
221   /**
222    * Shows the popup.
223    *
224    * The Popup will animate to the SHOW state
225    */
226   void Show();
227
228   /**
229    * Hides the popup.
230    *
231    * The Popup will animate to the HIDE state
232    */
233   void Hide();
234
235   /**
236    * Shows the tail.
237    *
238    * The tail position is specified relative to it's Parent.
239    * To display at top center for instace, pass:
240    *
241    * ParentOrigin::TOP_CENTER
242    *
243    * @note The tail images are defined inside PopupStyle as
244    * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
245    *
246    * @param[in] position A position around the perimeter of the Parent.
247    */
248   void ShowTail(const Vector3& position);
249
250   /**
251    * Hides the tail.
252    */
253   void HideTail();
254
255 public: // Not intended for application developers
256
257   /**
258    * Creates a handle using the Toolkit::Internal implementation.
259    * @param[in]  implementation  The Control implementation.
260    */
261   Popup(Internal::Popup& implementation);
262
263   /**
264    * Allows the creation of this Control from an Internal::CustomActor pointer.
265    * @param[in]  internal  A pointer to the internal CustomActor.
266    */
267   Popup( Dali::Internal::CustomActor* internal );
268 };
269
270 } // namespace Toolkit
271
272 } // namespace Dali
273
274 /**
275  * @}
276  */
277 #endif // __DALI_TOOLKIT_POPUP_H__