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>
30 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
31 #include <dali-toolkit/public-api/controls/text-controls/text-label.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;
135 * @copydoc Toolkit::Popup::MarkDirtyForRelayout
137 void MarkDirtyForRelayout();
142 * Construct a new Popup.
143 * @param[in] style of the popup
145 Popup(PopupStyle& style);
148 * A reference counted object may only be deleted by calling Unreference()
155 * Creates and applies the default background image.
157 void SetDefaultBackgroundImage();
161 * (covers all content behind the dialog)
163 void CreateBacking();
167 * (dialog content resides inside this - buttons, title etc.)
172 * Animate Popup by scaling uniformally from 0 to 100% and vice versa (default behaviour)
173 * @param[in] state The desired state to change into.
174 * @param[in] duration The time for this animation to take.
176 void HandleStateChange( Toolkit::Popup::PopupState state, float duration );
179 * Invoked once StateChange has completed.
181 void HandleStateChangeComplete();
186 * @copydoc Dali::Toolkit::Popup::OutsideTouchedSignal()
188 Toolkit::Popup::TouchedOutsideSignalType& OutsideTouchedSignal();
191 * @copydoc Dali::Toolkit::Popup::HiddenSignal()
193 Toolkit::Popup::HiddenSignalType& HiddenSignal();
196 * Connects a callback function with the object's signals.
197 * @param[in] object The object providing the signal.
198 * @param[in] tracker Used to disconnect the signal.
199 * @param[in] signalName The signal to connect to.
200 * @param[in] functor A newly allocated FunctorDelegate.
201 * @return True if the signal was connected.
202 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
204 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
209 * Signal occurs when the State animation (transition from hide<->show) finishes
210 * @param[in] source The animation that just finished.
212 void OnStateAnimationFinished( Animation& source );
215 * Signal occurs when the dimmed backing for the Popup is touched.
216 * @param[in] actor The Actor Touched
217 * @param[in] event The Touch Event.
218 * @return Whether to consume event or not.
220 bool OnBackingTouched(Actor actor, const TouchEvent& event);
223 * Signal occurs when the mouse wheel event is occured on dimmed backing for the Popup.
224 * @param[in] actor The Actor got mouse wheel
225 * @param[in] event The Mouse Wheel Event.
226 * @return Whether to consume event or not.
228 bool OnBackingMouseWheelEvent(Actor actor, const MouseWheelEvent& event);
231 * Signal occurs when the dialog has been touched.
232 * @param[in] actor The Actor Touched
233 * @param[in] event The Touch Event.
234 * @return Whether to consume event or not.
236 bool OnDialogTouched(Actor actor, const TouchEvent& event);
239 * @copydoc Toolkit::Control::OnInitialize()
241 virtual void OnInitialize();
244 * @copydoc Dali::CustomActorImpl::OnPropertySet()
246 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
249 * From Control; called after a child has been added to the owning actor.
250 * @param[in] child The child which has been added.
252 virtual void OnControlChildAdd( Actor& child );
255 * @copydoc Control::OnRelayOut()
257 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
260 * @copydoc Control::OnSetResizePolicy()
262 virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension );
265 * @copydoc Control::OnKeyEvent()
267 virtual bool OnKeyEvent(const KeyEvent& event);
270 * @copydoc Control::GetNaturalSize()
272 virtual Vector3 GetNaturalSize();
275 * @copydoc Control::GetHeightForWidth()
277 float GetHeightForWidth( float width );
280 * @copydoc Control::GetWidthForHeight()
282 float GetWidthForHeight( float height );
285 * @copydoc Control::GetNextKeyboardFocusableActor()
287 Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
290 * Create the root actor for the footer
300 Popup& operator=(const Popup& rhs);
307 Vector3 mContentSize;
308 Vector3 mButtonBgSize;
309 std::vector<Vector3> mButtonSize;
314 bool mShowing; ///< Popup is showing or not
316 Layer mLayer; ///< Popup Layer (i.e. Dim backing and PopupBg reside in this)
317 Toolkit::TableView mPopupLayout; ///< Popup layout (i.e. dialog reside in this)
318 ImageActor mBacking; ///< Backing actor (dim effect)
320 Actor mPreviousFocusedActor; ///< Store the previous focused actor to restore the focus when popup hide
322 Actor mBackgroundImage; ///< Stores the background image.
323 Actor mButtonAreaImage; ///< Stores the button background image.
324 Toolkit::TextLabel mTitle; ///< Stores the text title.
325 Actor mContent; ///< Stores popup's content.
326 Actor mBottomBg; ///< bottom button bar background. ImageActor is replaced with Actor due to hidden image.
327 Actor mTailImage; ///< Stores the tail image
329 ActorContainer mButtons; ///< Keeps track of the buttons added to this popup.
330 Toolkit::Popup::PopupState mState; ///< Popup current state.
331 Animation mAnimation; ///< The animation instance managing state changing.
332 bool mAlterAddedChild; ///< Flag used to control whether children are reparented or not.
333 PopupStylePtr mPopupStyle; ///< The style to be used for this popup.
335 LayoutInfo mLayoutInfo; ///< Stores sizes of all popup components.
337 Toolkit::Popup::TouchedOutsideSignalType mTouchedOutsideSignal;
338 Toolkit::Popup::HiddenSignalType mHiddenSignal;
340 Property::Index mPropertyTitle; ///< Property index for Title.
341 Property::Index mPropertyState; ///< Property index for popup state.
344 } // namespace Internal
346 // Helpers for public-api forwarding methods
348 inline Toolkit::Internal::Popup& GetImpl(Toolkit::Popup& pub)
350 DALI_ASSERT_ALWAYS(pub);
352 Dali::RefObject& handle = pub.GetImplementation();
354 return static_cast<Toolkit::Internal::Popup&>(handle);
357 inline const Toolkit::Internal::Popup& GetImpl(const Toolkit::Popup& pub)
359 DALI_ASSERT_ALWAYS(pub);
361 const Dali::RefObject& handle = pub.GetImplementation();
363 return static_cast<const Toolkit::Internal::Popup&>(handle);
366 } // namespace Toolkit
370 #endif // __DALI_TOOLKIT_INTERNAL_POPUP_H__