2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/adaptor-framework/timer.h>
24 #include <dali/public-api/actors/image-actor.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/actors/mesh-actor.h>
27 #include <dali/public-api/common/constants.h>
28 #include <dali/public-api/events/tap-gesture.h>
29 #include <dali/public-api/events/tap-gesture-detector.h>
30 #include <dali/public-api/events/pan-gesture.h>
31 #include <dali/public-api/events/pan-gesture-detector.h>
32 #include <dali/public-api/geometry/mesh.h>
33 #include <dali/public-api/geometry/mesh-data.h>
34 #include <dali/public-api/images/resource-image.h>
35 #include <dali/public-api/math/vector2.h>
36 #include <dali/public-api/math/vector4.h>
37 //#include <dali/public-api/images/nine-patch-image.h>
38 #include <dali/public-api/signals/connection-tracker.h>
41 #include <dali-toolkit/public-api/controls/control.h>
42 #include <dali-toolkit/public-api/controls/control-impl.h>
43 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
44 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
45 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
46 #include <dali-toolkit/public-api/controls/text-controls/text-selection-popup.h>
49 #define DECORATOR_DEBUG
56 const char* DEFAULT_GRAB_HANDLE_IMAGE( DALI_IMAGE_DIR "insertpoint-icon.png" );
57 const char* DEFAULT_SELECTION_HANDLE_ONE( DALI_IMAGE_DIR "text-input-selection-handle-left.png" );
58 const char* DEFAULT_SELECTION_HANDLE_TWO( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
59 //const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" );
60 //const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" );
62 const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.5f, 2.0f, 1.0f );
63 const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.5f, 1.5f, 1.0f );
65 const std::size_t CURSOR_BLINK_INTERVAL = 500; // Cursor blink interval
66 const std::size_t MILLISECONDS = 1000;
68 const float DISPLAYED_HIGHLIGHT_Z_OFFSET( -0.05f );
71 * structure to hold coordinates of each quad, which will make up the mesh.
73 struct QuadCoordinates
84 * @param[in] x1 left co-ordinate
85 * @param[in] y1 top co-ordinate
86 * @param[in] x2 right co-ordinate
87 * @param[in] y2 bottom co-ordinate
89 QuadCoordinates(float x1, float y1, float x2, float y2)
95 Dali::Vector2 min; ///< top-left (minimum) position of quad
96 Dali::Vector2 max; ///< bottom-right (maximum) position of quad
99 typedef std::vector<QuadCoordinates> QuadContainer;
101 } // end of namespace
112 struct Decorator::Impl : public ConnectionTracker
120 color(Dali::Color::WHITE)
131 struct SelectionHandleImpl
133 SelectionHandleImpl()
143 float cursorHeight; ///< Not the handle height
153 Impl( Dali::Toolkit::Internal::Control& parent, Observer& observer )
154 : mTextControlParent(parent),
156 mActiveCursor(ACTIVE_CURSOR_NONE),
157 mActiveGrabHandle(false),
158 mActiveSelection( false ),
159 mActiveCopyPastePopup( false ),
160 mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ),
161 mCursorBlinkDuration( 0.0f ),
162 mCursorBlinkStatus( true ),
163 mGrabDisplacementX( 0.0f ),
164 mGrabDisplacementY( 0.0f ),
165 mHighlightColor( 0.07f, 0.41f, 0.59f, 1.0f ), // light blue
166 mBoundingBox( Rect<int>() )
171 * Relayout of the decorations owned by the decorator.
172 * @param[in] size The Size of the UI control the decorater is adding it's decorations to.
174 void Relayout( const Vector2& size, const Vector2& scrollPosition )
176 // TODO - Remove this if nothing is active
179 // Show or hide the cursors
183 mPrimaryCursor.SetPosition( mCursor[PRIMARY_CURSOR].x + scrollPosition.x,
184 mCursor[PRIMARY_CURSOR].y + scrollPosition.y );
185 mPrimaryCursor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
186 mPrimaryCursor.SetPreferredSize( Vector2( 1.0f, mCursor[PRIMARY_CURSOR].height ) );
188 if( mSecondaryCursor )
190 mSecondaryCursor.SetPosition( mCursor[SECONDARY_CURSOR].x + scrollPosition.x,
191 mCursor[SECONDARY_CURSOR].y + scrollPosition.y );
192 mSecondaryCursor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
193 mSecondaryCursor.SetPreferredSize( Vector2( 1.0f, mCursor[SECONDARY_CURSOR].height ) );
196 // Show or hide the grab handle
197 if( mActiveGrabHandle )
203 mGrabHandle.SetPosition( mCursor[PRIMARY_CURSOR].x + scrollPosition.x,
204 mCursor[PRIMARY_CURSOR].y + scrollPosition.y + mCursor[PRIMARY_CURSOR].height );
206 else if( mGrabHandle )
208 UnparentAndReset( mGrabHandle );
211 // Show or hide the selection handles/highlight
212 if( mActiveSelection )
216 CreateSelectionHandles();
218 SelectionHandleImpl& primary = mSelectionHandle[ PRIMARY_SELECTION_HANDLE ];
219 primary.actor.SetPosition( primary.x + scrollPosition.x,
220 primary.y + scrollPosition.y + primary.cursorHeight );
222 SelectionHandleImpl& secondary = mSelectionHandle[ SECONDARY_SELECTION_HANDLE ];
223 secondary.actor.SetPosition( secondary.x + scrollPosition.x,
224 secondary.y + scrollPosition.y + secondary.cursorHeight );
231 UnparentAndReset( mSelectionHandle[ PRIMARY_SELECTION_HANDLE ].actor );
232 UnparentAndReset( mSelectionHandle[ SECONDARY_SELECTION_HANDLE ].actor );
233 UnparentAndReset( mHighlightMeshActor );
236 if ( mActiveCopyPastePopup )
238 if ( !mCopyPastePopup )
240 mCopyPastePopup = TextSelectionPopup::New();
241 mActiveLayer.Add ( mCopyPastePopup );
243 mCopyPastePopup.SetPosition( Vector3( 200.0f, -100.0f, 0.0f ) ); //todo grabhandle or selection handle positions to be used
247 if ( mCopyPastePopup )
249 UnparentAndReset( mCopyPastePopup );
254 void CreateCursor( ImageActor& cursor )
256 cursor = CreateSolidColorActor( Color::WHITE );
257 cursor.SetParentOrigin( ParentOrigin::TOP_LEFT );
258 cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
261 // Add or Remove cursor(s) from parent
264 if( mActiveCursor == ACTIVE_CURSOR_NONE )
266 UnparentAndReset( mPrimaryCursor );
267 UnparentAndReset( mSecondaryCursor );
271 /* Create Primary and or Secondary Cursor(s) if active and add to parent */
272 if ( mActiveCursor == ACTIVE_CURSOR_PRIMARY ||
273 mActiveCursor == ACTIVE_CURSOR_BOTH )
275 if ( !mPrimaryCursor )
277 CreateCursor( mPrimaryCursor );
278 #ifdef DECORATOR_DEBUG
279 mPrimaryCursor.SetName( "PrimaryCursorActor" );
281 mActiveLayer.Add( mPrimaryCursor);
285 if ( mActiveCursor == ACTIVE_CURSOR_BOTH )
287 if ( !mSecondaryCursor )
289 CreateCursor( mSecondaryCursor );
290 #ifdef DECORATOR_DEBUG
291 mSecondaryCursor.SetName( "SecondaryCursorActor" );
293 mActiveLayer.Add( mSecondaryCursor);
299 bool OnCursorBlinkTimerTick()
302 if ( mPrimaryCursor )
304 mPrimaryCursor.SetVisible( mCursorBlinkStatus );
306 if ( mSecondaryCursor )
308 mSecondaryCursor.SetVisible( mCursorBlinkStatus );
311 mCursorBlinkStatus = !mCursorBlinkStatus;
316 void SetupTouchEvents()
320 mTapDetector = TapGestureDetector::New();
321 mTapDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnTap );
324 if ( !mPanGestureDetector )
326 mPanGestureDetector = PanGestureDetector::New();
327 mPanGestureDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnPan );
331 void CreateActiveLayer()
335 Actor parent = mTextControlParent.Self();
337 mActiveLayer = Layer::New();
338 #ifdef DECORATOR_DEBUG
339 mActiveLayer.SetName ( "ActiveLayerActor" );
342 mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
343 mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
344 mActiveLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
345 mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
347 parent.Add( mActiveLayer );
350 mActiveLayer.RaiseToTop();
353 void CreateGrabHandle()
357 if ( !mGrabHandleImage )
359 mGrabHandleImage = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE );
362 mGrabHandle = ImageActor::New( mGrabHandleImage );
363 #ifdef DECORATOR_DEBUG
364 mGrabHandle.SetName( "GrabHandleActor" );
366 mGrabHandle.SetParentOrigin( ParentOrigin::TOP_LEFT );
367 mGrabHandle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
368 mGrabHandle.SetDrawMode( DrawMode::OVERLAY );
369 // Area that Grab handle responds to, larger than actual handle so easier to move
370 //#ifdef DECORATOR_DEBUG
371 // mGrabArea = Toolkit::CreateSolidColorActor( Vector4(0.0f, 0.0f, 0.0f, 0.0f), true, Color::RED, 1 );
372 // mGrabArea.SetName( "GrabArea" );
374 mGrabArea = Actor::New(); //todo Force use of Actor until SolidColorActor fixed in Size Negotiation
375 mGrabArea.SetRelayoutEnabled( true );
377 mGrabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
378 mGrabArea.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
379 mGrabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
380 mGrabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
381 mGrabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
382 mGrabHandle.Add( mGrabArea );
384 mTapDetector.Attach( mGrabArea );
385 mPanGestureDetector.Attach( mGrabArea );
387 mActiveLayer.Add(mGrabHandle);
391 void CreateSelectionHandles()
393 SelectionHandleImpl& primary = mSelectionHandle[ PRIMARY_SELECTION_HANDLE ];
394 if ( !primary.actor )
396 if ( !primary.releasedImage )
398 primary.releasedImage = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE );
401 primary.actor = ImageActor::New( primary.releasedImage );
402 #ifdef DECORATOR_DEBUG
403 primary.actor.SetName("SelectionHandleOne");
405 primary.actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
406 primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
407 primary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
408 primary.flipped = false;
410 primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
411 #ifdef DECORATOR_DEBUG
412 primary.grabArea.SetName("SelectionHandleOneGrabArea");
414 primary.grabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
415 primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
416 primary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
418 mTapDetector.Attach( primary.grabArea );
419 mPanGestureDetector.Attach( primary.grabArea );
420 primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
422 primary.actor.Add( primary.grabArea );
423 mActiveLayer.Add( primary.actor );
426 SelectionHandleImpl& secondary = mSelectionHandle[ SECONDARY_SELECTION_HANDLE ];
427 if ( !secondary.actor )
429 if ( !secondary.releasedImage )
431 secondary.releasedImage = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO );
434 secondary.actor = ImageActor::New( secondary.releasedImage );
435 #ifdef DECORATOR_DEBUG
436 secondary.actor.SetName("SelectionHandleTwo");
438 secondary.actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
439 secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text.
440 secondary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
441 secondary.flipped = false;
443 secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
444 #ifdef DECORATOR_DEBUG
445 secondary.grabArea.SetName("SelectionHandleTwoGrabArea");
447 secondary.grabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
448 secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
449 secondary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
451 mTapDetector.Attach( secondary.grabArea );
452 mPanGestureDetector.Attach( secondary.grabArea );
453 secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
455 secondary.actor.Add( secondary.grabArea );
456 mActiveLayer.Add( secondary.actor );
459 //SetUpHandlePropertyNotifications(); TODO
462 void CreateHighlight()
464 if ( !mHighlightMeshActor )
466 mHighlightMaterial = Material::New( "HighlightMaterial" );
467 mHighlightMaterial.SetDiffuseColor( mHighlightColor );
469 mHighlightMeshData.SetMaterial( mHighlightMaterial );
470 mHighlightMeshData.SetHasNormals( true );
472 mHighlightMesh = Mesh::New( mHighlightMeshData );
474 mHighlightMeshActor = MeshActor::New( mHighlightMesh );
475 #ifdef DECORATOR_DEBUG
476 mHighlightMeshActor.SetName( "HighlightMeshActor" );
478 mHighlightMeshActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
479 mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
480 mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
482 Actor parent = mTextControlParent.Self();
483 parent.Add( mHighlightMeshActor );
487 void UpdateHighlight()
489 // Construct a Mesh with a texture to be used as the highlight 'box' for selected text
491 // Example scenarios where mesh is made from 3, 1, 2, 2 ,3 or 3 quads.
493 // [ TOP ] [ TOP ] [TOP ] [ TOP ] [ TOP ] [ TOP ]
494 // [ MIDDLE ] [BOTTOM] [BOTTOM] [ MIDDLE ] [ MIDDLE ]
495 // [ BOTTOM] [ MIDDLE ] [ MIDDLE ]
496 // [BOTTOM] [ MIDDLE ]
499 // Each quad is created as 2 triangles.
500 // Middle is just 1 quad regardless of its size.
514 if ( mHighlightMesh && mHighlightMaterial && !mHighlightQuadList.empty() )
516 MeshData::VertexContainer vertices;
517 Dali::MeshData::FaceIndices faceIndices;
519 std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
520 std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
522 // vertex position defaults to (0 0 0)
523 MeshData::Vertex vertex;
524 // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor.
527 for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
529 // Add each quad geometry (a sub-selection) to the mesh data.
539 QuadCoordinates& quad = *iter;
541 vertex.x = quad.min.x;
542 vertex.y = quad.min.y;
543 vertices.push_back( vertex );
546 vertex.x = quad.max.x;
547 vertex.y = quad.min.y;
548 vertices.push_back( vertex );
551 vertex.x = quad.min.x;
552 vertex.y = quad.max.y;
553 vertices.push_back( vertex );
555 // bottom-right (v+3)
556 vertex.x = quad.max.x;
557 vertex.y = quad.max.y;
558 vertices.push_back( vertex );
560 // triangle A (3, 1, 0)
561 faceIndices.push_back( v + 3 );
562 faceIndices.push_back( v + 1 );
563 faceIndices.push_back( v );
565 // triangle B (0, 2, 3)
566 faceIndices.push_back( v );
567 faceIndices.push_back( v + 2 );
568 faceIndices.push_back( v + 3 );
570 mHighlightMeshData.SetFaceIndices( faceIndices );
573 BoneContainer bones(0); // passed empty as bones not required
574 mHighlightMeshData.SetData( vertices, faceIndices, bones, mHighlightMaterial );
575 mHighlightMesh.UpdateMeshData( mHighlightMeshData );
579 void OnTap( Actor actor, const TapGesture& tap )
581 if( actor == mGrabHandle )
587 void OnPan( Actor actor, const PanGesture& gesture )
589 if( actor == mGrabArea )
591 if( Gesture::Started == gesture.state )
593 mGrabDisplacementX = mGrabDisplacementY = 0;
596 mGrabDisplacementX += gesture.displacement.x;
597 mGrabDisplacementY += gesture.displacement.y;
599 float x = mCursor[PRIMARY_CURSOR].x + mGrabDisplacementX;
600 float y = mCursor[PRIMARY_CURSOR].y + mCursor[PRIMARY_CURSOR].height*0.5f + mGrabDisplacementY;
602 if( Gesture::Started == gesture.state ||
603 Gesture::Continuing == gesture.state )
605 mObserver.GrabHandleEvent( GRAB_HANDLE_PRESSED, x, y );
607 else if( Gesture::Finished == gesture.state ||
608 Gesture::Cancelled == gesture.state )
610 mObserver.GrabHandleEvent( GRAB_HANDLE_RELEASED, x, y );
615 bool OnHandleOneTouched( Actor actor, const TouchEvent& touch )
621 bool OnHandleTwoTouched( Actor actor, const TouchEvent& touch )
628 Internal::Control& mTextControlParent;
631 Layer mActiveLayer; // Layer for active handles and alike that ensures they are above all else.
633 unsigned int mActiveCursor;
634 bool mActiveGrabHandle;
635 bool mActiveSelection;
636 bool mActiveCopyPastePopup;
638 CursorImpl mCursor[CURSOR_COUNT];
640 Timer mCursorBlinkTimer; // Timer to signal cursor to blink
641 unsigned int mCursorBlinkInterval;
642 float mCursorBlinkDuration;
643 bool mCursorBlinkStatus; // Flag to switch between blink on and blink off
645 ImageActor mPrimaryCursor;
646 ImageActor mSecondaryCursor;
648 ImageActor mGrabHandle;
650 float mGrabDisplacementX;
651 float mGrabDisplacementY;
653 SelectionHandleImpl mSelectionHandle[SELECTION_HANDLE_COUNT];
655 MeshActor mHighlightMeshActor; ///< Mesh Actor to display highlight
656 Mesh mHighlightMesh; ///< Mesh for highlight
657 MeshData mHighlightMeshData; ///< Mesh Data for highlight
658 Material mHighlightMaterial; ///< Material used for highlight
659 Vector4 mHighlightColor; ///< Color of the highlight
660 QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
662 TextSelectionPopup mCopyPastePopup;
665 Image mGrabHandleImage;
667 TapGestureDetector mTapDetector;
668 PanGestureDetector mPanGestureDetector;
670 Rect<int> mBoundingBox;
673 DecoratorPtr Decorator::New( Internal::Control& parent, Observer& observer )
675 return DecoratorPtr( new Decorator(parent, observer) );
678 void Decorator::SetBoundingBox( const Rect<int>& boundingBox )
680 mImpl->mBoundingBox = boundingBox;
683 const Rect<int>& Decorator::GetBoundingBox() const
685 return mImpl->mBoundingBox;
688 void Decorator::Relayout( const Vector2& size, const Vector2& scrollPosition )
690 mImpl->Relayout( size, scrollPosition );
695 void Decorator::SetActiveCursor( ActiveCursor activeCursor )
697 mImpl->mActiveCursor = activeCursor;
700 unsigned int Decorator::GetActiveCursor() const
702 return mImpl->mActiveCursor;
705 void Decorator::SetPosition( Cursor cursor, float x, float y, float height )
707 // Adjust grab handle displacement
708 mImpl->mGrabDisplacementX -= x - mImpl->mCursor[cursor].x;
709 mImpl->mGrabDisplacementY -= y - mImpl->mCursor[cursor].y;
711 mImpl->mCursor[cursor].x = x;
712 mImpl->mCursor[cursor].y = y;
713 mImpl->mCursor[cursor].height = height;
716 void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& height ) const
718 x = mImpl->mCursor[cursor].x;
719 y = mImpl->mCursor[cursor].y;
720 height = mImpl->mCursor[cursor].height;
723 void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
725 mImpl->mCursor[cursor].color = color;
728 const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
730 return mImpl->mCursor[cursor].color;
733 void Decorator::StartCursorBlink()
735 if ( !mImpl->mCursorBlinkTimer )
737 mImpl->mCursorBlinkTimer = Timer::New( mImpl->mCursorBlinkInterval );
738 mImpl->mCursorBlinkTimer.TickSignal().Connect( mImpl, &Decorator::Impl::OnCursorBlinkTimerTick );
741 if ( !mImpl->mCursorBlinkTimer.IsRunning() )
743 mImpl->mCursorBlinkTimer.Start();
747 void Decorator::StopCursorBlink()
749 if ( mImpl->mCursorBlinkTimer )
751 mImpl->mCursorBlinkTimer.Stop();
755 void Decorator::SetCursorBlinkInterval( float seconds )
757 mImpl->mCursorBlinkInterval = seconds*MILLISECONDS; // Convert to milliseconds
760 float Decorator::GetCursorBlinkInterval() const
762 return mImpl->mCursorBlinkInterval;
765 void Decorator::SetCursorBlinkDuration( float seconds )
767 mImpl->mCursorBlinkDuration = seconds;
770 float Decorator::GetCursorBlinkDuration() const
772 return mImpl->mCursorBlinkDuration;
777 void Decorator::SetGrabHandleActive( bool active )
779 mImpl->mActiveGrabHandle = active;
782 bool Decorator::IsGrabHandleActive() const
784 return mImpl->mActiveGrabHandle;
787 void Decorator::SetGrabHandleImage( Dali::Image image )
789 mImpl->mGrabHandleImage = image;
792 Dali::Image Decorator::GetGrabHandleImage() const
794 return mImpl->mGrabHandleImage;
799 void Decorator::SetSelectionActive( bool active )
801 mImpl->mActiveSelection = active;
804 bool Decorator::IsSelectionActive() const
806 return mImpl->mActiveSelection;
809 void Decorator::SetPosition( SelectionHandle handle, float x, float y, float height )
811 mImpl->mSelectionHandle[handle].x = x;
812 mImpl->mSelectionHandle[handle].y = y;
813 mImpl->mSelectionHandle[handle].cursorHeight = height;
816 void Decorator::GetPosition( SelectionHandle handle, float& x, float& y, float& height ) const
818 x = mImpl->mSelectionHandle[handle].x;
819 y = mImpl->mSelectionHandle[handle].y;
820 height = mImpl->mSelectionHandle[handle].cursorHeight;
823 void Decorator::SetImage( SelectionHandle handle, SelectionHandleState state, Dali::Image image )
825 if( SELECTION_HANDLE_PRESSED == state )
827 mImpl->mSelectionHandle[handle].pressedImage = image;
831 mImpl->mSelectionHandle[handle].releasedImage = image;
835 Dali::Image Decorator::GetImage( SelectionHandle handle, SelectionHandleState state ) const
837 if( SELECTION_HANDLE_PRESSED == state )
839 return mImpl->mSelectionHandle[handle].pressedImage;
842 return mImpl->mSelectionHandle[handle].releasedImage;
845 void Decorator::AddHighlight( float x1, float y1, float x2, float y2 )
847 mImpl->mHighlightQuadList.push_back( QuadCoordinates(x1, y1, x2, y2) );
850 void Decorator::ClearHighlights()
852 mImpl->mHighlightQuadList.clear();
855 void Decorator::SetPopupActive( bool active )
857 mImpl->mActiveCopyPastePopup = active;
860 bool Decorator::IsPopupActive() const
862 return mImpl->mActiveCopyPastePopup ;
865 Decorator::~Decorator()
870 Decorator::Decorator( Dali::Toolkit::Internal::Control& parent, Observer& observer )
873 mImpl = new Decorator::Impl( parent, observer );
878 } // namespace Toolkit