1 #ifndef __DALI_TOOLKIT_INTERNAL_POPUP_H__
2 #define __DALI_TOOLKIT_INTERNAL_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/public-api/actors/image-actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/animation/animation.h>
27 #include <dali-toolkit/public-api/controls/control-impl.h>
28 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
29 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
30 #include <dali-toolkit/devel-api/controls/popup/popup.h>
31 #include <dali-toolkit/internal/controls/popup/popup-style-impl.h>
47 typedef IntrusivePtr<Popup> PopupPtr;
48 typedef IntrusivePtr<PopupStyle> PopupStylePtr;
51 * @copydoc Toolkit::Popup
53 class Popup : public Control
59 * @return A public handle to the newly allocated Popup.
61 static Dali::Toolkit::Popup New();
66 * Returns number of buttons added to Popup
68 * @return Number of buttons
70 size_t GetButtonCount() const;
73 * @copydoc Toolkit::Popup::SetBackgroundImage
75 void SetBackgroundImage( Actor image );
78 * @copydoc Toolkit::Popup::SetButtonAreaImage
80 void SetButtonAreaImage( Actor image );
83 * @copydoc Toolkit::Popup::SetTitle( const std::string& text );
85 void SetTitle( const std::string& text );
88 * @copydoc Toolkit::Popup::GetTitle
90 std::string GetTitle() const;
93 * @copydoc Toolkit::Popup::AddButton
95 void AddButton( Toolkit::Button button );
98 * @copydoc Toolkit::Popup::SetState( PopupState state )
100 void SetState( Toolkit::Popup::PopupState state );
103 * @copydoc Toolkit::Popup::SetState( PopupState state, float duration )
105 void SetState( Toolkit::Popup::PopupState state, float duration );
108 * @copydoc Toolkit::Popup::GetState( )
110 Toolkit::Popup::PopupState GetState() const;
113 * @copydoc Toolkit::Popup::ShowTail
115 void ShowTail(const Vector3& position);
118 * @copydoc Toolkit::Popup::HideTail
123 * Sets the style of the popup
124 * @param[in] style The style of the popup
126 void SetStyle(PopupStyle& style);
129 * Gets the style of the popup
130 * @return style of the popup
132 PopupStylePtr GetStyle() const;
137 * Construct a new Popup.
138 * @param[in] style of the popup
140 Popup(PopupStyle& style);
143 * A reference counted object may only be deleted by calling Unreference()
150 * Creates and applies the default background image.
152 void SetDefaultBackgroundImage();
156 * (covers all content behind the dialog)
158 void CreateBacking();
162 * (dialog content resides inside this - buttons, title etc.)
167 * Animate Popup by scaling uniformally from 0 to 100% and vice versa (default behaviour)
168 * @param[in] state The desired state to change into.
169 * @param[in] duration The time for this animation to take.
171 void HandleStateChange( Toolkit::Popup::PopupState state, float duration );
174 * Invoked once StateChange has completed.
176 void HandleStateChangeComplete();
181 * @copydoc Dali::Toolkit::Popup::OutsideTouchedSignal()
183 Toolkit::Popup::TouchedOutsideSignalType& OutsideTouchedSignal();
186 * @copydoc Dali::Toolkit::Popup::HiddenSignal()
188 Toolkit::Popup::HiddenSignalType& HiddenSignal();
191 * Connects a callback function with the object's signals.
192 * @param[in] object The object providing the signal.
193 * @param[in] tracker Used to disconnect the signal.
194 * @param[in] signalName The signal to connect to.
195 * @param[in] functor A newly allocated FunctorDelegate.
196 * @return True if the signal was connected.
197 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
199 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
204 * Signal occurs when the State animation (transition from hide<->show) finishes
205 * @param[in] source The animation that just finished.
207 void OnStateAnimationFinished( Animation& source );
210 * Signal occurs when the dimmed backing for the Popup is touched.
211 * @param[in] actor The Actor Touched
212 * @param[in] event The Touch Event.
213 * @return Whether to consume event or not.
215 bool OnBackingTouched(Actor actor, const TouchEvent& event);
218 * Signal occurs when the mouse wheel event is occured on dimmed backing for the Popup.
219 * @param[in] actor The Actor got mouse wheel
220 * @param[in] event The Mouse Wheel Event.
221 * @return Whether to consume event or not.
223 bool OnBackingMouseWheelEvent(Actor actor, const MouseWheelEvent& event);
226 * Signal occurs when the dialog has been touched.
227 * @param[in] actor The Actor Touched
228 * @param[in] event The Touch Event.
229 * @return Whether to consume event or not.
231 bool OnDialogTouched(Actor actor, const TouchEvent& event);
234 * @copydoc Toolkit::Control::OnInitialize()
236 virtual void OnInitialize();
239 * @copydoc Dali::CustomActorImpl::OnPropertySet()
241 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
244 * From Control; called after a child has been added to the owning actor.
245 * @param[in] child The child which has been added.
247 virtual void OnControlChildAdd( Actor& child );
250 * @copydoc Control::OnRelayOut()
252 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
255 * @copydoc Control::OnSetResizePolicy()
257 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
260 * @copydoc Control::OnKeyEvent()
262 virtual bool OnKeyEvent(const KeyEvent& event);
265 * @copydoc Control::GetNaturalSize()
267 virtual Vector3 GetNaturalSize();
270 * @copydoc Control::GetHeightForWidth()
272 float GetHeightForWidth( float width );
275 * @copydoc Control::GetWidthForHeight()
277 float GetWidthForHeight( float height );
280 * @copydoc Control::GetNextKeyboardFocusableActor()
282 Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
285 * Create the root actor for the footer
295 Popup& operator=(const Popup& rhs);
302 Vector3 mContentSize;
303 Vector3 mButtonBgSize;
304 std::vector<Vector3> mButtonSize;
309 bool mShowing; ///< Popup is showing or not
311 Layer mLayer; ///< Popup Layer (i.e. Dim backing and PopupBg reside in this)
312 Toolkit::TableView mPopupLayout; ///< Popup layout (i.e. dialog reside in this)
313 ImageActor mBacking; ///< Backing actor (dim effect)
315 Actor mPreviousFocusedActor; ///< Store the previous focused actor to restore the focus when popup hide
317 Actor mBackgroundImage; ///< Stores the background image.
318 Actor mButtonAreaImage; ///< Stores the button background image.
319 Toolkit::TextLabel mTitle; ///< Stores the text title.
320 Actor mContent; ///< Stores popup's content.
321 Actor mBottomBg; ///< bottom button bar background. ImageActor is replaced with Actor due to hidden image.
322 Actor mTailImage; ///< Stores the tail image
324 std::vector< Actor > mButtons; ///< Keeps track of the buttons added to this popup.
325 Toolkit::Popup::PopupState mState; ///< Popup current state.
326 Animation mAnimation; ///< The animation instance managing state changing.
327 bool mAlterAddedChild; ///< Flag used to control whether children are reparented or not.
328 PopupStylePtr mPopupStyle; ///< The style to be used for this popup.
330 LayoutInfo mLayoutInfo; ///< Stores sizes of all popup components.
332 Toolkit::Popup::TouchedOutsideSignalType mTouchedOutsideSignal;
333 Toolkit::Popup::HiddenSignalType mHiddenSignal;
335 Property::Index mPropertyTitle; ///< Property index for Title.
336 Property::Index mPropertyState; ///< Property index for popup state.
339 } // namespace Internal
341 // Helpers for public-api forwarding methods
343 inline Toolkit::Internal::Popup& GetImpl(Toolkit::Popup& pub)
345 DALI_ASSERT_ALWAYS(pub);
347 Dali::RefObject& handle = pub.GetImplementation();
349 return static_cast<Toolkit::Internal::Popup&>(handle);
352 inline const Toolkit::Internal::Popup& GetImpl(const Toolkit::Popup& pub)
354 DALI_ASSERT_ALWAYS(pub);
356 const Dali::RefObject& handle = pub.GetImplementation();
358 return static_cast<const Toolkit::Internal::Popup&>(handle);
361 } // namespace Toolkit
365 #endif // __DALI_TOOLKIT_INTERNAL_POPUP_H__