1 #ifndef __DALI_TOOLKIT_POPUP_H__
2 #define __DALI_TOOLKIT_POPUP_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @addtogroup CAPI_DALI_TOOLKIT_POPUP_MODULE
27 #include <dali-toolkit/public-api/controls/control.h>
28 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
30 namespace Dali DALI_IMPORT_API
36 namespace Internal DALI_INTERNAL
44 * @brief Popup contains content that can come into focus when activated, and out of focus when deactivated.
48 * The content within a popup consists of:
52 * 3. Background/Frame (i.e. Scale-9 image)
53 * 4. Custom Content (Actors)
55 * All of which are optional.
59 * A popup can be in a number of states:
62 * 2. SHOW (visible at normal size)
63 * 3. SHOW_MAXIMIZED (visible occupying full parent size)
64 * 4. Or custom defined.
68 * A popup can use various custom transition effects, e.g.
69 * Alpha fade, Scaling transition, position/rotation, shader effects.
71 class Popup : public Control
77 static const char* const SIGNAL_TOUCHED_OUTSIDE; ///< name "touched-outside"
78 static const char* const SIGNAL_HIDDEN; ///< name "hidden"
81 * @brief Current popup state.
85 POPUP_NONE, ///< Init status
86 POPUP_HIDE, ///< Hidden (not visible)
87 POPUP_SHOW, ///< Shown (visible in default size)
90 typedef SignalV2< void () > TouchedOutsideSignalV2; ///< Touched outside signal type.
91 typedef SignalV2< void () > HiddenSignalV2; ///< Hidden signal type.
94 * @brief Signal emitted when user has touched outside of the Dialog.
96 TouchedOutsideSignalV2& OutsideTouchedSignal();
99 * @brief Signal emitted when popup has been hidden.
101 HiddenSignalV2& HiddenSignal();
106 * @brief Creates an empty Popup handle.
111 * @brief Copy constructor.
113 * Creates another handle that points to the same real object
114 * @param[in] handle Handle to the copied object
116 Popup( const Popup& handle );
119 * @brief Assignment operator.
121 * Changes this handle to point to another real object
122 * @param[in] handle Handle to the object
123 * @return A reference to this
125 Popup& operator=( const Popup& handle );
128 * @brief Virtual destructor.
130 * Dali::Object derived classes typically do not contain member data.
135 * @brief Create the Poup control.
137 * @return A handle to the Popup control.
142 * @brief Downcast an Object handle to Popup.
144 * If handle points to a Popup the
145 * downcast produces valid handle. If not the returned handle is left uninitialized.
146 * @param[in] handle Handle to an object
147 * @return handle to a Popup or an uninitialized handle
149 static Popup DownCast( BaseHandle handle );
154 * @brief Sets the background image for this Popup.
156 * The background is resized (stretched according to scale settings),
157 * to the size of the Popup.
159 * @param[in] image The Background ImageActor to cover background
161 void SetBackgroundImage( Actor image );
164 * @brief Sets a title for this Popup.
166 * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
168 * @param[in] text The text to appear as the heading for this Popup
170 void SetTitle( const std::string& text );
173 * @brief Sets a title for this Popup.
175 * @param[in] titleActor The TextView to appear as the heading for this Popup
177 void SetTitle( TextView titleActor );
180 * @brief Gets the text (TextView) for this Popup.
182 * @return The TextView representing this popup is returned.
184 TextView GetTitle() const;
187 * @brief Adds a button to this Popup.
189 * Buttons are added to the bottom of the Popup and Centered.
191 * By default the first button added will have the focus, and the focus will
192 * shift to other buttons based on the sequence in which they are added to the popup.
194 * @param[in] button The button to be added to this Popup
196 void AddButton( Button button );
199 * @brief Sets state of Popup, such as HIDE, and SHOW.
201 * The Popup will instantaneously jump to this state.
203 * @param[in] state The state of the popup
205 void SetState( PopupState state );
208 * @brief Sets state of Popup, such as HIDE, and SHOW.
210 * The Popup will smoothly animate to this state.
212 * @param[in] state The state of the popup
213 * @param[in] duration The time to animate to this new state.
215 void SetState( PopupState state, float duration );
218 * @brief Gets the state of the popup.
220 * @return The state of the popup.
222 PopupState GetState() const;
225 * @brief Shows the popup.
227 * The Popup will animate to the SHOW state
232 * @brief Hides the popup.
234 * The Popup will animate to the HIDE state
239 * @brief Shows the tail.
241 * The tail position is specified relative to it's Parent.
242 * To display at top center for instace, pass:
244 * ParentOrigin::TOP_CENTER
246 * @note The tail images are defined inside PopupStyle as
247 * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
249 * @param[in] position A position around the perimeter of the Parent.
251 void ShowTail(const Vector3& position);
254 * @brief Hides the tail.
258 public: // Not intended for application developers
261 * @brief Creates a handle using the Toolkit::Internal implementation.
263 * @param[in] implementation The Control implementation.
265 Popup(Internal::Popup& implementation);
268 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
270 * @param[in] internal A pointer to the internal CustomActor.
272 Popup( Dali::Internal::CustomActor* internal );
275 } // namespace Toolkit
282 #endif // __DALI_TOOLKIT_POPUP_H__