X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscrollable-impl.cpp;h=384d45cb2adf756083fc35caf0a3e9e333078e91;hp=0c73cd4d7ae05084fdf0f8ae83b78bbd0986ca5f;hb=df89f9f230cadaac7be4007d1b1a7cf7dc893011;hpb=b458e407eba11c73f38da68bce8e967a30ea03e2 diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp index 0c73cd4..384d45c 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp @@ -16,12 +16,12 @@ */ // EXTERNAL INCLUDES +#include // for strcmp #include #include // INTERNAL INCLUDES #include -#include using namespace Dali; @@ -46,12 +46,22 @@ BaseHandle Create() // Setup properties, signals and actions using the type-registry. DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Scrollable, Toolkit::Control, Create ); -DALI_PROPERTY_REGISTRATION( Scrollable, "overshoot-effect-color", VECTOR4, OVERSHOOT_EFFECT_COLOR ) -DALI_PROPERTY_REGISTRATION( Scrollable, "overshoot-animation-speed", FLOAT, OVERSHOOT_ANIMATION_SPEED ) +DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshoot-effect-color", VECTOR4, OVERSHOOT_EFFECT_COLOR ) +DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshoot-animation-speed", FLOAT, OVERSHOOT_ANIMATION_SPEED ) -DALI_SIGNAL_REGISTRATION( Scrollable, "scroll-started", SIGNAL_SCROLL_STARTED ) -DALI_SIGNAL_REGISTRATION( Scrollable, "scroll-completed", SIGNAL_SCROLL_COMPLETED ) -DALI_SIGNAL_REGISTRATION( Scrollable, "scroll-updated", SIGNAL_SCROLL_UPDATED ) +DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-relative-position", VECTOR2, SCROLL_RELATIVE_POSITION) +DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-position-min", VECTOR2, SCROLL_POSITION_MIN) +DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-min-x", SCROLL_POSITION_MIN_X, SCROLL_POSITION_MIN, 0) +DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-min-y", SCROLL_POSITION_MIN_Y, SCROLL_POSITION_MIN, 1) +DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-position-max", VECTOR2, SCROLL_POSITION_MAX) +DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-max-x", SCROLL_POSITION_MAX_X, SCROLL_POSITION_MAX, 0) +DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-max-y", SCROLL_POSITION_MAX_Y, SCROLL_POSITION_MAX, 1) +DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "can-scroll-vertical", BOOLEAN, CAN_SCROLL_VERTICAL) +DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "can-scroll-horizontal", BOOLEAN, CAN_SCROLL_HORIZONTAL) + +DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scroll-started", SIGNAL_SCROLL_STARTED ) +DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scroll-completed", SIGNAL_SCROLL_COMPLETED ) +DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scroll-updated", SIGNAL_SCROLL_UPDATED ) DALI_TYPE_REGISTRATION_END() @@ -60,9 +70,6 @@ const float DEFAULT_OVERSHOOT_ANIMATION_SPEED(120.0f); // 120 pixels per second } -const char* const Scrollable::SCROLLABLE_CAN_SCROLL_VERTICAL = "scrollable-can-scroll-vertical"; -const char* const Scrollable::SCROLLABLE_CAN_SCROLL_HORIZONTAL = "scrollable-can-scroll-horizontal"; - /////////////////////////////////////////////////////////////////////////////////////////////////// // Scrollable /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -70,93 +77,34 @@ const char* const Scrollable::SCROLLABLE_CAN_SCROLL_HORIZONTAL = "scrollable-can // Scrollable controls are not layout containers so they dont need size negotiation.. // we dont want size negotiation while scrolling if we can avoid it Scrollable::Scrollable() -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | NO_SIZE_NEGOTIATION ) ), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | DISABLE_SIZE_NEGOTIATION ) ), mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ), mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ), - mPropertyRelativePosition(Property::INVALID_INDEX), - mPropertyPositionMin(Property::INVALID_INDEX), - mPropertyPositionMax(Property::INVALID_INDEX), - mPropertyScrollDirection(Property::INVALID_INDEX), - mPropertyCanScrollVertical(Property::INVALID_INDEX), - mPropertyCanScrollHorizontal(Property::INVALID_INDEX), mOvershootEnabled(false) { } -Scrollable::~Scrollable() +Scrollable::Scrollable( ControlBehaviour behaviourFlags ) +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | behaviourFlags ) ), + mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ), + mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ), + mOvershootEnabled(false) { - // Clear scroll components, forces their destruction before Scrollable is destroyed. - mComponents.clear(); } -void Scrollable::RegisterCommonProperties() +Scrollable::~Scrollable() { - Actor self = Self(); - - // Register properties. - mPropertyRelativePosition = self.RegisterProperty(Toolkit::Scrollable::SCROLL_RELATIVE_POSITION_PROPERTY_NAME, Vector3::ZERO); - mPropertyPositionMin = self.RegisterProperty(Toolkit::Scrollable::SCROLL_POSITION_MIN_PROPERTY_NAME, Vector3::ZERO); - mPropertyPositionMax = self.RegisterProperty(Toolkit::Scrollable::SCROLL_POSITION_MAX_PROPERTY_NAME, Vector3::ZERO); - mPropertyScrollDirection = self.RegisterProperty(Toolkit::Scrollable::SCROLL_DIRECTION_PROPERTY_NAME, Vector3::ZERO); - mPropertyCanScrollVertical = self.RegisterProperty(SCROLLABLE_CAN_SCROLL_VERTICAL, true); - mPropertyCanScrollHorizontal = self.RegisterProperty(SCROLLABLE_CAN_SCROLL_HORIZONTAL, true); } -bool Scrollable::IsScrollComponentEnabled(Toolkit::Scrollable::ScrollComponentType type) const +bool Scrollable::IsOvershootEnabled() const { - if(type == Toolkit::Scrollable::OvershootIndicator) - { - return mOvershootEnabled; - } - return (mComponents.find(type) != mComponents.end()); + return mOvershootEnabled; } -void Scrollable::EnableScrollComponent(Toolkit::Scrollable::ScrollComponentType type) +void Scrollable::SetOvershootEnabled(bool enable) { - if(type == Toolkit::Scrollable::OvershootIndicator) - { - if( !mOvershootEnabled ) - { - SetOvershootEnabled(true); - mOvershootEnabled = true; - } - return; - } - if( mComponents.find(type) == mComponents.end() ) - { - // Create ScrollComponent - Toolkit::Scrollable scrollable = Toolkit::Scrollable::DownCast(Self()); - Toolkit::ScrollComponent scrollComponent = NewScrollComponent(scrollable, type); - Toolkit::ScrollComponentImpl& component = static_cast(scrollComponent.GetImplementation()); - ScrollComponentPtr componentPtr(&component); - - mComponents[type] = componentPtr; - } -} - -void Scrollable::DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType type) -{ - if(type == Toolkit::Scrollable::OvershootIndicator) - { - if( mOvershootEnabled ) - { - SetOvershootEnabled(false); - mOvershootEnabled = false; - } - return; - } - ComponentIter pair = mComponents.find( type ); - - if( mComponents.end() != pair ) - { - ScrollComponentPtr component = pair->second; - - // Disconnect the scroll component first. - component->OnDisconnect(); - - // Destroy ScrollComponent. - mComponents.erase( type ); - } + EnableScrollOvershoot(enable); + mOvershootEnabled = enable; } Vector4 Scrollable::GetOvershootEffectColor() const @@ -267,32 +215,6 @@ Property::Value Scrollable::GetProperty( BaseObject* object, Property::Index ind return value; } -Toolkit::ScrollComponent Scrollable::NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type) -{ - Toolkit::ScrollComponent instance; - - switch(type) - { - case Toolkit::Scrollable::VerticalScrollBar: - { - instance = static_cast(Toolkit::ScrollBarInternal::New(scrollable, true)); - break; - } - case Toolkit::Scrollable::HorizontalScrollBar: - { - instance = static_cast(Toolkit::ScrollBarInternal::New(scrollable, false)); - break; - } - case Toolkit::Scrollable::OvershootIndicator: - { - DALI_ASSERT_ALWAYS(!"Unrecognized component type"); - break; - } - } - - return instance; -} - } // namespace Internal } // namespace Toolkit