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