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