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_FRAMEWORK
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 * Popup contains content that can come into focus when
44 * 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.
70 * Alpha fade, Scaling transition, position/rotation, shader effects.
73 class Popup : public Control
79 static const char* const SIGNAL_TOUCHED_OUTSIDE;
80 static const char* const SIGNAL_HIDDEN;
87 POPUP_NONE, ///< Init status
88 POPUP_HIDE, ///< Hidden (not visible)
89 POPUP_SHOW, ///< Shown (visible in default size)
92 typedef SignalV2< void () > TouchedOutsideSignalV2;
93 typedef SignalV2< void () > HiddenSignalV2;
96 * Signal emitted when user has touched outside of the Dialog.
98 TouchedOutsideSignalV2& OutsideTouchedSignal();
101 * Signal emitted when popup has been hidden.
103 HiddenSignalV2& HiddenSignal();
108 * Creates an empty Popup handle
113 * Copy constructor. Creates another handle that points to the same real object
115 Popup( const Popup& handle );
118 * Assignment operator. Changes this handle to point to another real object
120 Popup& operator=( const Popup& handle );
123 * Virtual destructor.
124 * Dali::Object derived classes typically do not contain member data.
129 * Create the Poup control
130 * @return A handle to the Popup control.
135 * Downcast an Object handle to Popup. If handle points to a Popup the
136 * downcast produces valid handle. If not the returned handle is left uninitialized.
137 * @param[in] handle Handle to an object
138 * @return handle to a Popup or an uninitialized handle
140 static Popup DownCast( BaseHandle handle );
145 * Sets the background image for this Popup.
147 * The background is resized (stretched according to scale settings),
148 * to the size of the Popup.
150 * @param[in] image The Background ImageActor to cover background
152 void SetBackgroundImage( Actor image );
155 * Sets a title for this Popup.
157 * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
159 * @param[in] text The text to appear as the heading for this Popup
161 void SetTitle( const std::string& text );
164 * Sets a title for this Popup.
166 * @param[in] titleActor The TextView to appear as the heading for this Popup
168 void SetTitle( TextView titleActor );
171 * Gets the text (TextView) for this Popup.
173 * @return The TextView representing this popup is returned.
175 TextView GetTitle() const;
178 * Adds a button to this Popup.
180 * Buttons are added to the bottom of the Popup and Centered.
182 * By default the first button added will have the focus, and the focus will
183 * shift to other buttons based on the sequence in which they are added to the popup.
185 * @param[in] button The button to be added to this Popup
187 void AddButton( Button button );
190 * Sets state of Popup, such as HIDE, and SHOW.
192 * The Popup will instantaneously jump to this state.
194 * @param[in] state The state of the popup
196 void SetState( PopupState state );
199 * Sets state of Popup, such as HIDE, and SHOW.
201 * The Popup will smoothly animate to this state.
203 * @param[in] state The state of the popup
204 * @param[in] duration The time to animate to this new state.
206 void SetState( PopupState state, float duration );
209 * Gets the state of the popup.
210 * @return The state of the popup.
212 PopupState GetState() const;
217 * The Popup will animate to the SHOW state
224 * The Popup will animate to the HIDE state
231 * The tail position is specified relative to it's Parent.
232 * To display at top center for instace, pass:
234 * ParentOrigin::TOP_CENTER
236 * @note The tail images are defined inside PopupStyle as
237 * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
239 * @param[in] position A position around the perimeter of the Parent.
241 void ShowTail(const Vector3& position);
248 public: // Not intended for application developers
251 * Creates a handle using the Toolkit::Internal implementation.
252 * @param[in] implementation The Control implementation.
254 Popup(Internal::Popup& implementation);
257 * Allows the creation of this Control from an Internal::CustomActor pointer.
258 * @param[in] internal A pointer to the internal CustomActor.
260 Popup( Dali::Internal::CustomActor* internal );
263 } // namespace Toolkit
270 #endif // __DALI_TOOLKIT_POPUP_H__