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