1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_POPUP_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_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/dali.h>
24 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
37 class TextInputPopup : public ConnectionTracker
51 static const char* const SIGNAL_PRESSED;
52 static const char* const SIGNAL_HIDE_FINISHED;
53 static const char* const SIGNAL_SHOW_FINISHED;
55 // Popup Button Pressed
56 typedef SignalV2< bool( Toolkit::Button ) > PressedSignalV2;
58 // Popup Hide Finished
59 typedef SignalV2< void( TextInputPopup& ) > HideFinishedSignalV2;
61 // Popup Show Finished
62 typedef SignalV2< void( TextInputPopup& ) > ShowFinishedSignalV2;
65 * Signal emitted when the button is touched.
67 PressedSignalV2& PressedSignal();
70 * Signal emitted when popup is completely hidden
71 * @note Only occurs after a Show() call with animation enabled.
73 HideFinishedSignalV2& HideFinishedSignal();
76 * Signal emitted when popup is completely shown
77 * @note Only occurs after a Hide() call with animation enabled.
79 ShowFinishedSignalV2& ShowFinishedSignal();
85 * Creates an empty popup base actor (no content i.e. invisible)
90 * @return The root actor of for this popup is returned.
95 * Clears popup options (popup no longer exists)
101 * @param[in] styledCaption The text to be displayed
102 * @return the newly created label
104 Toolkit::TextView CreateOptionText( const MarkupProcessor::StyledTextArray& styledCaption );
108 * @param[in] iconImage the image to be used
109 * @return the newly created Image actor to be used as the icon
111 ImageActor CreateOptionIcon( Image iconImage );
114 * Creates and sets up the popup background
116 void CreatePopUpBackground();
119 * Create divider if multiple options
121 void CreateDivider();
124 * Create a background to be used when button pressed
125 * @param[in] requiredSize size Image actor should be
126 * @param[in] finalFlag flag to be set if option is the final one.
127 * @return Returns an Image Actor to be used a pressed background
129 ImageActor CreatePressedBackground( const Vector3 requiredSize, const bool finalFlag );
132 * Adds a popup option.
133 * @note Creates popup frame if not already created.
134 * @param[in] name The unique name for this option.
135 * @param[in] caption The caption (label) for this option
136 * @param[in] iconImage Image to displayed with text.
137 * @param[in] finalOption Flag to indicate that this is the final option.
138 * (set to true on the last option you add)
140 void AddOption(const std::string& name, const std::string& caption, const Image iconImage, bool finalOption);
144 * @param[in] animate (optional) whether to animate popup to hide state over time (i.e. tween).
146 void Hide(bool animate = true);
150 * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
152 void Show(bool animate = true);
155 * Sets Alternative offset property.
156 * The alternative offset property is how much to move in the horizontal and vertical
157 * axes when the popup goes out of the screen on the left/right sides or top/bottom sides.
158 * @param[in] offset Vector holding the left/right offset (x) and top/bottom offset (y)
160 void SetAlternativeOffset(Vector2 offset);
163 * Returns the current state of the popup.
164 * @return The state of the popup see enum State
166 State GetState(void) const;
169 * Get the root actor which the buttons are added to.
170 * @return the root actor
172 Actor GetRootActor() const;
177 * Adds popup to the stage (ideally on a separate top-most layer and as an overlay)
182 * Applies constraint to keep Popup in view within the desired area.
184 void ApplyConfinementConstraint();
187 * Removes popup from the stage.
189 void RemoveFromStage();
192 * Called when a button is pressed in the popup
193 * @param[in] button The button pressed.
195 bool OnButtonPressed( Toolkit::Button button );
198 * Invoked upon popup Hide animation completing.
199 * @note Only called for animating hide, not called for instantaneous (animate = false)
200 * @param[in] source The animation which completed.
202 void OnHideFinished(Animation& source);
205 * Invoked upon popup Show animation completing.
206 * @note Only called for animating show, not called for instantaneous (animate = false)
207 * @param[in] source The animation which completed.
209 void OnShowFinished(Animation& source);
213 State mState; ///< Popup State.
214 Actor mRootActor; ///< The actor which all popup content is added to (i.e. panel and buttons)
215 Property::Index mAlternativeOffsetProperty; ///< Property [Vector3] how much to offset the popup if it goes out of the screen
216 ImageActor mBackground; ///< The background popup panel
217 ImageActor mTail; ///< The tail for the popup
218 Vector3 mContentSize; ///< Size of Content (i.e. Buttons)
219 ActorContainer mButtonContainer; ///< List of buttons added to popup.
220 ActorContainer mDividerContainer; ///< List of dividers added to popup.
221 Animation mAnimation; ///< Popup Hide/Show animation.
223 PressedSignalV2 mPressedSignal; ///< Signal emitted when a button within the popup is pressed.
224 HideFinishedSignalV2 mHideFinishedSignal; ///< Signal emitted when popup is completely hidden
225 ShowFinishedSignalV2 mShowFinishedSignal; ///< Signal emitted when popup is completely shown
229 } // namespace Internal
231 } // namespace Toolkit
235 #endif // __DALI_TOOLKIT_INTERNAL_ITEM_VIEW_H__