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