*/
// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/devel-api/object/type-registry-helper.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
-#include <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h>
using namespace Dali;
// 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_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_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshootEffectColor", VECTOR4, OVERSHOOT_EFFECT_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshootAnimationSpeed", FLOAT, OVERSHOOT_ANIMATION_SPEED )
+const int OVERSHOOT_SIZE = Dali::Toolkit::Scrollable::Property::OVERSHOOT_ANIMATION_SPEED + 1; // OVERSHOOT_SIZE is not public yet
+Dali::PropertyRegistration p1( typeRegistration, "overshootSize", OVERSHOOT_SIZE, Property::VECTOR2, Dali::Toolkit::Internal::Scrollable::SetProperty, Dali::Toolkit::Internal::Scrollable::GetProperty );
+
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scrollRelativePosition", VECTOR2, SCROLL_RELATIVE_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scrollPositionMin", VECTOR2, SCROLL_POSITION_MIN)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scrollPositionMinX", SCROLL_POSITION_MIN_X, SCROLL_POSITION_MIN, 0)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scrollPositionMinY", SCROLL_POSITION_MIN_Y, SCROLL_POSITION_MIN, 1)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scrollPositionMax", VECTOR2, SCROLL_POSITION_MAX)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scrollPositionMaxX", SCROLL_POSITION_MAX_X, SCROLL_POSITION_MAX, 0)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scrollPositionMaxY", SCROLL_POSITION_MAX_Y, SCROLL_POSITION_MAX, 1)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "canScrollVertical", BOOLEAN, CAN_SCROLL_VERTICAL)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "canScrollHorizontal", BOOLEAN, CAN_SCROLL_HORIZONTAL)
+
+DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scrollStarted", SIGNAL_SCROLL_STARTED )
+DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scrollCompleted", SIGNAL_SCROLL_COMPLETED )
+DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scrollUpdated", SIGNAL_SCROLL_UPDATED )
DALI_TYPE_REGISTRATION_END()
const Vector4 DEFAULT_OVERSHOOT_COLOUR(0.0f, 0.64f, 0.85f, 0.25f);
const float DEFAULT_OVERSHOOT_ANIMATION_SPEED(120.0f); // 120 pixels per second
+const Vector2 OVERSHOOT_DEFAULT_SIZE( 720.0f, 42.0f );
}
-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
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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)
+ mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
+ mOvershootEnabled(true)
{
}
-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 ),
+ mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
+ mOvershootEnabled(true)
{
- // 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<Toolkit::ScrollComponentImpl&>(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
return mOvershootAnimationSpeed;
};
+const Vector2& Scrollable::GetOvershootSize() const
+{
+ return mOvershootSize;
+}
+
Toolkit::Scrollable::ScrollStartedSignalType& Scrollable::ScrollStartedSignal()
{
return mScrollStartedSignal;
scrollableImpl.SetOvershootAnimationSpeed( value.Get<float>() );
break;
}
+ case OVERSHOOT_SIZE: // OVERSHOOT_SIZE is not public yet
+ {
+ Vector2 input;
+ if( value.Get( input ) )
+ {
+ scrollableImpl.mOvershootSize = input;
+ }
+ scrollableImpl.EnableScrollOvershoot( scrollableImpl.IsOvershootEnabled() );
+ break;
+ }
}
}
}
value = scrollableImpl.GetOvershootAnimationSpeed();
break;
}
+ case OVERSHOOT_SIZE: // OVERSHOOT_SIZE is not public yet
+ {
+ value = scrollableImpl.mOvershootSize;
+ break;
+ }
}
}
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::ScrollComponent>(Toolkit::ScrollBarInternal::New(scrollable, true));
- break;
- }
- case Toolkit::Scrollable::HorizontalScrollBar:
- {
- instance = static_cast<Toolkit::ScrollComponent>(Toolkit::ScrollBarInternal::New(scrollable, false));
- break;
- }
- case Toolkit::Scrollable::OvershootIndicator:
- {
- DALI_ASSERT_ALWAYS(!"Unrecognized component type");
- break;
- }
- }
-
- return instance;
-}
-
} // namespace Internal
} // namespace Toolkit