/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 <dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h>
// EXTERNAL INCLUDES
-#include <cstring> // for strcmp
+#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/devel-api/object/property-helper-devel.h>
+#include <dali/integration-api/debug.h>
#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/public-api/object/type-registry-helper.h>
-#include <dali/integration-api/debug.h>
-#include <dali/devel-api/object/property-helper-devel.h>
+#include <dali/public-api/object/type-registry.h>
+#include <cstring> // for strcmp
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
+#include <dali-toolkit/internal/controls/control/control-data-impl.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_FILE_NAME = "popup_scroll.9.png";
const float DEFAULT_SLIDER_DEPTH(1.0f);
const float DEFAULT_INDICATOR_SHOW_DURATION(0.5f);
* @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 )
+ 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();
+ const Vector3& parentSize = inputs[0]->GetVector3();
+ const float contentSize = inputs[1]->GetFloat();
// Take into account padding that may exist at the beginning and end of the indicator.
const float parentHeightMinusPadding = parentSize.height - mPadding;
- float height = contentSize > parentHeightMinusPadding ?
- parentHeightMinusPadding * ( parentHeightMinusPadding / contentSize ) :
- parentHeightMinusPadding * ( ( parentHeightMinusPadding - contentSize * 0.5f ) / parentHeightMinusPadding );
+ float height = contentSize > parentHeightMinusPadding ? parentHeightMinusPadding * (parentHeightMinusPadding / contentSize) : parentHeightMinusPadding * ((parentHeightMinusPadding - contentSize * 0.5f) / parentHeightMinusPadding);
- current.y = std::max( mMinimumHeight, height );
+ current.y = std::max(mMinimumHeight, height);
}
float mMinimumHeight;
* @param[in] startPadding The padding at the start of the indicator
* @param[in] endPadding The padding at the end of the indicator
*/
- IndicatorPositionConstraint( float startPadding, float endPadding )
- : mStartPadding( startPadding ),
- mEndPadding( endPadding )
+ IndicatorPositionConstraint(float startPadding, float endPadding)
+ : mStartPadding(startPadding),
+ mEndPadding(endPadding)
{
}
* @param[in] inputs Contains the size of indicator, the size of indicator's parent, and the scroll position of the scrollable container (from 0.0 -> 1.0 in each axis)
* @return The new indicator position is returned.
*/
- void operator()( Vector3& current, const PropertyInputContainer& inputs )
+ void operator()(Vector3& current, const PropertyInputContainer& inputs)
{
- const Vector3& indicatorSize = inputs[0]->GetVector3();
- const Vector3& parentSize = inputs[1]->GetVector3();
- const float scrollPosition = -inputs[2]->GetFloat();
- const float minimumScrollPosition = inputs[3]->GetFloat();
- const float maximumScrollPosition = inputs[4]->GetFloat();
+ const Vector3& indicatorSize = inputs[0]->GetVector3();
+ const Vector3& parentSize = inputs[1]->GetVector3();
+ const float scrollPosition = -inputs[2]->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 );
+ const float parentHeightMinusPadding = parentSize.height - (mStartPadding + mEndPadding);
- 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 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;
namespace Dali
{
-
namespace Toolkit
{
-
namespace Internal
{
-
namespace
{
-
using namespace Dali;
BaseHandle Create()
return Toolkit::ScrollBar::New();
}
+// clang-format off
// 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_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_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_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_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()
+// clang-format on
-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"};
-}
+} // namespace
ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
+: 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),
mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
mTransientIndicatorDuration(DEFAULT_INDICATOR_TRANSIENT_DURATION),
mScrollStart(0.0f),
- mGestureDisplacement( Vector3::ZERO ),
+ 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),
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 )
+void ScrollBar::SetScrollPropertySource(Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize)
{
- if( handle
- && propertyScrollPosition != Property::INVALID_INDEX
- && propertyMinScrollPosition != Property::INVALID_INDEX
- && propertyMaxScrollPosition != Property::INVALID_INDEX
- && propertyScrollContentSize != Property::INVALID_INDEX )
+ if(handle && propertyScrollPosition != Property::INVALID_INDEX && propertyMinScrollPosition != Property::INVALID_INDEX && propertyMaxScrollPosition != Property::INVALID_INDEX && propertyScrollContentSize != Property::INVALID_INDEX)
{
- mScrollableObject = WeakHandleBase(handle);
- mPropertyScrollPosition = propertyScrollPosition;
+ mScrollableObject = WeakHandle<Handle>(handle);
+ mPropertyScrollPosition = propertyScrollPosition;
mPropertyMinScrollPosition = propertyMinScrollPosition;
mPropertyMaxScrollPosition = propertyMaxScrollPosition;
mPropertyScrollContentSize = propertyScrollContentSize;
void ScrollBar::CreateDefaultIndicatorActor()
{
- const std::string imageDirPath = AssetManager::GetDaliImagePath();
- Toolkit::ImageView indicator = Toolkit::ImageView::New( imageDirPath + DEFAULT_INDICATOR_IMAGE_FILE_NAME );
- indicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
- indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- indicator.SetStyleName( "ScrollBarIndicator" );
- indicator.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
+ 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);
}
-void ScrollBar::SetScrollIndicator( Actor indicator )
+void ScrollBar::SetScrollIndicator(Actor indicator)
{
// Don't allow empty handle
- if( indicator )
+ if(indicator)
{
// Remove current Indicator
- if( mIndicator )
+ if(mIndicator)
{
- Self().Remove( 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() );
+ PanGestureDetector detector(GetPanGestureDetector());
detector.DetachAll();
- detector.Attach( mIndicator );
+ detector.Attach(mIndicator);
unsigned int childCount = mIndicator.GetChildCount();
- for ( unsigned int index = 0; index < childCount; index++ )
+ for(unsigned int index = 0; index < childCount; index++)
{
- Actor child = mIndicator.GetChildAt( index );
- if ( child )
+ Actor child = mIndicator.GetChildAt(index);
+ if(child)
{
- detector.Attach( child );
+ detector.Attach(child);
}
}
}
void ScrollBar::ApplyConstraints()
{
- Handle scrollableHandle = mScrollableObject.GetBaseHandle();
+ Handle scrollableHandle = mScrollableObject.GetHandle();
- if( scrollableHandle )
+ if(scrollableHandle)
{
if(mIndicatorSizeConstraint)
{
}
// 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( mIndicatorMinimumHeight, mIndicatorStartPadding + mIndicatorEndPadding ) );
- mIndicatorSizeConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
- mIndicatorSizeConstraint.AddSource( Source( scrollableHandle, mPropertyScrollContentSize ) );
+ 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( mIndicatorStartPadding, mIndicatorEndPadding ) );
- mIndicatorPositionConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
- mIndicatorPositionConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
- mIndicatorPositionConstraint.AddSource( Source( scrollableHandle, mPropertyScrollPosition ) );
- mIndicatorPositionConstraint.AddSource( Source( scrollableHandle, mPropertyMinScrollPosition ) );
- mIndicatorPositionConstraint.AddSource( Source( scrollableHandle, mPropertyMaxScrollPosition ) );
+ 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));
+ mIndicatorPositionConstraint.AddSource(Source(scrollableHandle, mPropertyMinScrollPosition));
+ mIndicatorPositionConstraint.AddSource(Source(scrollableHandle, mPropertyMaxScrollPosition));
mIndicatorPositionConstraint.Apply();
}
}
-void ScrollBar::SetScrollPositionIntervals( const Dali::Vector<float>& positions )
+void ScrollBar::SetScrollPositionIntervals(const Dali::Vector<float>& positions)
{
mScrollPositionIntervals = positions;
- Handle scrollableHandle = mScrollableObject.GetBaseHandle();
+ Handle scrollableHandle = mScrollableObject.GetHandle();
- if( scrollableHandle )
+ if(scrollableHandle)
{
- if( mPositionNotification )
+ if(mPositionNotification)
{
scrollableHandle.RemovePropertyNotification(mPositionNotification);
}
- mPositionNotification = scrollableHandle.AddPropertyNotification( mPropertyScrollPosition, VariableStepCondition(mScrollPositionIntervals) );
- mPositionNotification.NotifySignal().Connect( this, &ScrollBar::OnScrollPositionIntervalReached );
+ mPositionNotification = scrollableHandle.AddPropertyNotification(mPropertyScrollPosition, VariableStepCondition(mScrollPositionIntervals));
+ mPositionNotification.NotifySignal().Connect(this, &ScrollBar::OnScrollPositionIntervalReached);
}
}
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.GetCurrentProperty< float >( mPropertyScrollPosition ) );
+ mScrollPositionIntervalReachedSignal.Emit(scrollableHandle.GetCurrentProperty<float>(mPropertyScrollPosition));
+ if(Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
+ {
+ Control::Impl::GetAccessibilityObject(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
+ }
}
}
mAnimation.Reset();
}
- if( mIndicatorFirstShow )
+ if(mIndicatorFirstShow)
{
// Preserve the alpha value from the stylesheet
- mIndicatorShowAlpha = Self().GetCurrentColor().a;
+ mIndicatorShowAlpha = Self().GetCurrentProperty<Vector4>(Actor::Property::COLOR).a;
mIndicatorFirstShow = false;
}
if(mIndicatorShowDuration > 0.0f)
{
- mAnimation = Animation::New( mIndicatorShowDuration );
- mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), mIndicatorShowAlpha, AlphaFunction::EASE_IN );
+ mAnimation = Animation::New(mIndicatorShowDuration);
+ mAnimation.AnimateTo(Property(mIndicator, Actor::Property::COLOR_ALPHA), mIndicatorShowAlpha, AlphaFunction::EASE_IN);
mAnimation.Play();
}
else
{
- mIndicator.SetOpacity(mIndicatorShowAlpha);
+ mIndicator.SetProperty(Actor::Property::OPACITY, mIndicatorShowAlpha);
}
}
if(mIndicatorHideDuration > 0.0f)
{
- mAnimation = Animation::New( mIndicatorHideDuration );
- mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN );
+ mAnimation = Animation::New(mIndicatorHideDuration);
+ mAnimation.AnimateTo(Property(mIndicator, Actor::Property::COLOR_ALPHA), 0.0f, AlphaFunction::EASE_IN);
mAnimation.Play();
}
else
{
- mIndicator.SetOpacity(0.0f);
+ mIndicator.SetProperty(Actor::Property::OPACITY, 0.0f);
}
}
mAnimation.Reset();
}
- mAnimation = Animation::New( mIndicatorShowDuration + mTransientIndicatorDuration + mIndicatorHideDuration );
+ 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) );
+ mAnimation.AnimateTo(Property(mIndicator, Actor::Property::COLOR_ALPHA),
+ mIndicatorShowAlpha,
+ AlphaFunction::EASE_IN,
+ TimePeriod(0, mIndicatorShowDuration));
}
else
{
- mIndicator.SetOpacity(mIndicatorShowAlpha);
+ mIndicator.SetProperty(Actor::Property::OPACITY, mIndicatorShowAlpha);
}
- mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ),
- 0.0f, AlphaFunction::EASE_IN, TimePeriod((mIndicatorShowDuration + mTransientIndicatorDuration), mIndicatorHideDuration) );
+ 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();
- if( scrollableHandle )
+ Handle scrollableHandle = mScrollableObject.GetHandle();
+ if(scrollableHandle)
{
scrollableHandle.SetProperty(mPropertyScrollPosition, mCurrentScrollPosition);
}
return true;
}
-void ScrollBar::OnPan( const PanGesture& gesture )
+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 )
+ if(!mPanProcessTimer)
{
// Make sure the pan gesture is only being processed once per frame.
- mPanProcessTimer = Timer::New( DEFAULT_PAN_GESTURE_PROCESS_TIME );
- mPanProcessTimer.TickSignal().Connect( this, &ScrollBar::OnPanGestureProcessTick );
+ mPanProcessTimer = Timer::New(DEFAULT_PAN_GESTURE_PROCESS_TIME);
+ mPanProcessTimer.TickSignal().Connect(this, &ScrollBar::OnPanGestureProcessTick);
mPanProcessTimer.Start();
}
ShowIndicator();
- mScrollStart = scrollableHandle.GetCurrentProperty< float >( mPropertyScrollPosition );
- mGestureDisplacement = Vector3::ZERO;
- mIsPanning = true;
+ mScrollStart = scrollableHandle.GetCurrentProperty<float>(mPropertyScrollPosition);
+ mGestureDisplacement = Vector2::ZERO;
+ mIsPanning = true;
break;
}
- case Gesture::Continuing:
+ case Dali::GestureState::CONTINUING:
{
- mGestureDisplacement.x += gesture.displacement.x;
- mGestureDisplacement.y += gesture.displacement.y;
+ mGestureDisplacement += gesture.GetDisplacement();
- float minScrollPosition = scrollableHandle.GetCurrentProperty<float>( mPropertyMinScrollPosition );
- float maxScrollPosition = scrollableHandle.GetCurrentProperty<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().GetCurrentSize().y - ( mIndicator.GetCurrentSize().y + mIndicatorStartPadding + mIndicatorEndPadding );
+ 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 ) / logicalSize );
- mCurrentScrollPosition = -std::min( maxScrollPosition, std::max( -mCurrentScrollPosition, minScrollPosition ) );
+ mCurrentScrollPosition = mScrollStart - ((mGestureDisplacement.y * domainSize) / logicalSize);
+ mCurrentScrollPosition = -std::min(maxScrollPosition, std::max(-mCurrentScrollPosition, minScrollPosition));
break;
}
{
mIsPanning = false;
- if( mPanProcessTimer )
+ if(mPanProcessTimer)
{
// Destroy the timer when pan gesture is finished.
mPanProcessTimer.Stop();
- mPanProcessTimer.TickSignal().Disconnect( this, &ScrollBar::OnPanGestureProcessTick );
+ mPanProcessTimer.TickSignal().Disconnect(this, &ScrollBar::OnPanGestureProcessTick);
mPanProcessTimer.Reset();
}
}
}
-void ScrollBar::OnSizeSet( const Vector3& size )
+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 );
+ Control::OnSizeSet(size);
}
-void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction )
+void ScrollBar::SetScrollDirection(Toolkit::ScrollBar::Direction direction)
{
mDirection = direction;
}
return mDirection;
}
-void ScrollBar::SetIndicatorHeightPolicy( Toolkit::ScrollBar::IndicatorHeightPolicy policy )
+void ScrollBar::SetIndicatorHeightPolicy(Toolkit::ScrollBar::IndicatorHeightPolicy policy)
{
- if( policy != mIndicatorHeightPolicy )
+ if(policy != mIndicatorHeightPolicy)
{
mIndicatorHeightPolicy = policy;
ApplyConstraints();
return mIndicatorHeightPolicy;
}
-void ScrollBar::SetIndicatorFixedHeight( float height )
+void ScrollBar::SetIndicatorFixedHeight(float height)
{
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));
}
}
return mIndicatorFixedHeight;
}
-void ScrollBar::SetIndicatorShowDuration( float durationSeconds )
+void ScrollBar::SetIndicatorShowDuration(float durationSeconds)
{
mIndicatorShowDuration = durationSeconds;
}
return mIndicatorShowDuration;
}
-void ScrollBar::SetIndicatorHideDuration( float durationSeconds )
+void ScrollBar::SetIndicatorHideDuration(float durationSeconds)
{
mIndicatorHideDuration = durationSeconds;
}
return mIndicatorHideDuration;
}
-void ScrollBar::OnScrollDirectionPropertySet( Property::Value propertyValue )
+void ScrollBar::OnScrollDirectionPropertySet(Property::Value propertyValue)
{
- std::string directionName( propertyValue.Get<std::string>() );
- if(directionName == "Vertical")
+ std::string directionName(propertyValue.Get<std::string>());
+ 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
{
- DALI_ASSERT_ALWAYS( !"ScrollBar::OnScrollDirectionPropertySet(). Invalid Property value." );
+ DALI_ASSERT_ALWAYS(!"ScrollBar::OnScrollDirectionPropertySet(). Invalid Property value.");
}
}
-void ScrollBar::OnIndicatorHeightPolicyPropertySet( Property::Value propertyValue )
+void ScrollBar::OnIndicatorHeightPolicyPropertySet(Property::Value propertyValue)
{
- std::string policyName( propertyValue.Get<std::string>() );
- if(policyName == "Variable")
+ std::string policyName(propertyValue.Get<std::string>());
+ 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
{
- DALI_ASSERT_ALWAYS( !"ScrollBar::OnIndicatorHeightPolicyPropertySet(). Invalid Property value." );
+ DALI_ASSERT_ALWAYS(!"ScrollBar::OnIndicatorHeightPolicyPropertySet(). Invalid Property value.");
}
}
-bool ScrollBar::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool ScrollBar::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- Dali::BaseHandle handle( object );
+ Dali::BaseHandle handle(object);
- bool connected( true );
- Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( handle );
+ bool connected(true);
+ Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast(handle);
- if( 0 == strcmp( signalName.c_str(), PAN_FINISHED_SIGNAL ) )
+ if(0 == strcmp(signalName.c_str(), PAN_FINISHED_SIGNAL))
{
- scrollBar.PanFinishedSignal().Connect( tracker, functor );
+ scrollBar.PanFinishedSignal().Connect(tracker, functor);
}
- else if( 0 == strcmp( signalName.c_str(), SCROLL_POSITION_INTERVAL_REACHED_SIGNAL ) )
+ else if(0 == strcmp(signalName.c_str(), SCROLL_POSITION_INTERVAL_REACHED_SIGNAL))
{
- scrollBar.ScrollPositionIntervalReachedSignal().Connect( tracker, functor );
+ scrollBar.ScrollPositionIntervalReachedSignal().Connect(tracker, functor);
}
else
{
return connected;
}
-void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+void ScrollBar::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
{
- Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( Dali::BaseHandle( object ) );
+ Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast(Dali::BaseHandle(object));
- if( scrollBar )
+ if(scrollBar)
{
- ScrollBar& scrollBarImpl( GetImpl( scrollBar ) );
- switch( index )
+ ScrollBar& scrollBarImpl(GetImpl(scrollBar));
+ switch(index)
{
case Toolkit::ScrollBar::Property::SCROLL_DIRECTION:
{
- scrollBarImpl.OnScrollDirectionPropertySet( value );
+ scrollBarImpl.OnScrollDirectionPropertySet(value);
break;
}
case Toolkit::ScrollBar::Property::INDICATOR_HEIGHT_POLICY:
{
- scrollBarImpl.OnIndicatorHeightPolicyPropertySet( value );
+ scrollBarImpl.OnIndicatorHeightPolicyPropertySet(value);
break;
}
case Toolkit::ScrollBar::Property::INDICATOR_FIXED_HEIGHT:
}
case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
{
- Property::Array* array = value.GetArray();
- if( array )
+ const Property::Array* array = value.GetArray();
+ if(array)
{
Dali::Vector<float> positions;
- size_t positionCount = array->Count();
- positions.Resize( positionCount );
- for( size_t i = 0; i != positionCount; ++i )
+ size_t positionCount = array->Count();
+ positions.Resize(positionCount);
+ for(size_t i = 0; i != positionCount; ++i)
{
- array->GetElementAt( i ).Get( positions[i] );
+ array->GetElementAt(i).Get(positions[i]);
}
scrollBarImpl.SetScrollPositionIntervals(positions);
}
}
-Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index index )
+Property::Value ScrollBar::GetProperty(BaseObject* object, Property::Index index)
{
Property::Value value;
- Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( Dali::BaseHandle( object ) );
+ Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast(Dali::BaseHandle(object));
- if( scrollBar )
+ if(scrollBar)
{
- ScrollBar& scrollBarImpl( GetImpl( scrollBar ) );
- switch( index )
+ ScrollBar& scrollBarImpl(GetImpl(scrollBar));
+ switch(index)
{
case Toolkit::ScrollBar::Property::SCROLL_DIRECTION:
{
- value = SCROLL_DIRECTION_NAME[ scrollBarImpl.GetScrollDirection() ];
+ value = SCROLL_DIRECTION_NAME[scrollBarImpl.GetScrollDirection()];
break;
}
case Toolkit::ScrollBar::Property::INDICATOR_HEIGHT_POLICY:
{
- value = INDICATOR_HEIGHT_POLICY_NAME[ scrollBarImpl.GetIndicatorHeightPolicy() ];
+ value = INDICATOR_HEIGHT_POLICY_NAME[scrollBarImpl.GetIndicatorHeightPolicy()];
break;
}
case Toolkit::ScrollBar::Property::INDICATOR_FIXED_HEIGHT:
}
case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
{
- Property::Value tempValue( Property::ARRAY );
+ Property::Value tempValue(Property::ARRAY);
Property::Array* array = tempValue.GetArray();
- if( array )
+ if(array)
{
Dali::Vector<float> positions = scrollBarImpl.GetScrollPositionIntervals();
- size_t positionCount( positions.Count() );
+ size_t positionCount(positions.Count());
- for( size_t i( 0 ); i != positionCount; ++i )
+ for(size_t i(0); i != positionCount; ++i)
{
- array->PushBack( positions[i] );
+ array->PushBack(positions[i]);
}
value = tempValue;
return value;
}
-bool ScrollBar::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
+bool ScrollBar::DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes)
{
bool ret = false;
- Dali::BaseHandle handle( object );
+ Dali::BaseHandle handle(object);
- Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( handle );
+ Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast(handle);
- DALI_ASSERT_DEBUG( scrollBar );
+ DALI_ASSERT_DEBUG(scrollBar);
- if( scrollBar )
+ if(scrollBar)
{
- if( 0 == strcmp( actionName.c_str(), ACTION_SHOW_INDICATOR ) )
+ if(0 == strcmp(actionName.c_str(), ACTION_SHOW_INDICATOR))
{
- GetImpl( scrollBar ).ShowIndicator();
+ GetImpl(scrollBar).ShowIndicator();
ret = true;
}
- else if( 0 == strcmp( actionName.c_str(), ACTION_HIDE_INDICATOR ) )
+ else if(0 == strcmp(actionName.c_str(), ACTION_HIDE_INDICATOR))
{
- GetImpl( scrollBar ).HideIndicator();
+ GetImpl(scrollBar).HideIndicator();
ret = true;
}
- else if( 0 == strcmp( actionName.c_str(), ACTION_SHOW_TRANSIENT_INDICATOR ) )
+ else if(0 == strcmp(actionName.c_str(), ACTION_SHOW_TRANSIENT_INDICATOR))
{
- GetImpl( scrollBar ).ShowTransientIndicator();
+ GetImpl(scrollBar).ShowTransientIndicator();
ret = true;
}
}
Toolkit::ScrollBar ScrollBar::New(Toolkit::ScrollBar::Direction direction)
{
// Create the implementation, temporarily owned by this handle on stack
- IntrusivePtr< ScrollBar > impl = new ScrollBar(direction);
+ IntrusivePtr<ScrollBar> impl = new ScrollBar(direction);
// Pass ownership to CustomActor handle
- Toolkit::ScrollBar handle( *impl );
+ Toolkit::ScrollBar handle(*impl);
// Second-phase init of the implementation
// This can only be done after the CustomActor connection has been made...
return handle;
}
+double ScrollBar::AccessibleImpl::GetMinimum()
+{
+ auto self = Toolkit::ScrollBar::DownCast(Self());
+ Handle scrollableHandle = GetImpl(self).mScrollableObject.GetHandle();
+ return scrollableHandle ? scrollableHandle.GetCurrentProperty<float>(GetImpl(self).mPropertyMinScrollPosition) : 0.0f;
+}
+
+double ScrollBar::AccessibleImpl::GetCurrent()
+{
+ auto self = Toolkit::ScrollBar::DownCast(Self());
+ Handle scrollableHandle = GetImpl(self).mScrollableObject.GetHandle();
+ return scrollableHandle ? scrollableHandle.GetCurrentProperty<float>(GetImpl(self).mPropertyScrollPosition) : 0.0f;
+}
+
+double ScrollBar::AccessibleImpl::GetMaximum()
+{
+ auto self = Toolkit::ScrollBar::DownCast(Self());
+ Handle scrollableHandle = GetImpl(self).mScrollableObject.GetHandle();
+ return scrollableHandle ? scrollableHandle.GetCurrentProperty<float>(GetImpl(self).mPropertyMaxScrollPosition) : 1.0f;
+}
+
+bool ScrollBar::AccessibleImpl::SetCurrent(double current)
+{
+ if(current < GetMinimum() || current > GetMaximum())
+ {
+ return false;
+ }
+
+ auto valueBefore = GetCurrent();
+
+ auto self = Toolkit::ScrollBar::DownCast(Self());
+ Handle scrollableHandle = GetImpl(self).mScrollableObject.GetHandle();
+ if(!scrollableHandle)
+ {
+ return false;
+ }
+
+ scrollableHandle.SetProperty(GetImpl(self).mPropertyScrollPosition, static_cast<float>(current));
+
+ auto valueAfter = GetCurrent();
+
+ if((current != valueBefore) && (valueBefore == valueAfter))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+double ScrollBar::AccessibleImpl::GetMinimumIncrement()
+{
+ return 1.0;
+}
+
} // namespace Internal
} // namespace Toolkit