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 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 #include <dali/dali.h>
23 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
36 class TextInputPopup : public ConnectionTracker
50 static const char* const SIGNAL_PRESSED;
51 static const char* const SIGNAL_HIDE_FINISHED;
52 static const char* const SIGNAL_SHOW_FINISHED;
54 // Popup Button Pressed
55 typedef SignalV2< bool( Toolkit::Button ) > PressedSignalV2;
57 // Popup Hide Finished
58 typedef SignalV2< void( TextInputPopup& ) > HideFinishedSignalV2;
60 // Popup Show Finished
61 typedef SignalV2< void( TextInputPopup& ) > ShowFinishedSignalV2;
64 * Signal emitted when the button is touched.
66 PressedSignalV2& PressedSignal();
69 * Signal emitted when popup is completely hidden
70 * @note Only occurs after a Show() call with animation enabled.
72 HideFinishedSignalV2& HideFinishedSignal();
75 * Signal emitted when popup is completely shown
76 * @note Only occurs after a Hide() call with animation enabled.
78 ShowFinishedSignalV2& ShowFinishedSignal();
84 * Creates an empty popup base actor (no content i.e. invisible)
89 * @return The root actor of for this popup is returned.
94 * Clears popup options (popup no longer exists)
100 * @param[in] styledCaption The text to be displayed
101 * @return the newly created label
103 Toolkit::TextView CreateOptionText( const MarkupProcessor::StyledTextArray& styledCaption );
107 * @param[in] iconImage the image to be used
108 * @return the newly created Image actor to be used as the icon
110 ImageActor CreateOptionIcon( Image iconImage );
113 * Creates and sets up the popup background
115 void CreatePopUpBackground();
118 * Create divider if multiple options
120 void CreateDivider();
123 * Create a background to be used when button pressed
124 * @param[in] requiredSize size Image actor should be
125 * @param[in] finalFlag flag to be set if option is the final one.
126 * @return Returns an Image Actor to be used a pressed background
128 ImageActor CreatePressedBackground( const Vector3 requiredSize, const bool finalFlag );
131 * Adds a popup option.
132 * @note Creates popup frame if not already created.
133 * @param[in] name The unique name for this option.
134 * @param[in] caption The caption (label) for this option
135 * @param[in] iconImage Image to displayed with text.
136 * @param[in] finalOption Flag to indicate that this is the final option.
137 * (set to true on the last option you add)
139 void AddOption(const std::string& name, const std::string& caption, const Image iconImage, bool finalOption);
143 * @param[in] animate (optional) whether to animate popup to hide state over time (i.e. tween).
145 void Hide(bool animate = true);
149 * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
151 void Show(bool animate = true);
154 * Sets Alternative offset property.
155 * The alternative offset property is how much to move in the horizontal and vertical
156 * axes when the popup goes out of the screen on the left/right sides or top/bottom sides.
157 * @param[in] offset Vector holding the left/right offset (x) and top/bottom offset (y)
159 void SetAlternativeOffset(Vector2 offset);
162 * Returns the current state of the popup.
163 * @return The state of the popup see enum State
165 State GetState(void) const;
168 * Get the root actor which the buttons are added to.
169 * @return the root actor
171 Actor GetRootActor() const;
176 * Adds popup to the stage (ideally on a separate top-most layer and as an overlay)
181 * Applies constraint to keep Popup in view within the desired area.
183 void ApplyConfinementConstraint();
186 * Removes popup from the stage.
188 void RemoveFromStage();
191 * Called when a button is pressed in the popup
192 * @param[in] button The button pressed.
194 bool OnButtonPressed( Toolkit::Button button );
197 * Invoked upon popup Hide animation completing.
198 * @note Only called for animating hide, not called for instantaneous (animate = false)
199 * @param[in] source The animation which completed.
201 void OnHideFinished(Animation& source);
204 * Invoked upon popup Show animation completing.
205 * @note Only called for animating show, not called for instantaneous (animate = false)
206 * @param[in] source The animation which completed.
208 void OnShowFinished(Animation& source);
212 State mState; ///< Popup State.
213 Actor mRootActor; ///< The actor which all popup content is added to (i.e. panel and buttons)
214 Property::Index mAlternativeOffsetProperty; ///< Property [Vector3] how much to offset the popup if it goes out of the screen
215 ImageActor mBackground; ///< The background popup panel
216 ImageActor mTail; ///< The tail for the popup
217 Vector3 mContentSize; ///< Size of Content (i.e. Buttons)
218 ActorContainer mButtonContainer; ///< List of buttons added to popup.
219 ActorContainer mDividerContainer; ///< List of dividers added to popup.
220 Animation mAnimation; ///< Popup Hide/Show animation.
222 PressedSignalV2 mPressedSignal; ///< Signal emitted when a button within the popup is pressed.
223 HideFinishedSignalV2 mHideFinishedSignal; ///< Signal emitted when popup is completely hidden
224 ShowFinishedSignalV2 mShowFinishedSignal; ///< Signal emitted when popup is completely shown
228 } // namespace Internal
230 } // namespace Toolkit
234 #endif // __DALI_TOOLKIT_INTERNAL_ITEM_VIEW_H__