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 #include <dali-toolkit/public-api/controls/control.h>
30 namespace Internal DALI_INTERNAL
38 * @brief Popup contains content that can come into focus when activated, and out of focus when deactivated.
42 * The content within a popup consists of:
46 * 3. Background/Frame (i.e. Scale-9 image)
47 * 4. Custom Content (Actors)
49 * All of which are optional.
53 * A popup can be in a number of states:
56 * 2. SHOW (visible at normal size)
57 * 3. SHOW_MAXIMIZED (visible occupying full parent size)
58 * 4. Or custom defined.
62 * A popup can use various custom transition effects, e.g.
63 * Alpha fade, Scaling transition, position/rotation, shader effects.
65 class DALI_IMPORT_API Popup : public Control
71 static const char* const SIGNAL_TOUCHED_OUTSIDE; ///< name "touched-outside"
72 static const char* const SIGNAL_HIDDEN; ///< name "hidden"
75 * @brief Current popup state.
79 POPUP_NONE, ///< Init status
80 POPUP_HIDE, ///< Hidden (not visible)
81 POPUP_SHOW, ///< Shown (visible in default size)
84 typedef SignalV2< void () > TouchedOutsideSignalV2; ///< Touched outside signal type.
85 typedef SignalV2< void () > HiddenSignalV2; ///< Hidden signal type.
88 * @brief Signal emitted when user has touched outside of the Dialog.
90 TouchedOutsideSignalV2& OutsideTouchedSignal();
93 * @brief Signal emitted when popup has been hidden.
95 HiddenSignalV2& HiddenSignal();
100 * @brief Creates an empty Popup handle.
105 * @brief Copy constructor.
107 * Creates another handle that points to the same real object
108 * @param[in] handle Handle to the copied object
110 Popup( const Popup& handle );
113 * @brief Assignment operator.
115 * Changes this handle to point to another real object
116 * @param[in] handle Handle to the object
117 * @return A reference to this
119 Popup& operator=( const Popup& handle );
124 * This is non-virtual since derived Handle types must not contain data or virtual methods.
129 * @brief Create the Poup control.
131 * @return A handle to the Popup control.
136 * @brief Downcast an Object handle to Popup.
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
143 static Popup DownCast( BaseHandle handle );
148 * @brief Sets the background image for this Popup.
150 * The background is resized (stretched according to scale settings),
151 * to the size of the Popup.
153 * @param[in] image The Background ImageActor to cover background
155 void SetBackgroundImage( Actor image );
158 * @brief Sets a title for this Popup.
160 * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
162 * @param[in] text The text to appear as the heading for this Popup
164 void SetTitle( const std::string& text );
167 * @brief Gets the text (TextView) for this Popup.
169 * @return The text to appear as the heading for this Popup
171 const std::string& GetTitle() const;
174 * @brief Adds a button to this Popup.
176 * Buttons are added to the bottom of the Popup and Centered.
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.
181 * @param[in] button The button to be added to this Popup
183 void AddButton( Button button );
186 * @brief Sets state of Popup, such as HIDE, and SHOW.
188 * The Popup will instantaneously jump to this state.
190 * @param[in] state The state of the popup
192 void SetState( PopupState state );
195 * @brief Sets state of Popup, such as HIDE, and SHOW.
197 * The Popup will smoothly animate to this state.
199 * @param[in] state The state of the popup
200 * @param[in] duration The time to animate to this new state.
202 void SetState( PopupState state, float duration );
205 * @brief Gets the state of the popup.
207 * @return The state of the popup.
209 PopupState GetState() const;
212 * @brief Shows the popup.
214 * The Popup will animate to the SHOW state
219 * @brief Hides the popup.
221 * The Popup will animate to the HIDE state
226 * @brief Shows the tail.
228 * The tail position is specified relative to it's Parent.
229 * To display at top center for instace, pass:
231 * ParentOrigin::TOP_CENTER
233 * @note The tail images are defined inside PopupStyle as
234 * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
236 * @param[in] position A position around the perimeter of the Parent.
238 void ShowTail(const Vector3& position);
241 * @brief Hides the tail.
245 public: // Not intended for application developers
248 * @brief Creates a handle using the Toolkit::Internal implementation.
250 * @param[in] implementation The Control implementation.
252 DALI_INTERNAL Popup(Internal::Popup& implementation);
255 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
257 * @param[in] internal A pointer to the internal CustomActor.
259 explicit DALI_INTERNAL Popup( Dali::Internal::CustomActor* internal );
262 } // namespace Toolkit
266 #endif // __DALI_TOOLKIT_POPUP_H__