1 #ifndef __DALI_TOOLKIT_POPUP_H__
2 #define __DALI_TOOLKIT_POPUP_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
21 * @addtogroup CAPI_DALI_TOOLKIT_POPUP_MODULE
26 #include <dali-toolkit/public-api/controls/control.h>
27 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
29 namespace Dali DALI_IMPORT_API
35 namespace Internal DALI_INTERNAL
43 * @brief Popup contains content that can come into focus when activated, and out of focus when deactivated.
47 * The content within a popup consists of:
51 * 3. Background/Frame (i.e. Scale-9 image)
52 * 4. Custom Content (Actors)
54 * All of which are optional.
58 * A popup can be in a number of states:
61 * 2. SHOW (visible at normal size)
62 * 3. SHOW_MAXIMIZED (visible occupying full parent size)
63 * 4. Or custom defined.
67 * A popup can use various custom transition effects, e.g.
68 * Alpha fade, Scaling transition, position/rotation, shader effects.
70 class Popup : public Control
76 static const char* const SIGNAL_TOUCHED_OUTSIDE; ///< name "touched-outside"
77 static const char* const SIGNAL_HIDDEN; ///< name "hidden"
80 * @brief Current popup state.
84 POPUP_NONE, ///< Init status
85 POPUP_HIDE, ///< Hidden (not visible)
86 POPUP_SHOW, ///< Shown (visible in default size)
89 typedef SignalV2< void () > TouchedOutsideSignalV2; ///< Touched outside signal type.
90 typedef SignalV2< void () > HiddenSignalV2; ///< Hidden signal type.
93 * @brief Signal emitted when user has touched outside of the Dialog.
95 TouchedOutsideSignalV2& OutsideTouchedSignal();
98 * @brief Signal emitted when popup has been hidden.
100 HiddenSignalV2& HiddenSignal();
105 * @brief Creates an empty Popup handle.
110 * @brief Copy constructor.
112 * Creates another handle that points to the same real object
113 * @param[in] handle Handle to the copied object
115 Popup( const Popup& handle );
118 * @brief Assignment operator.
120 * Changes this handle to point to another real object
121 * @param[in] handle Handle to the object
122 * @return A reference to this
124 Popup& operator=( const Popup& handle );
127 * @brief Virtual destructor.
129 * Dali::Object derived classes typically do not contain member data.
134 * @brief Create the Poup control.
136 * @return A handle to the Popup control.
141 * @brief Downcast an Object handle to Popup.
143 * If handle points to a Popup the
144 * downcast produces valid handle. If not the returned handle is left uninitialized.
145 * @param[in] handle Handle to an object
146 * @return handle to a Popup or an uninitialized handle
148 static Popup DownCast( BaseHandle handle );
153 * @brief Sets the background image for this Popup.
155 * The background is resized (stretched according to scale settings),
156 * to the size of the Popup.
158 * @param[in] image The Background ImageActor to cover background
160 void SetBackgroundImage( Actor image );
163 * @brief Sets a title for this Popup.
165 * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
167 * @param[in] text The text to appear as the heading for this Popup
169 void SetTitle( const std::string& text );
172 * @brief Sets a title for this Popup.
174 * @param[in] titleActor The TextView to appear as the heading for this Popup
176 void SetTitle( TextView titleActor );
179 * @brief Gets the text (TextView) for this Popup.
181 * @return The TextView representing this popup is returned.
183 TextView GetTitle() const;
186 * @brief Adds a button to this Popup.
188 * Buttons are added to the bottom of the Popup and Centered.
190 * By default the first button added will have the focus, and the focus will
191 * shift to other buttons based on the sequence in which they are added to the popup.
193 * @param[in] button The button to be added to this Popup
195 void AddButton( Button button );
198 * @brief Sets state of Popup, such as HIDE, and SHOW.
200 * The Popup will instantaneously jump to this state.
202 * @param[in] state The state of the popup
204 void SetState( PopupState state );
207 * @brief Sets state of Popup, such as HIDE, and SHOW.
209 * The Popup will smoothly animate to this state.
211 * @param[in] state The state of the popup
212 * @param[in] duration The time to animate to this new state.
214 void SetState( PopupState state, float duration );
217 * @brief Gets the state of the popup.
219 * @return The state of the popup.
221 PopupState GetState() const;
224 * @brief Shows the popup.
226 * The Popup will animate to the SHOW state
231 * @brief Hides the popup.
233 * The Popup will animate to the HIDE state
238 * @brief Shows the tail.
240 * The tail position is specified relative to it's Parent.
241 * To display at top center for instace, pass:
243 * ParentOrigin::TOP_CENTER
245 * @note The tail images are defined inside PopupStyle as
246 * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
248 * @param[in] position A position around the perimeter of the Parent.
250 void ShowTail(const Vector3& position);
253 * @brief Hides the tail.
257 public: // Not intended for application developers
260 * @brief Creates a handle using the Toolkit::Internal implementation.
262 * @param[in] implementation The Control implementation.
264 Popup(Internal::Popup& implementation);
267 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
269 * @param[in] internal A pointer to the internal CustomActor.
271 Popup( Dali::Internal::CustomActor* internal );
274 } // namespace Toolkit
281 #endif // __DALI_TOOLKIT_POPUP_H__