X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.h;h=5363c2512dac9057d92b34cf171901f809f5fc7a;hp=faf0ccf520263d77bdce3f6473b9b2254cd1ce4c;hb=9945b2a54e066f5d95b218ddf74c1599f8bff868;hpb=0109cc725742c57e83ff9dd9868c360edf4aa1fe diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index faf0ccf..5363c25 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_CONTROL_IMPL_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ // EXTERNAL INCLUDES #include -#include #include #include #include @@ -41,13 +40,9 @@ class StyleManager; namespace Internal DALI_INTERNAL { -class RelayoutControllerImpl; class KeyInputFocusManager; } -typedef std::pair< Actor, Vector2 > ActorSizePair; ///< Pair of actor and size -typedef std::vector< ActorSizePair > ActorSizeContainer; ///< Container of actors and their sizes - namespace Internal { @@ -62,6 +57,8 @@ class DALI_IMPORT_API Control : public CustomActorImpl, public ConnectionTracker { public: + class Extension; ///< Forward declare future extension interface + // Creation & Destruction /** @@ -80,73 +77,19 @@ public: // Size negotiation /** - * @copydoc Toolkit::Control::SetSizePolicy() - */ - void SetSizePolicy( Toolkit::Control::SizePolicy widthPolicy, Toolkit::Control::SizePolicy heightPolicy ); - - /** - * @copydoc Toolkit::Control::GetSizePolicy() - */ - void GetSizePolicy( Toolkit::Control::SizePolicy& widthPolicy, Toolkit::Control::SizePolicy& heightPolicy ) const; - - /** - * @copydoc Toolkit::Control::SetMinimumSize() - */ - void SetMinimumSize( const Vector3& size ); - - /** - * @copydoc Toolkit::Control::GetMinimumSize() - */ - const Vector3& GetMinimumSize() const; - - /** - * @copydoc Toolkit::Control::SetMaximumSize() - */ - void SetMaximumSize( const Vector3& size ); - - /** - * @copydoc Toolkit::Control::GetMaximumSize() - */ - const Vector3& GetMaximumSize() const; - - /** - * @copydoc Toolkit::Control::GetNaturalSize() - */ - virtual Vector3 GetNaturalSize(); - - /** - * @brief This method is called during size negotiation when a height is required for a given width. - * - * Derived classes should override this if they wish to customize the height returned. - * - * @param width to use. - * @return the height based on the width. + * @copydoc Dali::CustomActorImpl::GetHeightForWidth() */ virtual float GetHeightForWidth( float width ); /** - * @brief This method is called during size negotiation when a width is required for a given height. - * - * Derived classes should override this if they wish to customize the width returned. - * - * @param height to use. - * @return the width based on the width. + * @copydoc Dali::CustomActorImpl::GetWidthForHeight() */ virtual float GetWidthForHeight( float height ); /** - * @brief Retrieves the current Control's size. - * - * @return The control's size. - */ - const Vector3& GetControlSize() const; - - /** - * @brief Retrieves the Control's size set by the Application / Control. - * - * @return The control's size. + * @copydoc Toolkit::CustomActorImpl::GetNaturalSize() */ - const Vector3& GetSizeSet() const; + virtual Vector3 GetNaturalSize(); // Key Input @@ -214,6 +157,16 @@ public: // Background /** + * @copydoc Dali::Toolkit::Control::SetStyleName + */ + void SetStyleName( const std::string& styleName ); + + /** + * @copydoc Dali::Toolkit::Control::GetStyleName + */ + const std::string& GetStyleName() const; + + /** * @copydoc Dali::Toolkit::Control::SetBackgroundColor */ void SetBackgroundColor( const Vector4& color ); @@ -243,7 +196,7 @@ public: /** * @brief Sets whether this control supports two dimensional * keyboard navigation (i.e. whether it knows how to handle the - * keyboardn focus movement between its child actors). + * keyboard focus movement between its child actors). * * The control doesn't support it by default. * @param[in] isSupported Whether this control supports two dimensional keyboard navigation. @@ -291,22 +244,6 @@ public: */ virtual bool OnAccessibilityValueChange(bool isIncrease); - // Called by the RelayoutController - - /** - * @brief Called by the RelayoutController to negotiate the size of a control. - * - * The size allocated by the the algorithm is passed in which the - * control must adhere to. A container is passed in as well which - * the control should populate with actors it has not / or does not - * need to handle in its size negotiation. - * - * @param[in] size The allocated size. - * @param[in,out] container The container that holds actors that are fed back into the - * RelayoutController algorithm. - */ - DALI_INTERNAL void NegotiateSize( const Vector2& size, ActorSizeContainer& container ); - // Keyboard Focus /** @@ -346,6 +283,15 @@ public: */ virtual void OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor); + /** + * @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal + * + * Should be called last by the control after it acts on the Input Focus change. + * + * @param[in] focusGained True if gained, False if lost + */ + void EmitKeyInputFocusSignal( bool focusGained ); + // Actions & Signals /** @@ -375,6 +321,16 @@ public: Toolkit::Control::KeyEventSignalType& KeyEventSignal(); /** + * @copydoc Dali::Toolkit::Control::KeyInputFocusGainedSignal() + */ + Toolkit::Control::KeyInputFocusSignalType& KeyInputFocusGainedSignal(); + + /** + * @copydoc Dali::Toolkit::Control::KeyInputFocusLostSignal() + */ + Toolkit::Control::KeyInputFocusSignalType& KeyInputFocusLostSignal(); + + /** * @brief Called by the KeyInputFocusManager to emit key event signals. * * @param[in] event The key event. @@ -389,14 +345,14 @@ protected: // Flags for the constructor enum ControlBehaviour { - CONTROL_BEHAVIOUR_NONE = 0, - REQUIRES_TOUCH_EVENTS = 1<<1, ///< True if the OnTouchEvent() callback is required. - REQUIRES_STYLE_CHANGE_SIGNALS = 1<<2, ///< True if needs to monitor style change signals such as theme/font change - NO_SIZE_NEGOTIATION = 1<<3, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm - REQUIRES_HOVER_EVENTS = 1<<4, ///< True if the OnHoverEvent() callback is required. - REQUIRES_MOUSE_WHEEL_EVENTS = 1<<5 ///< True if the OnMouseWheelEvent() callback is required. + REQUIRES_STYLE_CHANGE_SIGNALS = 1 << ( CustomActorImpl::ACTOR_FLAG_COUNT + 0 ), ///< True if needs to monitor style change signals such as theme/font change + REQUIRES_KEYBOARD_NAVIGATION_SUPPORT = 1 << ( CustomActorImpl::ACTOR_FLAG_COUNT + 1 ), ///< True if needs to support keyboard navigation + + LAST_CONTROL_BEHAVIOUR_FLAG }; + static const int CONTROL_BEHAVIOUR_FLAG_COUNT = Log< LAST_CONTROL_BEHAVIOUR_FLAG - 1 >::value + 1; ///< Total count of flags + /** * @brief Create a Control. * @@ -431,32 +387,10 @@ protected: */ void DisableGestureDetection(Gesture::Type type); - // Size Negotiation - /** - * @brief Request a relayout, which means performing a size negotiation on this control, its parent and children (and potentially whole scene) - * - * This method is automatically called from OnStageConnection(), OnChildAdd(), - * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize(). - * - * This method can also be called from a derived class every time it needs a different size. - * At the end of event processing, the relayout process starts and - * all controls which requested Relayout will have their sizes (re)negotiated. - * - * @note RelayoutRequest() can be called multiple times; the size negotiation is still - * only performed once, i.e. there is no need to keep track of this in the calling side. + * @copydoc Dali::CustomActorImpl::RelayoutDependentOnChildren() */ - void RelayoutRequest(); - - /** - * @brief Helper method for controls to Relayout their children if - * they do not know whether that child is a control or not. - * - * @param[in] actor The actor to relayout. - * @param[in] size The size to allocate to the actor. - * @param[in,out] container The container that holds actors that have not been allocated a size yet. - */ - static void Relayout( Actor actor, const Vector2& size, ActorSizeContainer& container ); + virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); private: @@ -477,21 +411,12 @@ private: virtual void OnActivated(); /** - * @brief This method should be overridden by deriving classes when - * they wish to be notified when the style manager changes the theme. + * @brief This method should be overridden by deriving classes requiring notifications when the style changes. * * @param[in] styleManager The StyleManager object. + * @param[in] change Information denoting what has changed. */ - virtual void OnThemeChange( Toolkit::StyleManager styleManager ); - - /** - * @brief This method should be overridden by deriving classes when - * they wish to be notified when the style changes the default font. - * - * @param[in] defaultFontChange Information denoting whether the default font has changed. - * @param[in] defaultFontSizeChange Information denoting whether the default font size has changed. - */ - virtual void OnFontChange( bool defaultFontChange, bool defaultFontSizeChange ); + virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ); /** * @brief Called whenever a pinch gesture is detected on this control. @@ -588,24 +513,6 @@ private: virtual void OnControlSizeSet( const Vector3& size ); /** - * @brief Called after the size negotiation has been finished for this control. - * - * The control is expected to assign this given size to itself/its children. - * - * Should be overridden by derived classes if they need to layout - * actors differently after certain operations like add or remove - * actors, resize or after changing specific properties. - * - * Note! As this function is called from inside the size negotiation algorithm, you cannot - * call RequestRelayout (the call would just be ignored) - * - * @param[in] size The allocated size. - * @param[in,out] container The control should add actors to this container that it is not able - * to allocate a size for. - */ - virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container ); - - /** * @brief Called when the control gains key input focus. * * Should be overridden by derived classes if they need to customize what happens when focus is gained. @@ -646,6 +553,31 @@ private: */ virtual bool OnMouseWheelEvent(const MouseWheelEvent& event); + /** + * @copydoc Dali::CustomActorImpl::OnCalculateRelayoutSize() + */ + virtual void OnCalculateRelayoutSize( Dimension::Type dimension ); + + /** + * @copydoc Dali::CustomActorImpl::OnLayoutNegotiated() + */ + virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ); + + /** + * @copydoc Dali::CustomActorImpl::OnRelayout() + */ + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); + + /** + * @copydoc Dali::CustomActorImpl::OnSetResizePolicy() + */ + virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ); + + /** + * @copydoc Dali::CustomActorImpl::CalculateChildSize() + */ + virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ); + // From CustomActorImpl, derived classes should NOT override these. /** @@ -661,51 +593,22 @@ private: virtual void OnStageConnection(); /** - * @brief Calls OnControlStageDisconnection() to notify derived classed. - * - * @see Dali::CustomActorImpl::OnStageDisconnection() + * @copydoc Dali::CustomActorImpl::OnStageDisconnection() */ virtual void OnStageDisconnection(); /** - * @brief Sends a request to relayout this control. - * - * The control will be relaid out after the - * Dali::Stage::SignalMessageQueueFlushed() signal is emitted. It - * calls OnControlChildAdd() to notify derived classes. - * - * @note This method shouldn't be overridden by derived classes. - * - * @param[in] child The added actor. - * - * @see Dali::CustomActorImpl::OnChildAdd(Actor&) + * @copydoc Dali::CustomActorImpl::OnChildAdd(Actor&) */ virtual void OnChildAdd(Actor& child); /** - * @brief Sends a request to relayout this control. - * - * The control will be relaid out after the - * Dali::Stage::SignalMessageQueueFlushed() signal is emitted. It - * calls OnControlChildRemove() to notify derived classes. - * - * @note This method shouldn't be overridden by derived classes. - * - * @param[in] child The removed actor. - * - * @see Dali::CustomActorImpl::OnChildRemove(Actor&) + * @copydoc Dali::CustomActorImpl::OnChildRemove(Actor&) */ virtual void OnChildRemove(Actor& child); /** - * @brief It stores the size set by size negotiation and relayout. - * - * It also keeps a backup of the size set through the Actor's API used in the size negotiation. - * It calls the OnControlSizeSet() to notify derived classes. - * - * @param[in] targetSize The new size. - * - * @see Dali::CustomActorImpl::OnSizeSet(const Vector3&) + * @copydoc Dali::CustomActorImpl::OnSizeSet(const Vector3&) */ virtual void OnSizeSet(const Vector3& targetSize); @@ -721,15 +624,15 @@ private: */ virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback ); - // Style - /** - * @brief This method is the callback for the StyleChangeSignal from StyleManager + * Retrieve the extension for this control * - * @param[in] styleManager The StyleManager Object - * @param[in] change Information denoting what has changed. + * @return The extension if available, NULL otherwise */ - DALI_INTERNAL void DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change ); + virtual Extension* GetExtension() + { + return NULL; + } private: