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>
23 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
31 namespace Internal DALI_INTERNAL
39 * @brief Popup contains content that can come into focus when activated, and out of focus when deactivated.
43 * The content within a popup consists of:
47 * 3. Background/Frame (i.e. Scale-9 image)
48 * 4. Custom Content (Actors)
50 * All of which are optional.
54 * A popup can be in a number of states:
57 * 2. SHOW (visible at normal size)
58 * 3. SHOW_MAXIMIZED (visible occupying full parent size)
59 * 4. Or custom defined.
63 * A popup can use various custom transition effects, e.g.
64 * Alpha fade, Scaling transition, position/rotation, shader effects.
66 class DALI_IMPORT_API Popup : public Control
72 static const char* const SIGNAL_TOUCHED_OUTSIDE; ///< name "touched-outside"
73 static const char* const SIGNAL_HIDDEN; ///< name "hidden"
76 * @brief Current popup state.
80 POPUP_NONE, ///< Init status
81 POPUP_HIDE, ///< Hidden (not visible)
82 POPUP_SHOW, ///< Shown (visible in default size)
85 typedef SignalV2< void () > TouchedOutsideSignalV2; ///< Touched outside signal type.
86 typedef SignalV2< void () > HiddenSignalV2; ///< Hidden signal type.
89 * @brief Signal emitted when user has touched outside of the Dialog.
91 TouchedOutsideSignalV2& OutsideTouchedSignal();
94 * @brief Signal emitted when popup has been hidden.
96 HiddenSignalV2& HiddenSignal();
101 * @brief Creates an empty Popup handle.
106 * @brief Copy constructor.
108 * Creates another handle that points to the same real object
109 * @param[in] handle Handle to the copied object
111 Popup( const Popup& handle );
114 * @brief Assignment operator.
116 * Changes this handle to point to another real object
117 * @param[in] handle Handle to the object
118 * @return A reference to this
120 Popup& operator=( const Popup& handle );
125 * This is non-virtual since derived Handle types must not contain data or virtual methods.
130 * @brief Create the Poup control.
132 * @return A handle to the Popup control.
137 * @brief Downcast an Object handle to Popup.
139 * If handle points to a Popup the
140 * downcast produces valid handle. If not the returned handle is left uninitialized.
141 * @param[in] handle Handle to an object
142 * @return handle to a Popup or an uninitialized handle
144 static Popup DownCast( BaseHandle handle );
149 * @brief Sets the background image for this Popup.
151 * The background is resized (stretched according to scale settings),
152 * to the size of the Popup.
154 * @param[in] image The Background ImageActor to cover background
156 void SetBackgroundImage( Actor image );
159 * @brief Sets a title for this Popup.
161 * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
163 * @param[in] text The text to appear as the heading for this Popup
165 void SetTitle( const std::string& text );
168 * @brief Sets a title for this Popup.
170 * @param[in] titleActor The TextView to appear as the heading for this Popup
172 void SetTitle( TextView titleActor );
175 * @brief Gets the text (TextView) for this Popup.
177 * @return The TextView representing this popup is returned.
179 TextView GetTitle() const;
182 * @brief Adds a button to this Popup.
184 * Buttons are added to the bottom of the Popup and Centered.
186 * By default the first button added will have the focus, and the focus will
187 * shift to other buttons based on the sequence in which they are added to the popup.
189 * @param[in] button The button to be added to this Popup
191 void AddButton( Button button );
194 * @brief Sets state of Popup, such as HIDE, and SHOW.
196 * The Popup will instantaneously jump to this state.
198 * @param[in] state The state of the popup
200 void SetState( PopupState state );
203 * @brief Sets state of Popup, such as HIDE, and SHOW.
205 * The Popup will smoothly animate to this state.
207 * @param[in] state The state of the popup
208 * @param[in] duration The time to animate to this new state.
210 void SetState( PopupState state, float duration );
213 * @brief Gets the state of the popup.
215 * @return The state of the popup.
217 PopupState GetState() const;
220 * @brief Shows the popup.
222 * The Popup will animate to the SHOW state
227 * @brief Hides the popup.
229 * The Popup will animate to the HIDE state
234 * @brief Shows the tail.
236 * The tail position is specified relative to it's Parent.
237 * To display at top center for instace, pass:
239 * ParentOrigin::TOP_CENTER
241 * @note The tail images are defined inside PopupStyle as
242 * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
244 * @param[in] position A position around the perimeter of the Parent.
246 void ShowTail(const Vector3& position);
249 * @brief Hides the tail.
253 public: // Not intended for application developers
256 * @brief Creates a handle using the Toolkit::Internal implementation.
258 * @param[in] implementation The Control implementation.
260 DALI_INTERNAL Popup(Internal::Popup& implementation);
263 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
265 * @param[in] internal A pointer to the internal CustomActor.
267 explicit DALI_INTERNAL Popup( Dali::Internal::CustomActor* internal );
270 } // namespace Toolkit
274 #endif // __DALI_TOOLKIT_POPUP_H__