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/popup/popup.h>
29 #include <dali-toolkit/internal/controls/popup/popup-style-impl.h>
45 typedef IntrusivePtr<Popup> PopupPtr;
46 typedef IntrusivePtr<PopupStyle> PopupStylePtr;
49 * @copydoc Toolkit::Popup
51 class Popup : public Control
57 * @return A public handle to the newly allocated Popup.
59 static Dali::Toolkit::Popup New();
64 * Returns number of buttons added to Popup
66 * @return Number of buttons
68 size_t GetButtonCount() const;
71 * @copydoc Toolkit::Popup::SetBackgroundImage
73 void SetBackgroundImage( Actor image );
76 * @copydoc Toolkit::Popup::SetButtonAreaImage
78 void SetButtonAreaImage( Actor image );
81 * @copydoc Toolkit::Popup::SetTitle( const std::string& text );
83 void SetTitle( const std::string& text );
86 * @copydoc Toolkit::Popup::SetTitle( TextView titleActor )
88 void SetTitle( Toolkit::TextView titleActor );
91 * @copydoc Toolkit::Popup::GetTitle
93 Toolkit::TextView GetTitle() const;
96 * @copydoc Toolkit::Popup::AddButton
98 void AddButton( Toolkit::Button button );
101 * @copydoc Toolkit::Popup::SetState( PopupState state )
103 void SetState( Toolkit::Popup::PopupState state );
106 * @copydoc Toolkit::Popup::SetState( PopupState state, float duration )
108 void SetState( Toolkit::Popup::PopupState state, float duration );
111 * @copydoc Toolkit::Popup::GetState( )
113 Toolkit::Popup::PopupState GetState() const;
116 * @copydoc Toolkit::Popup::ShowTail
118 void ShowTail(const Vector3& position);
121 * @copydoc Toolkit::Popup::HideTail
127 * Sets the style of the popup
128 * @param[in] style The style of the popup
130 void SetStyle(PopupStyle& style);
133 * Gets the style of the popup
134 * @return style of the popup
136 PopupStylePtr GetStyle() const;
141 * Construct a new Popup.
142 * @param[in] style of the popup
144 Popup(PopupStyle& style);
147 * A reference counted object may only be deleted by calling Unreference()
154 * Creates and applies the default background image.
156 void SetDefaultBackgroundImage();
160 * (covers all content behind the dialog)
162 void CreateBacking();
166 * (dialog content resides inside this - buttons, title etc.)
171 * Animate Popup by scaling uniformally from 0 to 100% and vice versa (default behaviour)
172 * @param[in] state The desired state to change into.
173 * @param[in] duration The time for this animation to take.
175 void HandleStateChange( Toolkit::Popup::PopupState state, float duration );
178 * Invoked once StateChange has completed.
180 void HandleStateChangeComplete();
185 * @copydoc Dali::Toolkit::Popup::OutsideTouchedSignal()
187 Toolkit::Popup::TouchedOutsideSignalV2& OutsideTouchedSignal();
190 * @copydoc Dali::Toolkit::Popup::HiddenSignal()
192 Toolkit::Popup::HiddenSignalV2& HiddenSignal();
195 * Connects a callback function with the object's signals.
196 * @param[in] object The object providing the signal.
197 * @param[in] tracker Used to disconnect the signal.
198 * @param[in] signalName The signal to connect to.
199 * @param[in] functor A newly allocated FunctorDelegate.
200 * @return True if the signal was connected.
201 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
203 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
208 * Signal occurs when the State animation (transition from hide<->show) finishes
209 * @param[in] source The animation that just finished.
211 void OnStateAnimationFinished( Animation& source );
214 * Signal occurs when the dimmed backing for the Popup is touched.
215 * @param[in] actor The Actor Touched
216 * @param[in] event The Touch Event.
217 * @return Whether to consume event or not.
219 bool OnBackingTouched(Actor actor, const TouchEvent& event);
222 * Signal occurs when the mouse wheel event is occured on dimmed backing for the Popup.
223 * @param[in] actor The Actor got mouse wheel
224 * @param[in] event The Mouse Wheel Event.
225 * @return Whether to consume event or not.
227 bool OnBackingMouseWheelEvent(Actor actor, const MouseWheelEvent& event);
230 * Signal occurs when the dialog has been touched.
231 * @param[in] actor The Actor Touched
232 * @param[in] event The Touch Event.
233 * @return Whether to consume event or not.
235 bool OnDialogTouched(Actor actor, const TouchEvent& event);
238 * @copydoc Toolkit::Control::OnInitialize()
240 virtual void OnInitialize();
243 * @copydoc Dali::CustomActorImpl::OnPropertySet()
245 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
248 * From Control; called after a child has been added to the owning actor.
249 * @param[in] child The child which has been added.
251 virtual void OnControlChildAdd( Actor& child );
254 * @copydoc Control::OnRelaidOut()
256 virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
259 * @copydoc Control::OnKeyEvent()
261 virtual bool OnKeyEvent(const KeyEvent& event);
264 * @copydoc Control::GetNaturalSize()
266 virtual Vector3 GetNaturalSize();
269 * @copydoc Control::GetHeightForWidth()
271 float GetHeightForWidth( float width );
274 * @copydoc Control::GetWidthForHeight()
276 float GetWidthForHeight( float height );
279 * @copydoc Control::GetNextKeyboardFocusableActor()
281 Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
289 Popup& operator=(const Popup& rhs);
296 Vector3 mContentSize;
297 Vector3 mButtonBgSize;
298 std::vector<Vector3> mButtonSize;
303 bool mShowing; ///< Popup is showing or not
305 Layer mLayer; ///< Popup Layer (i.e. Dim backing and PopupBg reside in this)
306 Actor mPopupBg; ///< Popup Background (i.e. dialog reside in this)
307 ImageActor mBacking; ///< Backing actor (dim effect)
309 Actor mPreviousFocusedActor; ///< Store the previous focused actor to restore the focus when popup hide
311 Actor mBackgroundImage; ///< Stores the background image.
312 Actor mButtonAreaImage; ///< Stores the button background image.
313 Toolkit::TextView mTitle; ///< Stores the text title.
314 Actor mContent; ///< Stores popup's content.
315 Actor mBottomBg; ///< bottom button bar background. ImageActor is replaced with Actor due to hidden image.
316 Actor mTailImage; ///< Stores the tail image
318 ActorContainer mButtons; ///< Keeps track of the buttons added to this popup.
319 Toolkit::Popup::PopupState mState; ///< Popup current state.
320 Animation mAnimation; ///< The animation instance managing state changing.
321 bool mAlterAddedChild; ///< Flag used to control whether children are reparented or not.
322 PopupStylePtr mPopupStyle; ///< The style to be used for this popup.
324 LayoutInfo mLayoutInfo; ///< Stores sizes of all popup components.
326 Toolkit::Popup::TouchedOutsideSignalV2 mTouchedOutsideSignalV2;
327 Toolkit::Popup::HiddenSignalV2 mHiddenSignalV2;
329 Property::Index mPropertyTitle; ///< Property index for Title.
330 Property::Index mPropertyState; ///< Property index for popup state.
333 } // namespace Internal
335 // Helpers for public-api forwarding methods
337 inline Toolkit::Internal::Popup& GetImpl(Toolkit::Popup& pub)
339 DALI_ASSERT_ALWAYS(pub);
341 Dali::RefObject& handle = pub.GetImplementation();
343 return static_cast<Toolkit::Internal::Popup&>(handle);
346 inline const Toolkit::Internal::Popup& GetImpl(const Toolkit::Popup& pub)
348 DALI_ASSERT_ALWAYS(pub);
350 const Dali::RefObject& handle = pub.GetImplementation();
352 return static_cast<const Toolkit::Internal::Popup&>(handle);
355 } // namespace Toolkit
359 #endif // __DALI_TOOLKIT_INTERNAL_POPUP_H__