/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
#include <cstring> // for strcmp
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
-#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/property-array.h>
-#include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/public-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
-
+#include <dali/devel-api/object/property-helper-devel.h>
+#include <dali/devel-api/actors/actor-devel.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
#include <dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
namespace
{
-const char* DEFAULT_INDICATOR_IMAGE_PATH = DALI_IMAGE_DIR "popup_scroll.9.png";
-const float MINIMUM_INDICATOR_HEIGHT(20.0f); // The minimum indicator height for the nine patch border
+const char* DEFAULT_INDICATOR_IMAGE_FILE_NAME = "popup_scroll.9.png";
const float DEFAULT_SLIDER_DEPTH(1.0f);
const float DEFAULT_INDICATOR_SHOW_DURATION(0.5f);
const float DEFAULT_INDICATOR_HIDE_DURATION(0.5f);
const float DEFAULT_PAN_GESTURE_PROCESS_TIME(16.7f); // 16.7 milliseconds, i.e. one frame
const float DEFAULT_INDICATOR_FIXED_HEIGHT(80.0f);
+const float DEFAULT_INDICATOR_MINIMUM_HEIGHT(0.0f);
+const float DEFAULT_INDICATOR_START_PADDING(0.0f);
+const float DEFAULT_INDICATOR_END_PADDING(0.0f);
+const float DEFAULT_INDICATOR_TRANSIENT_DURATION(1.0f);
/**
* Indicator size constraint
*/
struct IndicatorSizeConstraint
{
- IndicatorSizeConstraint()
+ /**
+ * @param[in] minimumHeight The minimum height for the indicator
+ * @param[in] padding The sum of the padding at the start & end of the indicator
+ */
+ IndicatorSizeConstraint( float minimumHeight, float padding )
+ : mMinimumHeight( minimumHeight ),
+ mPadding( padding )
{
}
* @param[in] parentSizeProperty The parent size of scroll indicator.
* @return The new scroll indicator size.
*/
- void operator()(Vector3& current, const PropertyInputContainer& inputs )
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
const Vector3& parentSize = inputs[0]->GetVector3();
const float contentSize = inputs[1]->GetFloat();
- float height = contentSize > parentSize.height ?
- parentSize.height * ( parentSize.height / contentSize ) :
- parentSize.height * ( (parentSize.height - contentSize * 0.5f) / parentSize.height);
+ // Take into account padding that may exist at the beginning and end of the indicator.
+ const float parentHeightMinusPadding = parentSize.height - mPadding;
- current.y = std::max(MINIMUM_INDICATOR_HEIGHT, height);
+ float height = contentSize > parentHeightMinusPadding ?
+ parentHeightMinusPadding * ( parentHeightMinusPadding / contentSize ) :
+ parentHeightMinusPadding * ( ( parentHeightMinusPadding - contentSize * 0.5f ) / parentHeightMinusPadding );
+
+ current.y = std::max( mMinimumHeight, height );
}
+
+ float mMinimumHeight;
+ float mPadding;
};
/**
struct IndicatorPositionConstraint
{
/**
- * @param[in] minPosition The minimum limit of scroll position
- * @param[in] maxPosition the maximum limit of scroll position
+ * @param[in] startPadding The padding at the start of the indicator
+ * @param[in] endPadding The padding at the end of the indicator
*/
- IndicatorPositionConstraint()
+ IndicatorPositionConstraint( float startPadding, float endPadding )
+ : mStartPadding( startPadding ),
+ mEndPadding( endPadding )
{
}
const Vector3& indicatorSize = inputs[0]->GetVector3();
const Vector3& parentSize = inputs[1]->GetVector3();
const float scrollPosition = -inputs[2]->GetFloat();
- const float minScrollPosition = inputs[3]->GetFloat();
- const float maxScrollPosition = inputs[4]->GetFloat();
+ const float minimumScrollPosition = inputs[3]->GetFloat();
+ const float maximumScrollPosition = inputs[4]->GetFloat();
+
+ // Take into account padding that may exist at the beginning and end of the indicator.
+ const float parentHeightMinusPadding = parentSize.height - ( mStartPadding + mEndPadding );
- float relativePosition = std::max( 0.0f, std::min( 1.0f, (scrollPosition - minScrollPosition) / (maxScrollPosition - minScrollPosition) ) );
- current.y = ( parentSize.height - indicatorSize.height ) * relativePosition;
+ float relativePosition = std::max( 0.0f, std::min( 1.0f, ( scrollPosition - minimumScrollPosition ) / ( maximumScrollPosition - minimumScrollPosition ) ) );
+ current.y = mStartPadding + ( parentHeightMinusPadding - indicatorSize.height ) * relativePosition;
current.z = DEFAULT_SLIDER_DEPTH;
}
+
+ float mStartPadding;
+ float mEndPadding;
};
} // unnamed namespace
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollBar, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollDirection", STRING, SCROLL_DIRECTION )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHeightPolicy", STRING, INDICATOR_HEIGHT_POLICY )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorFixedHeight", FLOAT, INDICATOR_FIXED_HEIGHT )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorShowDuration", FLOAT, INDICATOR_SHOW_DURATION )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHideDuration", FLOAT, INDICATOR_HIDE_DURATION )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollPositionIntervals", ARRAY, SCROLL_POSITION_INTERVALS )
-
-DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "panFinished", PAN_FINISHED_SIGNAL )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollDirection", STRING, SCROLL_DIRECTION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHeightPolicy", STRING, INDICATOR_HEIGHT_POLICY )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorFixedHeight", FLOAT, INDICATOR_FIXED_HEIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorShowDuration", FLOAT, INDICATOR_SHOW_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHideDuration", FLOAT, INDICATOR_HIDE_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollPositionIntervals", ARRAY, SCROLL_POSITION_INTERVALS )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorMinimumHeight", FLOAT, INDICATOR_MINIMUM_HEIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorStartPadding", FLOAT, INDICATOR_START_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorEndPadding", FLOAT, INDICATOR_END_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorTransientDuration", FLOAT, INDICATOR_TRANSIENT_DURATION )
+
+DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "panFinished", PAN_FINISHED_SIGNAL )
DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "scrollPositionIntervalReached", SCROLL_POSITION_INTERVAL_REACHED_SIGNAL )
+DALI_ACTION_REGISTRATION( Toolkit, ScrollBar, "ShowIndicator", ACTION_SHOW_INDICATOR )
+DALI_ACTION_REGISTRATION( Toolkit, ScrollBar, "HideIndicator", ACTION_HIDE_INDICATOR )
+DALI_ACTION_REGISTRATION( Toolkit, ScrollBar, "ShowTransientIndicator", ACTION_SHOW_TRANSIENT_INDICATOR )
+
DALI_TYPE_REGISTRATION_END()
-const char* SCROLL_DIRECTION_NAME[] = {"Vertical", "Horizontal"};
-const char* INDICATOR_HEIGHT_POLICY_NAME[] = {"Variable", "Fixed"};
+const char* SCROLL_DIRECTION_NAME[] = {"VERTICAL", "HORIZONTAL"};
+const char* INDICATOR_HEIGHT_POLICY_NAME[] = {"VARIABLE", "FIXED"};
}
ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mIndicatorShowAlpha(1.0f),
mDirection(direction),
- mScrollableObject(WeakHandleBase()),
+ mScrollableObject(WeakHandle<Handle>()),
mPropertyScrollPosition(Property::INVALID_INDEX),
mPropertyMinScrollPosition(Property::INVALID_INDEX),
mPropertyMaxScrollPosition(Property::INVALID_INDEX),
mPropertyScrollContentSize(Property::INVALID_INDEX),
mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION),
mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
+ mTransientIndicatorDuration(DEFAULT_INDICATOR_TRANSIENT_DURATION),
mScrollStart(0.0f),
+ mGestureDisplacement( Vector2::ZERO ),
mCurrentScrollPosition(0.0f),
- mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable),
+ mIndicatorHeightPolicy(Toolkit::ScrollBar::VARIABLE),
mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT),
+ mIndicatorMinimumHeight(DEFAULT_INDICATOR_MINIMUM_HEIGHT),
+ mIndicatorStartPadding(DEFAULT_INDICATOR_START_PADDING),
+ mIndicatorEndPadding(DEFAULT_INDICATOR_END_PADDING),
mIsPanning(false),
mIndicatorFirstShow(true)
{
void ScrollBar::OnInitialize()
{
CreateDefaultIndicatorActor();
- Self().SetDrawMode(DrawMode::OVERLAY_2D);
+ Self().SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D);
+
+ DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
+ return std::unique_ptr< Dali::Accessibility::Accessible >(
+ new AccessibleImpl( actor, Dali::Accessibility::Role::SCROLL_BAR ) );
+ } );
}
void ScrollBar::SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize )
&& propertyMaxScrollPosition != Property::INVALID_INDEX
&& propertyScrollContentSize != Property::INVALID_INDEX )
{
- mScrollableObject = WeakHandleBase(handle);
+ mScrollableObject = WeakHandle<Handle>(handle);
mPropertyScrollPosition = propertyScrollPosition;
mPropertyMinScrollPosition = propertyMinScrollPosition;
mPropertyMaxScrollPosition = propertyMaxScrollPosition;
void ScrollBar::CreateDefaultIndicatorActor()
{
- Toolkit::ImageView indicator = Toolkit::ImageView::New( DEFAULT_INDICATOR_IMAGE_PATH );
- indicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
- indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-
+ const std::string imageDirPath = AssetManager::GetDaliImagePath();
+ Toolkit::ImageView indicator = Toolkit::ImageView::New( imageDirPath + DEFAULT_INDICATOR_IMAGE_FILE_NAME );
+ indicator.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ indicator.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ indicator.SetStyleName( "ScrollBarIndicator" );
+ indicator.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
SetScrollIndicator(indicator);
}
// Don't allow empty handle
if( indicator )
{
+ // Remove current Indicator
+ if( mIndicator )
+ {
+ Self().Remove( mIndicator );
+ }
mIndicator = indicator;
+
mIndicatorFirstShow = true;
- Self().Add(mIndicator);
+ Self().Add( mIndicator );
- EnableGestureDetection(Gesture::Type(Gesture::Pan));
+ EnableGestureDetection( GestureType::Value( GestureType::PAN ) );
PanGestureDetector detector( GetPanGestureDetector() );
detector.DetachAll();
void ScrollBar::ApplyConstraints()
{
- Handle scrollableHandle = mScrollableObject.GetBaseHandle();
+ Handle scrollableHandle = mScrollableObject.GetHandle();
if( scrollableHandle )
{
}
// Set indicator height according to the indicator's height policy
- if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
+ if(mIndicatorHeightPolicy == Toolkit::ScrollBar::FIXED)
{
- mIndicator.SetSize(Self().GetCurrentSize().width, mIndicatorFixedHeight);
+ mIndicator.SetProperty( Actor::Property::SIZE, Vector2( Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, mIndicatorFixedHeight) );
}
else
{
- mIndicatorSizeConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::SIZE, IndicatorSizeConstraint() );
+ mIndicatorSizeConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::SIZE,
+ IndicatorSizeConstraint( mIndicatorMinimumHeight, mIndicatorStartPadding + mIndicatorEndPadding ) );
mIndicatorSizeConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
mIndicatorSizeConstraint.AddSource( Source( scrollableHandle, mPropertyScrollContentSize ) );
mIndicatorSizeConstraint.Apply();
mIndicatorPositionConstraint.Remove();
}
- mIndicatorPositionConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::POSITION, IndicatorPositionConstraint() );
+ mIndicatorPositionConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::POSITION,
+ IndicatorPositionConstraint( mIndicatorStartPadding, mIndicatorEndPadding ) );
mIndicatorPositionConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
mIndicatorPositionConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
mIndicatorPositionConstraint.AddSource( Source( scrollableHandle, mPropertyScrollPosition ) );
{
mScrollPositionIntervals = positions;
- Handle scrollableHandle = mScrollableObject.GetBaseHandle();
+ Handle scrollableHandle = mScrollableObject.GetHandle();
if( scrollableHandle )
{
void ScrollBar::OnScrollPositionIntervalReached(PropertyNotification& source)
{
// Emit the signal to notify the scroll position crossing
- Handle scrollableHandle = mScrollableObject.GetBaseHandle();
+ Handle scrollableHandle = mScrollableObject.GetHandle();
if(scrollableHandle)
{
- mScrollPositionIntervalReachedSignal.Emit(scrollableHandle.GetProperty<float>(mPropertyScrollPosition));
+ mScrollPositionIntervalReachedSignal.Emit( scrollableHandle.GetCurrentProperty< float >( mPropertyScrollPosition ) );
+ if (Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
+ {
+ Control::Impl::GetAccessibilityObject(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
+ }
}
}
if( mIndicatorFirstShow )
{
// Preserve the alpha value from the stylesheet
- mIndicatorShowAlpha = Self().GetCurrentColor().a;
+ mIndicatorShowAlpha = Self().GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a;
mIndicatorFirstShow = false;
}
}
else
{
- mIndicator.SetOpacity(mIndicatorShowAlpha);
+ mIndicator.SetProperty( Actor::Property::OPACITY,mIndicatorShowAlpha);
}
}
}
else
{
- mIndicator.SetOpacity(0.0f);
+ mIndicator.SetProperty( Actor::Property::OPACITY,0.0f);
}
}
+void ScrollBar::ShowTransientIndicator()
+{
+ // Cancel any animation
+ if(mAnimation)
+ {
+ mAnimation.Clear();
+ mAnimation.Reset();
+ }
+
+ mAnimation = Animation::New( mIndicatorShowDuration + mTransientIndicatorDuration + mIndicatorHideDuration );
+ if(mIndicatorShowDuration > 0.0f)
+ {
+ mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ),
+ mIndicatorShowAlpha, AlphaFunction::EASE_IN, TimePeriod(0, mIndicatorShowDuration) );
+ }
+ else
+ {
+ mIndicator.SetProperty( Actor::Property::OPACITY,mIndicatorShowAlpha);
+ }
+ mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ),
+ 0.0f, AlphaFunction::EASE_IN, TimePeriod((mIndicatorShowDuration + mTransientIndicatorDuration), mIndicatorHideDuration) );
+ mAnimation.Play();
+}
+
bool ScrollBar::OnPanGestureProcessTick()
{
// Update the scroll position property.
- Handle scrollableHandle = mScrollableObject.GetBaseHandle();
+ Handle scrollableHandle = mScrollableObject.GetHandle();
if( scrollableHandle )
{
scrollableHandle.SetProperty(mPropertyScrollPosition, mCurrentScrollPosition);
void ScrollBar::OnPan( const PanGesture& gesture )
{
- Handle scrollableHandle = mScrollableObject.GetBaseHandle();
+ Handle scrollableHandle = mScrollableObject.GetHandle();
if(scrollableHandle)
{
Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast(scrollableHandle);
- switch(gesture.state)
+ switch(gesture.GetState())
{
- case Gesture::Started:
+ case Dali::GestureState::STARTED:
{
if( !mPanProcessTimer )
{
}
ShowIndicator();
- mScrollStart = scrollableHandle.GetProperty<float>(mPropertyScrollPosition);
- mGestureDisplacement = Vector3::ZERO;
+ mScrollStart = scrollableHandle.GetCurrentProperty< float >( mPropertyScrollPosition );
+ mGestureDisplacement = Vector2::ZERO;
mIsPanning = true;
break;
}
- case Gesture::Continuing:
+ case Dali::GestureState::CONTINUING:
{
- Vector3 delta(gesture.displacement.x, gesture.displacement.y, 0.0f);
- mGestureDisplacement+=delta;
+ mGestureDisplacement += gesture.GetDisplacement();
- Vector3 span = Self().GetCurrentSize() - mIndicator.GetCurrentSize();
- float minScrollPosition = scrollableHandle.GetProperty<float>(mPropertyMinScrollPosition);
- float maxScrollPosition = scrollableHandle.GetProperty<float>(mPropertyMaxScrollPosition);
+ float minScrollPosition = scrollableHandle.GetCurrentProperty<float>( mPropertyMinScrollPosition );
+ float maxScrollPosition = scrollableHandle.GetCurrentProperty<float>( mPropertyMaxScrollPosition );
+
+ // The domain size is the internal range
float domainSize = maxScrollPosition - minScrollPosition;
+ float logicalSize = Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y - ( mIndicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y + mIndicatorStartPadding + mIndicatorEndPadding );
- mCurrentScrollPosition = mScrollStart - mGestureDisplacement.y * domainSize / span.y;
- mCurrentScrollPosition = 0.0f - std::min(maxScrollPosition, std::max(-mCurrentScrollPosition, minScrollPosition));
+ mCurrentScrollPosition = mScrollStart - ( ( mGestureDisplacement.y * domainSize ) / logicalSize );
+ mCurrentScrollPosition = -std::min( maxScrollPosition, std::max( -mCurrentScrollPosition, minScrollPosition ) );
break;
}
void ScrollBar::OnSizeSet( const Vector3& size )
{
- if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
+ if(mIndicatorHeightPolicy == Toolkit::ScrollBar::FIXED)
{
- mIndicator.SetSize(size.width, mIndicatorFixedHeight);
+ mIndicator.SetProperty( Actor::Property::SIZE, Vector2( size.width, mIndicatorFixedHeight ) );
}
+
+ Control::OnSizeSet( size );
}
void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction )
void ScrollBar::SetIndicatorHeightPolicy( Toolkit::ScrollBar::IndicatorHeightPolicy policy )
{
- mIndicatorHeightPolicy = policy;
- ApplyConstraints();
+ if( policy != mIndicatorHeightPolicy )
+ {
+ mIndicatorHeightPolicy = policy;
+ ApplyConstraints();
+ }
}
Toolkit::ScrollBar::IndicatorHeightPolicy ScrollBar::GetIndicatorHeightPolicy() const
{
mIndicatorFixedHeight = height;
- if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
+ if(mIndicatorHeightPolicy == Toolkit::ScrollBar::FIXED)
{
- mIndicator.SetSize(Self().GetCurrentSize().width, mIndicatorFixedHeight);
+ mIndicator.SetProperty( Actor::Property::SIZE, Vector2( Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, mIndicatorFixedHeight) );
}
}
void ScrollBar::OnScrollDirectionPropertySet( Property::Value propertyValue )
{
std::string directionName( propertyValue.Get<std::string>() );
- if(directionName == "Vertical")
+ if(directionName == "VERTICAL")
{
- SetScrollDirection(Toolkit::ScrollBar::Vertical);
+ SetScrollDirection(Toolkit::ScrollBar::VERTICAL);
}
- else if(directionName == "Horizontal")
+ else if(directionName == "HORIZONTAL")
{
- SetScrollDirection(Toolkit::ScrollBar::Horizontal);
+ SetScrollDirection(Toolkit::ScrollBar::HORIZONTAL);
}
else
{
void ScrollBar::OnIndicatorHeightPolicyPropertySet( Property::Value propertyValue )
{
std::string policyName( propertyValue.Get<std::string>() );
- if(policyName == "Variable")
+ if(policyName == "VARIABLE")
{
- SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
+ SetIndicatorHeightPolicy(Toolkit::ScrollBar::VARIABLE);
}
- else if(policyName == "Fixed")
+ else if(policyName == "FIXED")
{
- SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
+ SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
}
else
{
}
case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
{
- Property::Array* array = value.GetArray();
+ const Property::Array* array = value.GetArray();
if( array )
{
Dali::Vector<float> positions;
}
break;
}
+ case Toolkit::ScrollBar::Property::INDICATOR_MINIMUM_HEIGHT:
+ {
+ scrollBarImpl.mIndicatorMinimumHeight = value.Get<float>();
+ scrollBarImpl.ApplyConstraints();
+ break;
+ }
+ case Toolkit::ScrollBar::Property::INDICATOR_START_PADDING:
+ {
+ scrollBarImpl.mIndicatorStartPadding = value.Get<float>();
+ scrollBarImpl.ApplyConstraints();
+ break;
+ }
+ case Toolkit::ScrollBar::Property::INDICATOR_END_PADDING:
+ {
+ scrollBarImpl.mIndicatorEndPadding = value.Get<float>();
+ scrollBarImpl.ApplyConstraints();
+ break;
+ }
+ case Toolkit::ScrollBar::Property::INDICATOR_TRANSIENT_DURATION:
+ {
+ scrollBarImpl.mTransientIndicatorDuration = value.Get<float>();
+ break;
+ }
}
}
}
}
case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
{
- Property::Value value( Property::ARRAY );
- Property::Array* array = value.GetArray();
+ Property::Value tempValue( Property::ARRAY );
+ Property::Array* array = tempValue.GetArray();
if( array )
{
Dali::Vector<float> positions = scrollBarImpl.GetScrollPositionIntervals();
- size_t positionCount( array->Count() );
+ size_t positionCount( positions.Count() );
+
for( size_t i( 0 ); i != positionCount; ++i )
{
array->PushBack( positions[i] );
}
+
+ value = tempValue;
}
break;
}
+ case Toolkit::ScrollBar::Property::INDICATOR_MINIMUM_HEIGHT:
+ {
+ value = scrollBarImpl.mIndicatorMinimumHeight;
+ break;
+ }
+ case Toolkit::ScrollBar::Property::INDICATOR_START_PADDING:
+ {
+ value = scrollBarImpl.mIndicatorStartPadding;
+ break;
+ }
+ case Toolkit::ScrollBar::Property::INDICATOR_END_PADDING:
+ {
+ value = scrollBarImpl.mIndicatorEndPadding;
+ break;
+ }
+ case Toolkit::ScrollBar::Property::INDICATOR_TRANSIENT_DURATION:
+ {
+ value = scrollBarImpl.mTransientIndicatorDuration;
+ break;
+ }
}
}
return value;
}
+bool ScrollBar::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
+{
+ bool ret = false;
+
+ Dali::BaseHandle handle( object );
+
+ Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( handle );
+
+ DALI_ASSERT_DEBUG( scrollBar );
+
+ if( scrollBar )
+ {
+ if( 0 == strcmp( actionName.c_str(), ACTION_SHOW_INDICATOR ) )
+ {
+ GetImpl( scrollBar ).ShowIndicator();
+ ret = true;
+ }
+ else if( 0 == strcmp( actionName.c_str(), ACTION_HIDE_INDICATOR ) )
+ {
+ GetImpl( scrollBar ).HideIndicator();
+ ret = true;
+ }
+ else if( 0 == strcmp( actionName.c_str(), ACTION_SHOW_TRANSIENT_INDICATOR ) )
+ {
+ GetImpl( scrollBar ).ShowTransientIndicator();
+ ret = true;
+ }
+ }
+
+ return ret;
+}
+
Toolkit::ScrollBar ScrollBar::New(Toolkit::ScrollBar::Direction direction)
{
// Create the implementation, temporarily owned by this handle on stack
return handle;
}
+double ScrollBar::AccessibleImpl::GetMinimum()
+{
+ auto p = Toolkit::ScrollBar::DownCast( self );
+ Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle();
+ return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyMinScrollPosition ) : 0.0f;
+}
+
+double ScrollBar::AccessibleImpl::GetCurrent()
+{
+ auto p = Toolkit::ScrollBar::DownCast( self );
+ Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle();
+ return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyScrollPosition ) : 0.0f;
+}
+
+double ScrollBar::AccessibleImpl::GetMaximum()
+{
+ auto p = Toolkit::ScrollBar::DownCast( self );
+ Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle();
+ return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyMaxScrollPosition ) : 1.0f;
+}
+
+bool ScrollBar::AccessibleImpl::SetCurrent( double current )
+{
+ if( current < GetMinimum() || current > GetMaximum() )
+ return false;
+
+ auto value_before = GetCurrent();
+
+ auto p = Toolkit::ScrollBar::DownCast( self );
+ Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle();
+ if( !scrollableHandle )
+ return false;
+ scrollableHandle.SetProperty( GetImpl( p ).mPropertyScrollPosition, static_cast< float >( current ) );
+
+ auto value_after = GetCurrent();
+
+ if( ( current != value_before ) && ( value_before == value_after ) )
+ return false;
+
+ return true;
+}
+
+double ScrollBar::AccessibleImpl::GetMinimumIncrement() { return 1.0; }
+
} // namespace Internal
} // namespace Toolkit