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