2961c52059ed2f949b585a467d69269c1812d3f8
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / decorator / text-decorator.cpp
1 /*
2  * Copyright (c) 2015 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/text/decorator/text-decorator.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/adaptor-framework/timer.h>
25 #include <dali/public-api/actors/image-actor.h>
26 #include <dali/public-api/actors/layer.h>
27 #include <dali/devel-api/actors/mesh-actor.h>
28 #include <dali/public-api/animation/constraint.h>
29 #include <dali/public-api/common/constants.h>
30 #include <dali/public-api/common/stage.h>
31 #include <dali/public-api/events/tap-gesture.h>
32 #include <dali/public-api/events/tap-gesture-detector.h>
33 #include <dali/public-api/events/touch-event.h>
34 #include <dali/public-api/events/pan-gesture.h>
35 #include <dali/public-api/events/pan-gesture-detector.h>
36 #include <dali/devel-api/geometry/mesh.h>
37 #include <dali/devel-api/geometry/mesh-data.h>
38 #include <dali/public-api/images/resource-image.h>
39 #include <dali/public-api/math/rect.h>
40 #include <dali/public-api/math/vector2.h>
41 #include <dali/public-api/math/vector4.h>
42 #include <dali/public-api/object/property-notification.h>
43 #include <dali/public-api/signals/connection-tracker.h>
44
45 // INTERNAL INCLUDES
46 #include <dali-toolkit/public-api/controls/control.h>
47 #include <dali-toolkit/public-api/controls/control-impl.h>
48 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
49 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
50 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
51 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
52
53 #ifdef DEBUG_ENABLED
54 #define DECORATOR_DEBUG
55
56 #endif
57
58 namespace Dali
59 {
60 namespace Internal
61 {
62 namespace
63 {
64 #ifdef DECORATOR_DEBUG
65 Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_TEXT_DECORATOR") );
66 #endif
67 }
68 }
69 }
70
71
72 // Local Data
73 namespace
74 {
75
76 const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "insertpoint-icon.png" );
77 const char* DEFAULT_GRAB_HANDLE_IMAGE_PRESSED( DALI_IMAGE_DIR "insertpoint-icon-pressed.png" );
78 const char* DEFAULT_SELECTION_HANDLE_ONE( DALI_IMAGE_DIR "text-input-selection-handle-left.png" );
79 const char* DEFAULT_SELECTION_HANDLE_TWO( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
80
81 const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.5f, 2.0f, 1.0f );
82 const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.5f, 1.5f, 1.0f );
83
84 const Dali::Vector4 LIGHT_BLUE( 0.07f, 0.41f, 0.59f, 1.0f ); // The text highlight color.
85
86 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
87 const float TO_MILLISECONDS = 1000.f;
88 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
89
90 const float DISPLAYED_HIGHLIGHT_Z_OFFSET( -0.05f );
91
92 const unsigned int SCROLL_TICK_INTERVAL = 50u;
93
94 const float SCROLL_THRESHOLD = 10.f;
95 const float SCROLL_SPEED = 300.f;
96 const float SCROLL_DISTANCE = SCROLL_SPEED * SCROLL_TICK_INTERVAL * TO_SECONDS;
97
98 /**
99  * structure to hold coordinates of each quad, which will make up the mesh.
100  */
101 struct QuadCoordinates
102 {
103   /**
104    * Default constructor
105    */
106   QuadCoordinates()
107   {
108   }
109
110   /**
111    * Constructor
112    * @param[in] x1 left co-ordinate
113    * @param[in] y1 top co-ordinate
114    * @param[in] x2 right co-ordinate
115    * @param[in] y2 bottom co-ordinate
116    */
117   QuadCoordinates(float x1, float y1, float x2, float y2)
118   : min(x1, y1),
119     max(x2, y2)
120   {
121   }
122
123   Dali::Vector2 min;                          ///< top-left (minimum) position of quad
124   Dali::Vector2 max;                          ///< bottom-right (maximum) position of quad
125 };
126
127 typedef std::vector<QuadCoordinates> QuadContainer;
128
129 /**
130  * @brief Takes a bounding rectangle in the local coordinates of an actor and returns the world coordinates Bounding Box.
131  * @param[in] boundingRectangle local bounding
132  * @param[out] Vector4 World coordinate bounding Box.
133  */
134 void LocalToWorldCoordinatesBoundingBox( const Dali::Rect<int>& boundingRectangle, Dali::Vector4& boundingBox )
135 {
136   // Convert to world coordinates and store as a Vector4 to be compatible with Property Notifications.
137   Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
138
139   const float originX = boundingRectangle.x - 0.5f * stageSize.width;
140   const float originY = boundingRectangle.y - 0.5f * stageSize.height;
141
142   boundingBox = Dali::Vector4( originX,
143                                originY,
144                                originX + boundingRectangle.width,
145                                originY + boundingRectangle.height );
146 }
147
148
149 } // end of namespace
150
151 namespace Dali
152 {
153
154 namespace Toolkit
155 {
156
157 namespace Text
158 {
159
160 struct Decorator::Impl : public ConnectionTracker
161 {
162   enum ScrollDirection
163   {
164     SCROLL_NONE,
165     SCROLL_RIGHT,
166     SCROLL_LEFT,
167     SCROLL_TOP,
168     SCROLL_BOTTOM
169   };
170
171   struct CursorImpl
172   {
173     CursorImpl()
174     : color( Dali::Color::BLACK ),
175       position(),
176       cursorHeight( 0.0f ),
177       lineHeight( 0.0f )
178     {
179     }
180
181     Vector4 color;
182     Vector2 position;
183     float cursorHeight;
184     float lineHeight;
185   };
186
187   struct HandleImpl
188   {
189     HandleImpl()
190     : position(),
191       lineHeight( 0.0f ),
192       grabDisplacementX( 0.f ),
193       grabDisplacementY( 0.f ),
194       active( false ),
195       visible( false ),
196       flipped( false )
197     {
198     }
199
200     ImageActor actor;
201     Actor grabArea;
202
203     Vector2 position;
204     float lineHeight; ///< Not the handle height
205     float grabDisplacementX;
206     float grabDisplacementY;
207     bool active  : 1;
208     bool visible : 1;
209     bool flipped : 1;
210   };
211
212   Impl( ControllerInterface& controller )
213   : mController( controller ),
214     mBoundingBox( Rect<int>() ),
215     mHighlightColor( LIGHT_BLUE ),
216     mActiveCursor( ACTIVE_CURSOR_NONE ),
217     mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ),
218     mCursorBlinkDuration( 0.0f ),
219     mHandleScrolling( HANDLE_TYPE_COUNT ),
220     mScrollDirection( SCROLL_NONE ),
221     mScrollThreshold( SCROLL_THRESHOLD ),
222     mScrollSpeed( SCROLL_SPEED ),
223     mScrollDistance( SCROLL_DISTANCE ),
224     mActiveCopyPastePopup( false ),
225     mCursorBlinkStatus( true ),
226     mPrimaryCursorVisible( false ),
227     mSecondaryCursorVisible( false )
228   {
229   }
230
231   /**
232    * Relayout of the decorations owned by the decorator.
233    * @param[in] size The Size of the UI control the decorator is adding it's decorations to.
234    */
235   void Relayout( const Vector2& size )
236   {
237     // TODO - Remove this if nothing is active
238     CreateActiveLayer();
239
240     // Show or hide the cursors
241     CreateCursors();
242     if( mPrimaryCursor )
243     {
244       const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
245       mPrimaryCursorVisible = ( cursor.position.x <= size.width ) && ( cursor.position.x >= 0.f );
246       if( mPrimaryCursorVisible )
247       {
248         Vector2 position = cursor.position;
249         if( GRAB_HANDLE == mHandleScrolling )
250         {
251           if( mScrollDirection == SCROLL_RIGHT )
252           {
253             position.x = 0.f;
254           }
255           else
256           {
257             position.x = size.width;
258           }
259         }
260
261         mPrimaryCursor.SetPosition( position.x,
262                                     position.y );
263         mPrimaryCursor.SetSize( Size( 1.0f, cursor.cursorHeight ) );
264       }
265       mPrimaryCursor.SetVisible( mPrimaryCursorVisible );
266     }
267     if( mSecondaryCursor )
268     {
269       const CursorImpl& cursor = mCursor[SECONDARY_CURSOR];
270       mSecondaryCursorVisible = ( cursor.position.x <= size.width ) && ( cursor.position.x >= 0.f );
271       if( mSecondaryCursorVisible )
272       {
273         mSecondaryCursor.SetPosition( cursor.position.x,
274                                       cursor.position.y );
275         mSecondaryCursor.SetSize( Size( 1.0f, cursor.cursorHeight ) );
276       }
277       mSecondaryCursor.SetVisible( mSecondaryCursorVisible );
278     }
279
280     // Show or hide the grab handle
281     HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
282     if( grabHandle.active )
283     {
284       Vector2 position = grabHandle.position;
285
286       if( GRAB_HANDLE == mHandleScrolling )
287       {
288         if( mScrollDirection == SCROLL_RIGHT )
289         {
290           position.x = 0.f;
291         }
292         else
293         {
294           position.x = size.width;
295         }
296       }
297
298       const bool isVisible = ( position.x <= size.width ) && ( position.x >= 0.f );
299
300       if( isVisible )
301       {
302         SetupTouchEvents();
303
304         CreateGrabHandle();
305
306         grabHandle.actor.SetPosition( position.x,
307                                       position.y + grabHandle.lineHeight );
308       }
309       grabHandle.actor.SetVisible( isVisible );
310     }
311     else if( grabHandle.actor )
312     {
313       UnparentAndReset( grabHandle.actor );
314     }
315
316     // Show or hide the selection handles/highlight
317     HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
318     HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
319     if( primary.active || secondary.active )
320     {
321       SetupTouchEvents();
322
323       CreateSelectionHandles();
324
325       primary.actor.SetPosition( primary.position.x,
326                                  primary.position.y + primary.lineHeight );
327
328       secondary.actor.SetPosition( secondary.position.x,
329                                    secondary.position.y + secondary.lineHeight );
330
331       CreateHighlight();
332       UpdateHighlight();
333     }
334     else
335     {
336       UnparentAndReset( primary.actor );
337       UnparentAndReset( secondary.actor );
338       UnparentAndReset( mHighlightMeshActor );
339     }
340
341     if ( mActiveCopyPastePopup )
342     {
343       if ( !mCopyPastePopup )
344       {
345         mCopyPastePopup = TextSelectionPopup::New();
346 #ifdef DECORATOR_DEBUG
347         mCopyPastePopup.SetName("mCopyPastePopup");
348 #endif
349         mCopyPastePopup.SetAnchorPoint( AnchorPoint::CENTER );
350         mCopyPastePopup.OnRelayoutSignal().Connect( this,  &Decorator::Impl::PopUpRelayoutComplete  ); // Position popup after size negotiation
351         mActiveLayer.Add ( mCopyPastePopup );
352       }
353     }
354     else
355     {
356      if ( mCopyPastePopup )
357      {
358        UnparentAndReset( mCopyPastePopup );
359      }
360     }
361   }
362
363   void UpdatePositions( const Vector2& scrollOffset )
364   {
365     mCursor[PRIMARY_CURSOR].position += scrollOffset;
366     mCursor[SECONDARY_CURSOR].position += scrollOffset;
367     mHandle[ GRAB_HANDLE ].position += scrollOffset;
368     mHandle[ LEFT_SELECTION_HANDLE ].position += scrollOffset;
369     mHandle[ RIGHT_SELECTION_HANDLE ].position += scrollOffset;
370
371     // TODO Highlight box??
372   }
373
374   void PopUpRelayoutComplete( Actor actor )
375   {
376     // Size negotiation for CopyPastePopup complete so can get the size and constrain position within bounding box.
377
378     mCopyPastePopup.OnRelayoutSignal().Disconnect( this, &Decorator::Impl::PopUpRelayoutComplete  );
379
380     Vector3 popupPosition( mCursor[PRIMARY_CURSOR].position.x, mCursor[PRIMARY_CURSOR].position.y -100.0f , 0.0f); //todo 100 to be an offset Property
381
382     Vector3 popupSize = Vector3( mCopyPastePopup.GetRelayoutSize( Dimension::WIDTH ), mCopyPastePopup.GetRelayoutSize( Dimension::HEIGHT ), 0.0f );
383
384     GetConstrainedPopupPosition( popupPosition, popupSize, AnchorPoint::CENTER, mActiveLayer, mBoundingBox );
385
386     SetUpPopUpPositionNotifications();
387
388     mCopyPastePopup.SetPosition( popupPosition ); //todo grabhandle(cursor) or selection handle positions to be used
389   }
390
391   void CreateCursor( ImageActor& cursor, const Vector4& color )
392   {
393     cursor = CreateSolidColorActor( color );
394     cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one.
395     cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
396   }
397
398   // Add or Remove cursor(s) from parent
399   void CreateCursors()
400   {
401     if( mActiveCursor == ACTIVE_CURSOR_NONE )
402     {
403       UnparentAndReset( mPrimaryCursor );
404       UnparentAndReset( mSecondaryCursor );
405     }
406     else
407     {
408       /* Create Primary and or Secondary Cursor(s) if active and add to parent */
409       if ( mActiveCursor == ACTIVE_CURSOR_PRIMARY ||
410            mActiveCursor == ACTIVE_CURSOR_BOTH )
411       {
412         if ( !mPrimaryCursor )
413         {
414           CreateCursor( mPrimaryCursor, mCursor[PRIMARY_CURSOR].color );
415 #ifdef DECORATOR_DEBUG
416           mPrimaryCursor.SetName( "PrimaryCursorActor" );
417 #endif
418           mActiveLayer.Add( mPrimaryCursor );
419         }
420       }
421
422       if ( mActiveCursor == ACTIVE_CURSOR_BOTH )
423       {
424         if ( !mSecondaryCursor )
425         {
426           CreateCursor( mSecondaryCursor, mCursor[SECONDARY_CURSOR].color );
427 #ifdef DECORATOR_DEBUG
428           mSecondaryCursor.SetName( "SecondaryCursorActor" );
429 #endif
430           mActiveLayer.Add( mSecondaryCursor );
431         }
432       }
433       else
434       {
435         UnparentAndReset( mSecondaryCursor );
436       }
437     }
438   }
439
440   bool OnCursorBlinkTimerTick()
441   {
442     // Cursor blinking
443     if ( mPrimaryCursor )
444     {
445       mPrimaryCursor.SetVisible( mPrimaryCursorVisible && mCursorBlinkStatus );
446     }
447     if ( mSecondaryCursor )
448     {
449       mSecondaryCursor.SetVisible( mSecondaryCursorVisible && mCursorBlinkStatus );
450     }
451
452     mCursorBlinkStatus = !mCursorBlinkStatus;
453
454     return true;
455   }
456
457   void SetupTouchEvents()
458   {
459     if ( !mTapDetector )
460     {
461       mTapDetector = TapGestureDetector::New();
462       mTapDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnTap );
463     }
464
465     if ( !mPanGestureDetector )
466     {
467       mPanGestureDetector = PanGestureDetector::New();
468       mPanGestureDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnPan );
469     }
470   }
471
472   void CreateActiveLayer()
473   {
474     if( !mActiveLayer )
475     {
476       mActiveLayer = Layer::New();
477 #ifdef DECORATOR_DEBUG
478       mActiveLayer.SetName ( "ActiveLayerActor" );
479 #endif
480
481       mActiveLayer.SetParentOrigin( ParentOrigin::CENTER );
482       mActiveLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
483       mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
484
485       mController.AddDecoration( mActiveLayer );
486     }
487
488     mActiveLayer.RaiseToTop();
489   }
490
491   void CreateGrabHandle()
492   {
493     HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
494     if( !grabHandle.actor )
495     {
496       if( !mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] )
497       {
498         mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_RELEASED );
499       }
500       if( !mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] )
501       {
502         mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_PRESSED );
503       }
504
505       grabHandle.actor = ImageActor::New( mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] );
506       grabHandle.actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
507       grabHandle.actor.SetDrawMode( DrawMode::OVERLAY );
508       // Area that Grab handle responds to, larger than actual handle so easier to move
509 #ifdef DECORATOR_DEBUG
510       grabHandle.actor.SetName( "GrabHandleActor" );
511       if ( Dali::Internal::gLogFilter->IsEnabledFor( Debug::Verbose ) )
512       {
513         grabHandle.grabArea = Toolkit::CreateSolidColorActor( Vector4(0.0f, 0.0f, 0.0f, 0.0f), true, Color::RED, 1 );
514         grabHandle.grabArea.SetName( "GrabArea" );
515       }
516       else
517       {
518         grabHandle.grabArea = Actor::New();
519         grabHandle.grabArea.SetName( "GrabArea" );
520       }
521 #else
522       grabHandle.grabArea = Actor::New();
523 #endif
524
525       grabHandle.grabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
526       grabHandle.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
527       grabHandle.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
528       grabHandle.grabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
529       grabHandle.actor.Add( grabHandle.grabArea );
530
531       grabHandle.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
532       mTapDetector.Attach( grabHandle.grabArea );
533       mPanGestureDetector.Attach( grabHandle.grabArea );
534
535       mActiveLayer.Add( grabHandle.actor );
536     }
537   }
538
539   void CreateSelectionHandles()
540   {
541     HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
542     if( !primary.actor )
543     {
544       if( !mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
545       {
546         mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE );
547       }
548
549       primary.actor = ImageActor::New( mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
550 #ifdef DECORATOR_DEBUG
551       primary.actor.SetName("SelectionHandleOne");
552 #endif
553       primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
554       primary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
555       primary.flipped = false;
556
557       primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
558 #ifdef DECORATOR_DEBUG
559       primary.grabArea.SetName("SelectionHandleOneGrabArea");
560 #endif
561       primary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
562       primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
563       primary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
564
565       mTapDetector.Attach( primary.grabArea );
566       mPanGestureDetector.Attach( primary.grabArea );
567       primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
568
569       primary.actor.Add( primary.grabArea );
570       mActiveLayer.Add( primary.actor );
571     }
572
573     HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
574     if( !secondary.actor )
575     {
576       if( !mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
577       {
578         mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO );
579       }
580
581       secondary.actor = ImageActor::New( mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
582 #ifdef DECORATOR_DEBUG
583       secondary.actor.SetName("SelectionHandleTwo");
584 #endif
585       secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text.
586       secondary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
587       secondary.flipped = false;
588
589       secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
590 #ifdef DECORATOR_DEBUG
591       secondary.grabArea.SetName("SelectionHandleTwoGrabArea");
592 #endif
593       secondary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
594       secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
595       secondary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
596
597       mTapDetector.Attach( secondary.grabArea );
598       mPanGestureDetector.Attach( secondary.grabArea );
599       secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
600
601       secondary.actor.Add( secondary.grabArea );
602       mActiveLayer.Add( secondary.actor );
603     }
604   }
605
606   void CreateHighlight()
607   {
608     if ( !mHighlightMeshActor )
609     {
610       mHighlightMaterial = Material::New( "HighlightMaterial" );
611       mHighlightMaterial.SetDiffuseColor( mHighlightColor );
612
613       mHighlightMeshData.SetMaterial( mHighlightMaterial );
614       mHighlightMeshData.SetHasNormals( true );
615
616       mHighlightMesh = Mesh::New( mHighlightMeshData );
617
618       mHighlightMeshActor = MeshActor::New( mHighlightMesh );
619 #ifdef DECORATOR_DEBUG
620       mHighlightMeshActor.SetName( "HighlightMeshActor" );
621 #endif
622       mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
623       mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
624
625       mController.AddDecoration( mHighlightMeshActor );
626     }
627   }
628
629   void UpdateHighlight()
630   {
631     //  Construct a Mesh with a texture to be used as the highlight 'box' for selected text
632     //
633     //  Example scenarios where mesh is made from 3, 1, 2, 2 ,3 or 3 quads.
634     //
635     //   [ TOP   ]  [ TOP ]      [TOP ]  [ TOP    ]      [ TOP  ]      [ TOP  ]
636     //  [ MIDDLE ]             [BOTTOM]  [BOTTOM]      [ MIDDLE ]   [ MIDDLE  ]
637     //  [ BOTTOM]                                      [ MIDDLE ]   [ MIDDLE  ]
638     //                                                 [BOTTOM]     [ MIDDLE  ]
639     //                                                              [BOTTOM]
640     //
641     //  Each quad is created as 2 triangles.
642     //  Middle is just 1 quad regardless of its size.
643     //
644     //  (0,0)         (0,0)
645     //     0*    *2     0*       *2
646     //     TOP          TOP
647     //     3*    *1     3*       *1
648     //  4*       *1     4*     *6
649     //     MIDDLE         BOTTOM
650     //  6*       *5     7*     *5
651     //  6*    *8
652     //   BOTTOM
653     //  9*    *7
654     //
655
656     if ( mHighlightMesh && mHighlightMaterial && !mHighlightQuadList.empty() )
657     {
658       MeshData::VertexContainer vertices;
659       Dali::MeshData::FaceIndices faceIndices;
660
661       std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
662       std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
663
664       // vertex position defaults to (0 0 0)
665       MeshData::Vertex vertex;
666       // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor.
667       vertex.nZ = 1.0f;
668
669       for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
670       {
671         // Add each quad geometry (a sub-selection) to the mesh data.
672
673         // 0-----1
674         // |\    |
675         // | \ A |
676         // |  \  |
677         // | B \ |
678         // |    \|
679         // 2-----3
680
681         QuadCoordinates& quad = *iter;
682         // top-left (v+0)
683         vertex.x = quad.min.x;
684         vertex.y = quad.min.y;
685         vertices.push_back( vertex );
686
687         // top-right (v+1)
688         vertex.x = quad.max.x;
689         vertex.y = quad.min.y;
690         vertices.push_back( vertex );
691
692         // bottom-left (v+2)
693         vertex.x = quad.min.x;
694         vertex.y = quad.max.y;
695         vertices.push_back( vertex );
696
697         // bottom-right (v+3)
698         vertex.x = quad.max.x;
699         vertex.y = quad.max.y;
700         vertices.push_back( vertex );
701
702         // triangle A (3, 1, 0)
703         faceIndices.push_back( v + 3 );
704         faceIndices.push_back( v + 1 );
705         faceIndices.push_back( v );
706
707         // triangle B (0, 2, 3)
708         faceIndices.push_back( v );
709         faceIndices.push_back( v + 2 );
710         faceIndices.push_back( v + 3 );
711
712         mHighlightMeshData.SetFaceIndices( faceIndices );
713       }
714
715       BoneContainer bones(0); // passed empty as bones not required
716       mHighlightMeshData.SetData( vertices, faceIndices, bones, mHighlightMaterial );
717       mHighlightMesh.UpdateMeshData( mHighlightMeshData );
718     }
719   }
720
721   void OnTap( Actor actor, const TapGesture& tap )
722   {
723     if( actor == mHandle[GRAB_HANDLE].actor )
724     {
725       // TODO
726     }
727   }
728
729   void DoPan( HandleImpl& handle, HandleType type, const PanGesture& gesture )
730   {
731     if( Gesture::Started == gesture.state )
732     {
733       handle.grabDisplacementX = handle.grabDisplacementY = 0;
734     }
735
736     handle.grabDisplacementX += gesture.displacement.x;
737     handle.grabDisplacementY += gesture.displacement.y;
738
739     const float x = handle.position.x + handle.grabDisplacementX;
740     const float y = handle.position.y + handle.lineHeight*0.5f + handle.grabDisplacementY;
741
742     if( Gesture::Started    == gesture.state ||
743         Gesture::Continuing == gesture.state )
744     {
745       Vector2 targetSize;
746       mController.GetTargetSize( targetSize );
747
748       if( x < mScrollThreshold )
749       {
750         mScrollDirection = SCROLL_RIGHT;
751         mHandleScrolling = type;
752         StartScrollTimer();
753       }
754       else if( x > targetSize.width - mScrollThreshold )
755       {
756         mScrollDirection = SCROLL_LEFT;
757         mHandleScrolling = type;
758         StartScrollTimer();
759       }
760       else
761       {
762         mHandleScrolling = HANDLE_TYPE_COUNT;
763         StopScrollTimer();
764         mController.DecorationEvent( type, HANDLE_PRESSED, x, y );
765       }
766     }
767     else if( Gesture::Finished  == gesture.state ||
768              Gesture::Cancelled == gesture.state )
769     {
770       if( mScrollTimer && mScrollTimer.IsRunning() )
771       {
772         mHandleScrolling = HANDLE_TYPE_COUNT;
773         StopScrollTimer();
774         mController.DecorationEvent( type, HANDLE_STOP_SCROLLING, x, y );
775       }
776       else
777       {
778         mController.DecorationEvent( type, HANDLE_RELEASED, x, y );
779       }
780       handle.actor.SetImage( mHandleImages[type][HANDLE_IMAGE_RELEASED] );
781     }
782   }
783
784   void OnPan( Actor actor, const PanGesture& gesture )
785   {
786     HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
787     HandleImpl& primarySelectionHandle = mHandle[LEFT_SELECTION_HANDLE];
788     HandleImpl& secondarySelectionHandle = mHandle[RIGHT_SELECTION_HANDLE];
789
790     if( actor == grabHandle.grabArea )
791     {
792       DoPan( grabHandle, GRAB_HANDLE, gesture );
793     }
794     else if( actor == primarySelectionHandle.grabArea )
795     {
796       DoPan( primarySelectionHandle, LEFT_SELECTION_HANDLE, gesture );
797     }
798     else if( actor == secondarySelectionHandle.grabArea )
799     {
800       DoPan( secondarySelectionHandle, RIGHT_SELECTION_HANDLE, gesture );
801     }
802   }
803
804   bool OnGrabHandleTouched( Actor actor, const TouchEvent& event )
805   {
806     // Switch between pressed/release grab-handle images
807     if( event.GetPointCount() > 0 &&
808         mHandle[GRAB_HANDLE].actor )
809     {
810       const TouchPoint& point = event.GetPoint(0);
811
812       if( TouchPoint::Down == point.state &&
813           mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] )
814       {
815         mHandle[GRAB_HANDLE].actor.SetImage( mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] );
816       }
817       else if( TouchPoint::Up == point.state &&
818                mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] )
819       {
820         mHandle[GRAB_HANDLE].actor.SetImage( mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] );
821       }
822     }
823
824     // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
825     return true;
826   }
827
828   bool OnHandleOneTouched( Actor actor, const TouchEvent& touch )
829   {
830     // TODO
831     // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
832     return true;
833   }
834
835   bool OnHandleTwoTouched( Actor actor, const TouchEvent& touch )
836   {
837     // TODO
838     // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
839     return true;
840   }
841
842   // Popup
843
844   float AlternatePopUpPositionRelativeToCursor()
845   {
846     float alternativePosition=0.0f;;
847
848     if ( mPrimaryCursor ) // Secondary cursor not used for paste
849     {
850       Cursor cursor = PRIMARY_CURSOR;
851       alternativePosition = mCursor[cursor].position.y;
852     }
853
854     const float popupHeight = 120.0f; // todo Set as a MaxSize Property in Control or retrieve from CopyPastePopup class.
855
856     if( mHandle[GRAB_HANDLE].active )
857     {
858       // If grab handle enabled then position pop-up below the grab handle.
859       const Vector2 grabHandleSize( 59.0f, 56.0f ); // todo
860       const float BOTTOM_HANDLE_BOTTOM_OFFSET = 1.5; //todo Should be a property
861       alternativePosition +=  grabHandleSize.height  + popupHeight + BOTTOM_HANDLE_BOTTOM_OFFSET ;
862     }
863     else
864     {
865       alternativePosition += popupHeight;
866     }
867
868     return alternativePosition;
869   }
870
871   void PopUpLeavesVerticalBoundary( PropertyNotification& source )
872   {
873     float alternativeYPosition=0.0f;
874     // todo use AlternatePopUpPositionRelativeToSelectionHandles() if text is highlighted
875     // if can't be positioned above, then position below row.
876     alternativeYPosition = AlternatePopUpPositionRelativeToCursor();
877
878     mCopyPastePopup.SetY( alternativeYPosition );
879   }
880
881
882   void SetUpPopUpPositionNotifications( )
883   {
884     // Note Property notifications ignore any set anchor point so conditions must allow for this.  Default is Top Left.
885
886     // Exceeding vertical boundary
887
888     Vector4 worldCoordinatesBoundingBox;
889     LocalToWorldCoordinatesBoundingBox( mBoundingBox, worldCoordinatesBoundingBox );
890
891     float popupHeight = mCopyPastePopup.GetRelayoutSize( Dimension::HEIGHT);
892
893     PropertyNotification verticalExceedNotification = mCopyPastePopup.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
894                                                       OutsideCondition( worldCoordinatesBoundingBox.y + popupHeight/2,
895                                                                         worldCoordinatesBoundingBox.w - popupHeight/2 ) );
896
897     verticalExceedNotification.NotifySignal().Connect( this, &Decorator::Impl::PopUpLeavesVerticalBoundary );
898   }
899
900   void GetConstrainedPopupPosition( Vector3& requiredPopupPosition, Vector3& popupSize, Vector3 anchorPoint, Actor& parent, Rect<int>& boundingBox )
901   {
902     DALI_ASSERT_DEBUG ( "Popup parent not on stage" && parent.OnStage() )
903
904     // Parent must already by added to Stage for these Get calls to work
905     Vector3 parentAnchorPoint = parent.GetCurrentAnchorPoint();
906     Vector3 parentWorldPositionLeftAnchor = parent.GetCurrentWorldPosition() - parent.GetCurrentSize()*parentAnchorPoint;
907     Vector3 popupWorldPosition = parentWorldPositionLeftAnchor + requiredPopupPosition;  // Parent World position plus popup local position gives World Position
908     Vector3 popupDistanceFromAnchorPoint = popupSize*anchorPoint;
909
910     // Bounding rectangle is supplied as screen coordinates, bounding will be done in world coordinates.
911     Vector4 boundingRectangleWorld;
912     LocalToWorldCoordinatesBoundingBox( boundingBox, boundingRectangleWorld );
913
914     // Calculate distance to move popup (in local space) so fits within the boundary
915     float xOffSetToKeepWithinBounds = 0.0f;
916     if( popupWorldPosition.x - popupDistanceFromAnchorPoint.x < boundingRectangleWorld.x )
917     {
918       xOffSetToKeepWithinBounds = boundingRectangleWorld.x - ( popupWorldPosition.x - popupDistanceFromAnchorPoint.x );
919     }
920     else if ( popupWorldPosition.x +  popupDistanceFromAnchorPoint.x > boundingRectangleWorld.z )
921     {
922       xOffSetToKeepWithinBounds = boundingRectangleWorld.z - ( popupWorldPosition.x +  popupDistanceFromAnchorPoint.x );
923     }
924
925     // Ensure initial display of Popup is in alternative position if can not fit above. As Property notification will be a frame behind.
926     if ( popupWorldPosition.y - popupDistanceFromAnchorPoint.y < boundingRectangleWorld.y )
927     {
928       requiredPopupPosition.y = AlternatePopUpPositionRelativeToCursor();
929     }
930
931     requiredPopupPosition.x = requiredPopupPosition.x + xOffSetToKeepWithinBounds;
932   }
933
934   void SetScrollThreshold( float threshold )
935   {
936     mScrollThreshold = threshold;
937   }
938
939   float GetScrollThreshold() const
940   {
941     return mScrollThreshold;
942   }
943
944   void SetScrollSpeed( float speed )
945   {
946     mScrollSpeed = speed;
947     mScrollDistance = speed * SCROLL_TICK_INTERVAL * TO_SECONDS;
948   }
949
950   float GetScrollSpeed() const
951   {
952     return mScrollSpeed;
953   }
954
955   /**
956    * Creates and starts a timer to scroll the text when handles are close to the edges of the text.
957    *
958    * It only starts the timer if it's already created.
959    */
960   void StartScrollTimer()
961   {
962     if( !mScrollTimer )
963     {
964       mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL );
965       mScrollTimer.TickSignal().Connect( this, &Decorator::Impl::OnScrollTimerTick );
966     }
967
968     if( !mScrollTimer.IsRunning() )
969     {
970       mScrollTimer.Start();
971     }
972   }
973
974   /**
975    * Stops the timer used to scroll the text.
976    */
977   void StopScrollTimer()
978   {
979     if( mScrollTimer )
980     {
981       mScrollTimer.Stop();
982     }
983   }
984
985   /**
986    * Callback called by the timer used to scroll the text.
987    *
988    * It calculates and sets a new scroll position.
989    */
990   bool OnScrollTimerTick()
991   {
992     if( HANDLE_TYPE_COUNT != mHandleScrolling )
993     {
994       mController.DecorationEvent( mHandleScrolling,
995                                HANDLE_SCROLLING,
996                                mScrollDirection == SCROLL_RIGHT ? mScrollDistance : -mScrollDistance,
997                                0.f );
998     }
999
1000     return true;
1001   }
1002
1003   ControllerInterface& mController;
1004
1005   TapGestureDetector  mTapDetector;
1006   PanGestureDetector  mPanGestureDetector;
1007   Timer               mCursorBlinkTimer;          ///< Timer to signal cursor to blink
1008   Timer               mScrollTimer;               ///< Timer used to scroll the text when the grab handle is moved close to the edges.
1009
1010   Layer               mActiveLayer;               ///< Layer for active handles and alike that ensures they are above all else.
1011   ImageActor          mPrimaryCursor;
1012   ImageActor          mSecondaryCursor;
1013   MeshActor           mHighlightMeshActor;        ///< Mesh Actor to display highlight
1014   TextSelectionPopup  mCopyPastePopup;
1015
1016   Image               mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
1017   Image               mCursorImage;
1018   Mesh                mHighlightMesh;             ///< Mesh for highlight
1019   MeshData            mHighlightMeshData;         ///< Mesh Data for highlight
1020   Material            mHighlightMaterial;         ///< Material used for highlight
1021
1022   CursorImpl          mCursor[CURSOR_COUNT];
1023   HandleImpl          mHandle[HANDLE_TYPE_COUNT];
1024   QuadContainer       mHighlightQuadList;         ///< Sub-selections that combine to create the complete selection highlight
1025
1026   Rect<int>           mBoundingBox;
1027   Vector4             mHighlightColor;            ///< Color of the highlight
1028
1029   unsigned int        mActiveCursor;
1030   unsigned int        mCursorBlinkInterval;
1031   float               mCursorBlinkDuration;
1032   HandleType          mHandleScrolling;         ///< The handle which is scrolling.
1033   ScrollDirection     mScrollDirection;         ///< The direction of the scroll.
1034   float               mScrollThreshold;         ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
1035   float               mScrollSpeed;             ///< The scroll speed in pixels per second.
1036   float               mScrollDistance;          ///< Distance the text scrolls during a scroll interval.
1037   unsigned int        mScrollInterval;          ///< Time in milliseconds of a scroll interval.
1038
1039   bool                mActiveCopyPastePopup   : 1;
1040   bool                mCursorBlinkStatus      : 1; ///< Flag to switch between blink on and blink off.
1041   bool                mPrimaryCursorVisible   : 1; ///< Whether the primary cursor is visible.
1042   bool                mSecondaryCursorVisible : 1; ///< Whether the secondary cursor is visible.
1043 };
1044
1045 DecoratorPtr Decorator::New( ControllerInterface& controller )
1046 {
1047   return DecoratorPtr( new Decorator(controller) );
1048 }
1049
1050 void Decorator::SetBoundingBox( const Rect<int>& boundingBox )
1051 {
1052   mImpl->mBoundingBox = boundingBox;
1053 }
1054
1055 const Rect<int>& Decorator::GetBoundingBox() const
1056 {
1057   return mImpl->mBoundingBox;
1058 }
1059
1060 void Decorator::Relayout( const Vector2& size )
1061 {
1062   mImpl->Relayout( size );
1063 }
1064
1065 void Decorator::UpdatePositions( const Vector2& scrollOffset )
1066 {
1067   mImpl->UpdatePositions( scrollOffset );
1068 }
1069
1070 /** Cursor **/
1071
1072 void Decorator::SetActiveCursor( ActiveCursor activeCursor )
1073 {
1074   mImpl->mActiveCursor = activeCursor;
1075 }
1076
1077 unsigned int Decorator::GetActiveCursor() const
1078 {
1079   return mImpl->mActiveCursor;
1080 }
1081
1082 void Decorator::SetPosition( Cursor cursor, float x, float y, float cursorHeight, float lineHeight )
1083 {
1084   mImpl->mCursor[cursor].position.x = x;
1085   mImpl->mCursor[cursor].position.y = y;
1086   mImpl->mCursor[cursor].cursorHeight = cursorHeight;
1087   mImpl->mCursor[cursor].lineHeight = lineHeight;
1088 }
1089
1090 void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& cursorHeight, float& lineHeight ) const
1091 {
1092   x = mImpl->mCursor[cursor].position.x;
1093   y = mImpl->mCursor[cursor].position.y;
1094   cursorHeight = mImpl->mCursor[cursor].cursorHeight;
1095   lineHeight = mImpl->mCursor[cursor].lineHeight;
1096 }
1097
1098 const Vector2& Decorator::GetPosition( Cursor cursor ) const
1099 {
1100   return mImpl->mCursor[cursor].position;
1101 }
1102
1103 void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
1104 {
1105   mImpl->mCursor[cursor].color = color;
1106 }
1107
1108 const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
1109 {
1110   return mImpl->mCursor[cursor].color;
1111 }
1112
1113 void Decorator::StartCursorBlink()
1114 {
1115   if ( !mImpl->mCursorBlinkTimer )
1116   {
1117     mImpl->mCursorBlinkTimer = Timer::New( mImpl->mCursorBlinkInterval );
1118     mImpl->mCursorBlinkTimer.TickSignal().Connect( mImpl, &Decorator::Impl::OnCursorBlinkTimerTick );
1119   }
1120
1121   if ( !mImpl->mCursorBlinkTimer.IsRunning() )
1122   {
1123     mImpl->mCursorBlinkTimer.Start();
1124   }
1125 }
1126
1127 void Decorator::StopCursorBlink()
1128 {
1129   if ( mImpl->mCursorBlinkTimer )
1130   {
1131     mImpl->mCursorBlinkTimer.Stop();
1132   }
1133 }
1134
1135 void Decorator::SetCursorBlinkInterval( float seconds )
1136 {
1137   mImpl->mCursorBlinkInterval = static_cast<unsigned int>( seconds * TO_MILLISECONDS ); // Convert to milliseconds
1138 }
1139
1140 float Decorator::GetCursorBlinkInterval() const
1141 {
1142   return static_cast<float>( mImpl->mCursorBlinkInterval ) * TO_SECONDS;
1143 }
1144
1145 void Decorator::SetCursorBlinkDuration( float seconds )
1146 {
1147   mImpl->mCursorBlinkDuration = seconds;
1148 }
1149
1150 float Decorator::GetCursorBlinkDuration() const
1151 {
1152   return mImpl->mCursorBlinkDuration;
1153 }
1154
1155 /** Handles **/
1156
1157 void Decorator::SetHandleActive( HandleType handleType, bool active )
1158 {
1159   mImpl->mHandle[handleType].active = active;
1160 }
1161
1162 bool Decorator::IsHandleActive( HandleType handleType ) const
1163 {
1164   return mImpl->mHandle[handleType].active ;
1165 }
1166
1167 void Decorator::SetHandleImage( HandleType handleType, HandleImageType handleImageType, Dali::Image image )
1168 {
1169   mImpl->mHandleImages[handleType][handleImageType] = image;
1170 }
1171
1172 Dali::Image Decorator::GetHandleImage( HandleType handleType, HandleImageType handleImageType ) const
1173 {
1174   return mImpl->mHandleImages[handleType][handleImageType];
1175 }
1176
1177 void Decorator::SetPosition( HandleType handleType, float x, float y, float height )
1178 {
1179   // Adjust grab handle displacement
1180   Impl::HandleImpl& handle = mImpl->mHandle[handleType];
1181
1182   handle.grabDisplacementX -= x - handle.position.x;
1183   handle.grabDisplacementY -= y - handle.position.y;
1184
1185   handle.position.x = x;
1186   handle.position.y = y;
1187   handle.lineHeight = height;
1188 }
1189
1190 void Decorator::GetPosition( HandleType handleType, float& x, float& y, float& height ) const
1191 {
1192   Impl::HandleImpl& handle = mImpl->mHandle[handleType];
1193
1194   x = handle.position.x;
1195   y = handle.position.y;
1196   height = handle.lineHeight;
1197 }
1198
1199 void Decorator::AddHighlight( float x1, float y1, float x2, float y2 )
1200 {
1201   mImpl->mHighlightQuadList.push_back( QuadCoordinates(x1, y1, x2, y2) );
1202 }
1203
1204 void Decorator::ClearHighlights()
1205 {
1206   mImpl->mHighlightQuadList.clear();
1207 }
1208
1209 void Decorator::SetHighlightColor( const Vector4& color )
1210 {
1211   mImpl->mHighlightColor = color;
1212 }
1213
1214 const Vector4& Decorator::GetHighlightColor() const
1215 {
1216   return mImpl->mHighlightColor;
1217 }
1218
1219 void Decorator::SetPopupActive( bool active )
1220 {
1221   mImpl->mActiveCopyPastePopup = active;
1222 }
1223
1224 bool Decorator::IsPopupActive() const
1225 {
1226   return mImpl->mActiveCopyPastePopup ;
1227 }
1228
1229 /** Scroll **/
1230
1231 void Decorator::SetScrollThreshold( float threshold )
1232 {
1233   mImpl->SetScrollThreshold( threshold );
1234 }
1235
1236 float Decorator::GetScrollThreshold() const
1237 {
1238   return mImpl->GetScrollThreshold();
1239 }
1240
1241 void Decorator::SetScrollSpeed( float speed )
1242 {
1243   mImpl->SetScrollSpeed( speed );
1244 }
1245
1246 float Decorator::GetScrollSpeed() const
1247 {
1248   return mImpl->GetScrollSpeed();
1249 }
1250
1251 Decorator::~Decorator()
1252 {
1253   delete mImpl;
1254 }
1255
1256 Decorator::Decorator( ControllerInterface& controller )
1257 : mImpl( NULL )
1258 {
1259   mImpl = new Decorator::Impl( controller );
1260 }
1261
1262 } // namespace Text
1263
1264 } // namespace Toolkit
1265
1266 } // namespace Dali