X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscroll-bar%2Fscroll-bar-impl.cpp;h=b59e6e0918b513629a2840d45e6127dee4dc5a93;hp=f10dfb515594d83dca83808da8dd1e1423ee85ed;hb=a8d60282f49c906206c1ffb2f2425800b914d109;hpb=9bb8fbae3cd42147c42c2448ca736fc5db535f5a diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index f10dfb5..b59e6e0 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -27,10 +27,13 @@ #include #include #include +#include +#include // INTERNAL INCLUDES #include #include +#include using namespace Dali; @@ -46,6 +49,7 @@ 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 @@ -154,19 +158,25 @@ BaseHandle Create() // 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_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_DEVEL_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"}; @@ -175,7 +185,7 @@ 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()), @@ -185,6 +195,7 @@ ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction) mPropertyScrollContentSize(Property::INVALID_INDEX), mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION), mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION), + mTransientIndicatorDuration(DEFAULT_INDICATOR_TRANSIENT_DURATION), mScrollStart(0.0f), mCurrentScrollPosition(0.0f), mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable), @@ -234,7 +245,8 @@ void ScrollBar::CreateDefaultIndicatorActor() Toolkit::ImageView indicator = Toolkit::ImageView::New( DEFAULT_INDICATOR_IMAGE_PATH ); indicator.SetParentOrigin( ParentOrigin::TOP_LEFT ); indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - + indicator.SetStyleName( "ScrollBarIndicator" ); + indicator.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); SetScrollIndicator(indicator); } @@ -243,11 +255,17 @@ void ScrollBar::SetScrollIndicator( Actor 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( Gesture::Type( Gesture::Pan ) ); PanGestureDetector detector( GetPanGestureDetector() ); detector.DetachAll(); @@ -344,7 +362,7 @@ void ScrollBar::OnScrollPositionIntervalReached(PropertyNotification& source) Handle scrollableHandle = mScrollableObject.GetBaseHandle(); if(scrollableHandle) { - mScrollPositionIntervalReachedSignal.Emit(scrollableHandle.GetProperty(mPropertyScrollPosition)); + mScrollPositionIntervalReachedSignal.Emit( DevelHandle::GetCurrentProperty< float >( scrollableHandle, mPropertyScrollPosition ) ); } } @@ -397,6 +415,30 @@ void ScrollBar::HideIndicator() } } +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.SetOpacity(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. @@ -430,7 +472,7 @@ void ScrollBar::OnPan( const PanGesture& gesture ) } ShowIndicator(); - mScrollStart = scrollableHandle.GetProperty(mPropertyScrollPosition); + mScrollStart = DevelHandle::GetCurrentProperty< float >( scrollableHandle, mPropertyScrollPosition ); mGestureDisplacement = Vector3::ZERO; mIsPanning = true; @@ -441,8 +483,8 @@ void ScrollBar::OnPan( const PanGesture& gesture ) mGestureDisplacement.x += gesture.displacement.x; mGestureDisplacement.y += gesture.displacement.y; - float minScrollPosition = scrollableHandle.GetProperty( mPropertyMinScrollPosition ); - float maxScrollPosition = scrollableHandle.GetProperty( mPropertyMaxScrollPosition ); + float minScrollPosition = DevelHandle::GetCurrentProperty( scrollableHandle, mPropertyMinScrollPosition ); + float maxScrollPosition = DevelHandle::GetCurrentProperty( scrollableHandle, mPropertyMaxScrollPosition ); // The domain size is the internal range float domainSize = maxScrollPosition - minScrollPosition; @@ -491,6 +533,8 @@ void ScrollBar::OnSizeSet( const Vector3& size ) { mIndicator.SetSize(size.width, mIndicatorFixedHeight); } + + Control::OnSizeSet( size ); } void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction ) @@ -679,6 +723,11 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr scrollBarImpl.ApplyConstraints(); break; } + case Toolkit::DevelScrollBar::Property::INDICATOR_TRANSIENT_DURATION: + { + scrollBarImpl.mTransientIndicatorDuration = value.Get(); + break; + } } } } @@ -750,11 +799,48 @@ Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index inde value = scrollBarImpl.mIndicatorEndPadding; break; } + case Toolkit::DevelScrollBar::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