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