Internal::Control cleanup, remove dead an non-needed methods and adding missing test...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scroll-bar / scroll-bar-impl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <cstring> // for strcmp
23 #include <dali/integration-api/debug.h>
24 #include <dali/public-api/animation/constraint.h>
25 #include <dali/public-api/animation/constraints.h>
26 #include <dali/public-api/object/type-registry.h>
27 #include <dali/devel-api/object/type-registry-helper.h>
28 #include <dali/public-api/images/resource-image.h>
29
30 // INTERNAL INCLUDES
31 #include <dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h>
32
33 using namespace Dali;
34
35 namespace
36 {
37
38 const char* DEFAULT_INDICATOR_IMAGE_PATH = DALI_IMAGE_DIR "popup_scroll.png";
39 const Vector4 DEFAULT_INDICATOR_NINE_PATCH_BORDER(4.0f, 9.0f, 7.0f, 11.0f);
40 const float MINIMUM_INDICATOR_HEIGHT(20.0f); // The minimum indicator height for the nine patch border
41 const float DEFAULT_SLIDER_DEPTH(1.0f);
42 const float DEFAULT_INDICATOR_SHOW_DURATION(0.5f);
43 const float DEFAULT_INDICATOR_HIDE_DURATION(0.5f);
44 const float DEFAULT_PAN_GESTURE_PROCESS_TIME(16.7f); // 16.7 milliseconds, i.e. one frame
45 const float DEFAULT_INDICATOR_FIXED_HEIGHT(80.0f);
46
47 /**
48  * Indicator size constraint
49  * Indicator size depends on both indicator's parent size and the scroll content size
50  */
51 struct IndicatorSizeConstraint
52 {
53   IndicatorSizeConstraint()
54   {
55   }
56
57   /**
58    * Constraint operator
59    * @param[in] current The current indicator size
60    * @param[in] parentSizeProperty The parent size of scroll indicator.
61    * @return The new scroll indicator size.
62    */
63   void operator()(Vector3& current, const PropertyInputContainer& inputs )
64   {
65     const Vector3& parentSize = inputs[0]->GetVector3();
66     const float contentSize = inputs[1]->GetFloat();
67
68     float height = contentSize > parentSize.height ?
69                    parentSize.height * ( parentSize.height / contentSize ) :
70                    parentSize.height * ( (parentSize.height - contentSize * 0.5f) / parentSize.height);
71
72     current.y = std::max(MINIMUM_INDICATOR_HEIGHT, height);
73   }
74 };
75
76 /**
77  * Indicator position constraint
78  * Positions the indicator to reflect the current scroll position within the scroll domain.
79  */
80 struct IndicatorPositionConstraint
81 {
82   /**
83    * @param[in] minPosition The minimum limit of scroll position
84    * @param[in] maxPosition the maximum limit of scroll position
85    */
86   IndicatorPositionConstraint()
87   {
88   }
89
90   /**
91    * Constraint operator
92    * @param[in,out] current The current indicator position
93    * @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)
94    * @return The new indicator position is returned.
95    */
96   void operator()( Vector3& current, const PropertyInputContainer& inputs )
97   {
98     const Vector3& indicatorSize = inputs[0]->GetVector3();
99     const Vector3& parentSize = inputs[1]->GetVector3();
100     const float scrollPosition = -inputs[2]->GetFloat();
101     const float minScrollPosition = inputs[3]->GetFloat();
102     const float maxScrollPosition = inputs[4]->GetFloat();
103
104     float relativePosition = std::max( 0.0f, std::min( 1.0f, (scrollPosition - minScrollPosition) / (maxScrollPosition - minScrollPosition) ) );
105     current.y = ( parentSize.height - indicatorSize.height ) * relativePosition;
106     current.z = DEFAULT_SLIDER_DEPTH;
107   }
108 };
109
110 } // unnamed namespace
111
112 namespace Dali
113 {
114
115 namespace Toolkit
116 {
117
118 namespace Internal
119 {
120
121 namespace
122 {
123
124 using namespace Dali;
125
126 BaseHandle Create()
127 {
128   return Toolkit::ScrollBar::New();
129 }
130
131 // Setup properties, signals and actions using the type-registry.
132 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollBar, Toolkit::Control, Create );
133
134 DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scroll-direction",                  STRING, SCROLL_DIRECTION          )
135 DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-height-policy",           STRING, INDICATOR_HEIGHT_POLICY   )
136 DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-fixed-height",            FLOAT,  INDICATOR_FIXED_HEIGHT    )
137 DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-show-duration",           FLOAT,  INDICATOR_SHOW_DURATION   )
138 DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-hide-duration",           FLOAT,  INDICATOR_HIDE_DURATION   )
139 DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scroll-position-intervals",         ARRAY,  SCROLL_POSITION_INTERVALS )
140
141 DALI_SIGNAL_REGISTRATION(   Toolkit, ScrollBar, "pan-finished",                      PAN_FINISHED_SIGNAL )
142 DALI_SIGNAL_REGISTRATION(   Toolkit, ScrollBar, "scroll-position-interval-reached",  SCROLL_POSITION_INTERVAL_REACHED_SIGNAL )
143
144 DALI_TYPE_REGISTRATION_END()
145
146 const char* SCROLL_DIRECTION_NAME[] = {"Vertical", "Horizontal"};
147 const char* INDICATOR_HEIGHT_POLICY_NAME[] = {"Variable", "Fixed"};
148
149 }
150
151 ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
152 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
153   mDirection(direction),
154   mScrollableObject(Handle()),
155   mPropertyScrollPosition(Property::INVALID_INDEX),
156   mPropertyMinScrollPosition(Property::INVALID_INDEX),
157   mPropertyMaxScrollPosition(Property::INVALID_INDEX),
158   mPropertyScrollContentSize(Property::INVALID_INDEX),
159   mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION),
160   mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
161   mScrollStart(0.0f),
162   mIsPanning(false),
163   mCurrentScrollPosition(0.0f),
164   mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable),
165   mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT)
166 {
167 }
168
169 ScrollBar::~ScrollBar()
170 {
171 }
172
173 void ScrollBar::OnInitialize()
174 {
175   CreateDefaultIndicatorActor();
176 }
177
178 void ScrollBar::SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize )
179 {
180   if( handle
181       && propertyScrollPosition != Property::INVALID_INDEX
182       && propertyMinScrollPosition != Property::INVALID_INDEX
183       && propertyMaxScrollPosition != Property::INVALID_INDEX
184       && propertyScrollContentSize != Property::INVALID_INDEX )
185   {
186     mScrollableObject = handle;
187     mPropertyScrollPosition = propertyScrollPosition;
188     mPropertyMinScrollPosition = propertyMinScrollPosition;
189     mPropertyMaxScrollPosition = propertyMaxScrollPosition;
190     mPropertyScrollContentSize = propertyScrollContentSize;
191
192     ApplyConstraints();
193   }
194   else
195   {
196     DALI_LOG_ERROR("Can not set empty handle of source object or invalid source property index\n");
197   }
198 }
199
200 void ScrollBar::CreateDefaultIndicatorActor()
201 {
202   Image indicatorImage = ResourceImage::New( DEFAULT_INDICATOR_IMAGE_PATH );
203   ImageActor indicator = ImageActor::New( indicatorImage );
204   indicator.SetNinePatchBorder( DEFAULT_INDICATOR_NINE_PATCH_BORDER );
205   indicator.SetStyle( ImageActor::STYLE_NINE_PATCH );
206   indicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
207   indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
208
209   SetScrollIndicator(indicator);
210 }
211
212 void ScrollBar::SetScrollIndicator( Actor indicator )
213 {
214   // Don't allow empty handle
215   if( indicator )
216   {
217     mIndicator = indicator;
218
219     Actor self = Self();
220     self.Add(mIndicator);
221     self.SetDrawMode(DrawMode::OVERLAY);
222
223     if( !mPanGestureDetector )
224     {
225       mPanGestureDetector = PanGestureDetector::New();
226       mPanGestureDetector.DetectedSignal().Connect(this, &ScrollBar::OnPan);
227     }
228
229     mPanGestureDetector.DetachAll();
230     mPanGestureDetector.Attach( mIndicator );
231
232     unsigned int childCount = mIndicator.GetChildCount();
233     for ( unsigned int index = 0; index < childCount; index++ )
234     {
235       Actor child = mIndicator.GetChildAt( index );
236       if ( child )
237       {
238         mPanGestureDetector.Attach( child );
239       }
240     }
241   }
242   else
243   {
244     DALI_LOG_ERROR("Empty handle of scroll indicator\n");
245   }
246 }
247
248 Actor ScrollBar::GetScrollIndicator()
249 {
250   return mIndicator;
251 }
252
253 void ScrollBar::ApplyConstraints()
254 {
255   if( mScrollableObject )
256   {
257     if(mIndicatorSizeConstraint)
258     {
259       mIndicatorSizeConstraint.Remove();
260     }
261
262     // Set indicator height according to the indicator's height policy
263     if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
264     {
265       mIndicator.SetSize(Self().GetCurrentSize().width, mIndicatorFixedHeight);
266     }
267     else
268     {
269       mIndicatorSizeConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::SIZE, IndicatorSizeConstraint() );
270       mIndicatorSizeConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
271       mIndicatorSizeConstraint.AddSource( Source( mScrollableObject, mPropertyScrollContentSize ) );
272       mIndicatorSizeConstraint.Apply();
273     }
274
275     if(mIndicatorPositionConstraint)
276     {
277       mIndicatorPositionConstraint.Remove();
278     }
279
280     mIndicatorPositionConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::POSITION, IndicatorPositionConstraint() );
281     mIndicatorPositionConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
282     mIndicatorPositionConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
283     mIndicatorPositionConstraint.AddSource( Source( mScrollableObject, mPropertyScrollPosition ) );
284     mIndicatorPositionConstraint.AddSource( Source( mScrollableObject, mPropertyMinScrollPosition ) );
285     mIndicatorPositionConstraint.AddSource( Source( mScrollableObject, mPropertyMaxScrollPosition ) );
286     mIndicatorPositionConstraint.Apply();
287   }
288 }
289
290 void ScrollBar::SetScrollPositionIntervals( const Dali::Vector<float>& positions )
291 {
292   mScrollPositionIntervals = positions;
293
294   if( mScrollableObject )
295   {
296     if( mPositionNotification )
297     {
298       mScrollableObject.RemovePropertyNotification(mPositionNotification);
299     }
300
301     mPositionNotification = mScrollableObject.AddPropertyNotification( mPropertyScrollPosition, VariableStepCondition(mScrollPositionIntervals) );
302     mPositionNotification.NotifySignal().Connect( this, &ScrollBar::OnScrollPositionIntervalReached );
303   }
304 }
305
306 Dali::Vector<float> ScrollBar::GetScrollPositionIntervals() const
307 {
308   return mScrollPositionIntervals;
309 }
310
311 void ScrollBar::OnScrollPositionIntervalReached(PropertyNotification& source)
312 {
313   // Emit the signal to notify the scroll position crossing
314   if(mScrollableObject)
315   {
316     mScrollPositionIntervalReachedSignal.Emit(mScrollableObject.GetProperty<float>(mPropertyScrollPosition));
317   }
318 }
319
320 void ScrollBar::ShowIndicator()
321 {
322   // Cancel any animation
323   if(mAnimation)
324   {
325     mAnimation.Clear();
326     mAnimation.Reset();
327   }
328
329   if(mIndicatorShowDuration > 0.0f)
330   {
331     mAnimation = Animation::New( mIndicatorShowDuration );
332     mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN );
333     mAnimation.Play();
334   }
335   else
336   {
337     mIndicator.SetOpacity(1.0f);
338   }
339 }
340
341 void ScrollBar::HideIndicator()
342 {
343   // Cancel any animation
344   if(mAnimation)
345   {
346     mAnimation.Clear();
347     mAnimation.Reset();
348   }
349
350   if(mIndicatorHideDuration > 0.0f)
351   {
352     mAnimation = Animation::New( mIndicatorHideDuration );
353     mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN );
354     mAnimation.Play();
355   }
356   else
357   {
358     mIndicator.SetOpacity(0.0f);
359   }
360 }
361
362 bool ScrollBar::OnPanGestureProcessTick()
363 {
364   // Update the scroll position property.
365   if( mScrollableObject )
366   {
367     mScrollableObject.SetProperty(mPropertyScrollPosition, mCurrentScrollPosition);
368   }
369
370   return true;
371 }
372
373 void ScrollBar::OnPan( Actor source, const PanGesture& gesture )
374 {
375   if(mScrollableObject)
376   {
377     Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast(mScrollableObject);
378
379     switch(gesture.state)
380     {
381       case Gesture::Started:
382       {
383         if( !mPanProcessTimer )
384         {
385           // Make sure the pan gesture is only being processed once per frame.
386           mPanProcessTimer = Timer::New( DEFAULT_PAN_GESTURE_PROCESS_TIME );
387           mPanProcessTimer.TickSignal().Connect( this, &ScrollBar::OnPanGestureProcessTick );
388           mPanProcessTimer.Start();
389         }
390
391         ShowIndicator();
392         mScrollStart = mScrollableObject.GetProperty<float>(mPropertyScrollPosition);
393         mGestureDisplacement = Vector3::ZERO;
394         mIsPanning = true;
395
396         break;
397       }
398       case Gesture::Continuing:
399       {
400         Vector3 delta(gesture.displacement.x, gesture.displacement.y, 0.0f);
401         mGestureDisplacement+=delta;
402
403         Vector3 span = Self().GetCurrentSize() - mIndicator.GetCurrentSize();
404         float minScrollPosition = mScrollableObject.GetProperty<float>(mPropertyMinScrollPosition);
405         float maxScrollPosition = mScrollableObject.GetProperty<float>(mPropertyMaxScrollPosition);
406         float domainSize = maxScrollPosition - minScrollPosition;
407
408         mCurrentScrollPosition = mScrollStart - mGestureDisplacement.y * domainSize / span.y;
409         mCurrentScrollPosition = 0.0f - std::min(maxScrollPosition, std::max(-mCurrentScrollPosition, minScrollPosition));
410
411         break;
412       }
413       default:
414       {
415         mIsPanning = false;
416
417         if( mPanProcessTimer )
418         {
419           // Destroy the timer when pan gesture is finished.
420           mPanProcessTimer.Stop();
421           mPanProcessTimer.TickSignal().Disconnect( this, &ScrollBar::OnPanGestureProcessTick );
422           mPanProcessTimer.Reset();
423         }
424
425         if(itemView)
426         {
427           // Refresh the ItemView cache with extra items
428           GetImpl(itemView).DoRefresh(mCurrentScrollPosition, true);
429         }
430
431         mPanFinishedSignal.Emit();
432
433         break;
434       }
435     }
436
437     if(itemView)
438     {
439       // Disable automatic refresh in ItemView during fast scrolling
440       GetImpl(itemView).SetRefreshEnabled(true);//!mIsPanning);
441     }
442   }
443 }
444
445 void ScrollBar::OnSizeSet( const Vector3& size )
446 {
447   if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
448   {
449     mIndicator.SetSize(size.width, mIndicatorFixedHeight);
450   }
451 }
452
453 void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction )
454 {
455   mDirection = direction;
456 }
457
458 Toolkit::ScrollBar::Direction ScrollBar::GetScrollDirection() const
459 {
460   return mDirection;
461 }
462
463 void ScrollBar::SetIndicatorHeightPolicy( Toolkit::ScrollBar::IndicatorHeightPolicy policy )
464 {
465   mIndicatorHeightPolicy = policy;
466   ApplyConstraints();
467 }
468
469 Toolkit::ScrollBar::IndicatorHeightPolicy ScrollBar::GetIndicatorHeightPolicy() const
470 {
471   return mIndicatorHeightPolicy;
472 }
473
474 void ScrollBar::SetIndicatorFixedHeight( float height )
475 {
476   mIndicatorFixedHeight = height;
477
478   if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
479   {
480     mIndicator.SetSize(Self().GetCurrentSize().width, mIndicatorFixedHeight);
481   }
482 }
483
484 float ScrollBar::GetIndicatorFixedHeight() const
485 {
486   return mIndicatorFixedHeight;
487 }
488
489 void ScrollBar::SetIndicatorShowDuration( float durationSeconds )
490 {
491   mIndicatorShowDuration = durationSeconds;
492 }
493
494 float ScrollBar::GetIndicatorShowDuration() const
495 {
496   return mIndicatorShowDuration;
497 }
498
499 void ScrollBar::SetIndicatorHideDuration( float durationSeconds )
500 {
501   mIndicatorHideDuration = durationSeconds;
502 }
503
504 float ScrollBar::GetIndicatorHideDuration() const
505 {
506   return mIndicatorHideDuration;
507 }
508
509 void ScrollBar::OnScrollDirectionPropertySet( Property::Value propertyValue )
510 {
511   std::string directionName( propertyValue.Get<std::string>() );
512   if(directionName == "Vertical")
513   {
514     SetScrollDirection(Toolkit::ScrollBar::Vertical);
515   }
516   else if(directionName == "Horizontal")
517   {
518     SetScrollDirection(Toolkit::ScrollBar::Horizontal);
519   }
520   else
521   {
522     DALI_ASSERT_ALWAYS( !"ScrollBar::OnScrollDirectionPropertySet(). Invalid Property value." );
523   }
524 }
525
526 void ScrollBar::OnIndicatorHeightPolicyPropertySet( Property::Value propertyValue )
527 {
528   std::string policyName( propertyValue.Get<std::string>() );
529   if(policyName == "Variable")
530   {
531     SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
532   }
533   else if(policyName == "Fixed")
534   {
535     SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
536   }
537   else
538   {
539     DALI_ASSERT_ALWAYS( !"ScrollBar::OnIndicatorHeightPolicyPropertySet(). Invalid Property value." );
540   }
541 }
542
543 bool ScrollBar::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
544 {
545   Dali::BaseHandle handle( object );
546
547   bool connected( true );
548   Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( handle );
549
550   if( 0 == strcmp( signalName.c_str(), PAN_FINISHED_SIGNAL ) )
551   {
552     scrollBar.PanFinishedSignal().Connect( tracker, functor );
553   }
554   else if( 0 == strcmp( signalName.c_str(), SCROLL_POSITION_INTERVAL_REACHED_SIGNAL ) )
555   {
556     scrollBar.ScrollPositionIntervalReachedSignal().Connect( tracker, functor );
557   }
558   else
559   {
560     // signalName does not match any signal
561     connected = false;
562   }
563
564   return connected;
565 }
566
567 void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
568 {
569   Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( Dali::BaseHandle( object ) );
570
571   if( scrollBar )
572   {
573     ScrollBar& scrollBarImpl( GetImpl( scrollBar ) );
574     switch( index )
575     {
576       case Toolkit::ScrollBar::Property::SCROLL_DIRECTION:
577       {
578         scrollBarImpl.OnScrollDirectionPropertySet( value );
579         break;
580       }
581       case Toolkit::ScrollBar::Property::INDICATOR_HEIGHT_POLICY:
582       {
583         scrollBarImpl.OnIndicatorHeightPolicyPropertySet( value );
584         break;
585       }
586       case Toolkit::ScrollBar::Property::INDICATOR_FIXED_HEIGHT:
587       {
588         scrollBarImpl.SetIndicatorFixedHeight(value.Get<float>());
589         break;
590       }
591       case Toolkit::ScrollBar::Property::INDICATOR_SHOW_DURATION:
592       {
593         scrollBarImpl.SetIndicatorShowDuration(value.Get<float>());
594         break;
595       }
596       case Toolkit::ScrollBar::Property::INDICATOR_HIDE_DURATION:
597       {
598         scrollBarImpl.SetIndicatorHideDuration(value.Get<float>());
599         break;
600       }
601       case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
602       {
603         Dali::Vector<float> positions;
604         size_t positionCount = value.GetSize();
605         positions.Resize( positionCount );
606
607         for( size_t i = 0; i != positionCount; ++i )
608         {
609           value.GetItem(i).Get( positions[i] );
610         }
611
612         scrollBarImpl.SetScrollPositionIntervals(positions);
613         break;
614       }
615     }
616   }
617 }
618
619 Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index index )
620 {
621   Property::Value value;
622
623   Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( Dali::BaseHandle( object ) );
624
625   if( scrollBar )
626   {
627     ScrollBar& scrollBarImpl( GetImpl( scrollBar ) );
628     switch( index )
629     {
630       case Toolkit::ScrollBar::Property::SCROLL_DIRECTION:
631       {
632         value = SCROLL_DIRECTION_NAME[ scrollBarImpl.GetScrollDirection() ];
633         break;
634       }
635       case Toolkit::ScrollBar::Property::INDICATOR_HEIGHT_POLICY:
636       {
637         value = INDICATOR_HEIGHT_POLICY_NAME[ scrollBarImpl.GetIndicatorHeightPolicy() ];
638         break;
639       }
640       case Toolkit::ScrollBar::Property::INDICATOR_FIXED_HEIGHT:
641       {
642         value = scrollBarImpl.GetIndicatorFixedHeight();
643         break;
644       }
645       case Toolkit::ScrollBar::Property::INDICATOR_SHOW_DURATION:
646       {
647         value = scrollBarImpl.GetIndicatorShowDuration();
648         break;
649       }
650       case Toolkit::ScrollBar::Property::INDICATOR_HIDE_DURATION:
651       {
652         value = scrollBarImpl.GetIndicatorHideDuration();
653         break;
654       }
655       case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
656       {
657         Property::Value value;
658         Dali::Vector<float> positions = scrollBarImpl.GetScrollPositionIntervals();
659         size_t positionCount( positions.Size() );
660         for( size_t i( 0 ); i != positionCount; ++i )
661         {
662           value.AppendItem( positions[i] );
663         }
664         break;
665       }
666     }
667   }
668   return value;
669 }
670
671 Toolkit::ScrollBar ScrollBar::New(Toolkit::ScrollBar::Direction direction)
672 {
673   // Create the implementation, temporarily owned by this handle on stack
674   IntrusivePtr< ScrollBar > impl = new ScrollBar(direction);
675
676   // Pass ownership to CustomActor handle
677   Toolkit::ScrollBar handle( *impl );
678
679   // Second-phase init of the implementation
680   // This can only be done after the CustomActor connection has been made...
681   impl->Initialize();
682
683   return handle;
684 }
685
686 } // namespace Internal
687
688 } // namespace Toolkit
689
690 } // namespace Dali