X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscroll-bar%2Fscroll-bar-impl.cpp;h=cd8438eadf1de526c80b657d38b9ab09fc4a941c;hb=a507d54721445b44cfea7fb032a68d996bf17f09;hp=a34e7bdfec73fe46701e0b1051c5015318f4b5b8;hpb=0b5d20c961476797f7ffcdfb67026aac3253f94d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 a34e7bd..cd8438e 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,6 +27,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -46,6 +47,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 +156,24 @@ 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_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 +182,7 @@ const char* INDICATOR_HEIGHT_POLICY_NAME[] = {"Variable", "Fixed"}; } ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction) -: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mIndicatorShowAlpha(1.0f), mDirection(direction), mScrollableObject(WeakHandleBase()), @@ -185,7 +192,9 @@ 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), + mGestureDisplacement( Vector3::ZERO ), mCurrentScrollPosition(0.0f), mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable), mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT), @@ -234,7 +243,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); } @@ -249,6 +259,7 @@ void ScrollBar::SetScrollIndicator( Actor indicator ) Self().Remove( mIndicator ); } mIndicator = indicator; + mIndicatorFirstShow = true; Self().Add( mIndicator ); @@ -349,7 +360,7 @@ void ScrollBar::OnScrollPositionIntervalReached(PropertyNotification& source) Handle scrollableHandle = mScrollableObject.GetBaseHandle(); if(scrollableHandle) { - mScrollPositionIntervalReachedSignal.Emit(scrollableHandle.GetProperty(mPropertyScrollPosition)); + mScrollPositionIntervalReachedSignal.Emit( scrollableHandle.GetCurrentProperty< float >( mPropertyScrollPosition ) ); } } @@ -402,6 +413,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. @@ -435,7 +470,7 @@ void ScrollBar::OnPan( const PanGesture& gesture ) } ShowIndicator(); - mScrollStart = scrollableHandle.GetProperty(mPropertyScrollPosition); + mScrollStart = scrollableHandle.GetCurrentProperty< float >( mPropertyScrollPosition ); mGestureDisplacement = Vector3::ZERO; mIsPanning = true; @@ -446,8 +481,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 = scrollableHandle.GetCurrentProperty( mPropertyMinScrollPosition ); + float maxScrollPosition = scrollableHandle.GetCurrentProperty( mPropertyMaxScrollPosition ); // The domain size is the internal range float domainSize = maxScrollPosition - minScrollPosition; @@ -496,6 +531,8 @@ void ScrollBar::OnSizeSet( const Vector3& size ) { mIndicator.SetSize(size.width, mIndicatorFixedHeight); } + + Control::OnSizeSet( size ); } void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction ) @@ -684,6 +721,11 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr scrollBarImpl.ApplyConstraints(); break; } + case Toolkit::ScrollBar::Property::INDICATOR_TRANSIENT_DURATION: + { + scrollBarImpl.mTransientIndicatorDuration = value.Get(); + break; + } } } } @@ -726,17 +768,20 @@ Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index inde } 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 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; } @@ -755,11 +800,48 @@ Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index inde 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