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.SetSize( Vector2( 1.0f, mCursor[PRIMARY_CURSOR].height ) );
187 if( mSecondaryCursor )
189 mSecondaryCursor.SetPosition( mCursor[SECONDARY_CURSOR].x + scrollPosition.x,
190 mCursor[SECONDARY_CURSOR].y + scrollPosition.y );
191 mSecondaryCursor.SetSize( Vector2( 1.0f, mCursor[SECONDARY_CURSOR].height ) );
194 // Show or hide the grab handle
195 if( mActiveGrabHandle )
201 mGrabHandle.SetPosition( mCursor[PRIMARY_CURSOR].x + scrollPosition.x,
202 mCursor[PRIMARY_CURSOR].y + scrollPosition.y + mCursor[PRIMARY_CURSOR].height );
204 else if( mGrabHandle )
206 UnparentAndReset( mGrabHandle );
209 // Show or hide the selection handles/highlight
210 if( mActiveSelection )
214 CreateSelectionHandles();
216 SelectionHandleImpl& primary = mSelectionHandle[ PRIMARY_SELECTION_HANDLE ];
217 primary.actor.SetPosition( primary.x + scrollPosition.x,
218 primary.y + scrollPosition.y + primary.cursorHeight );
220 SelectionHandleImpl& secondary = mSelectionHandle[ SECONDARY_SELECTION_HANDLE ];
221 secondary.actor.SetPosition( secondary.x + scrollPosition.x,
222 secondary.y + scrollPosition.y + secondary.cursorHeight );
229 UnparentAndReset( mSelectionHandle[ PRIMARY_SELECTION_HANDLE ].actor );
230 UnparentAndReset( mSelectionHandle[ SECONDARY_SELECTION_HANDLE ].actor );
231 UnparentAndReset( mHighlightMeshActor );
234 if ( mActiveCopyPastePopup )
236 if ( !mCopyPastePopup )
238 mCopyPastePopup = TextSelectionPopup::New();
239 mActiveLayer.Add ( mCopyPastePopup );
241 mCopyPastePopup.SetPosition( Vector3( 200.0f, -100.0f, 0.0f ) ); //todo grabhandle or selection handle positions to be used
245 if ( mCopyPastePopup )
247 UnparentAndReset( mCopyPastePopup );
252 void CreateCursor( ImageActor& cursor )
254 cursor = CreateSolidColorActor( Color::WHITE );
255 cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one.
256 cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
257 cursor.SetRelayoutEnabled( false );
260 // Add or Remove cursor(s) from parent
263 if( mActiveCursor == ACTIVE_CURSOR_NONE )
265 UnparentAndReset( mPrimaryCursor );
266 UnparentAndReset( mSecondaryCursor );
270 /* Create Primary and or Secondary Cursor(s) if active and add to parent */
271 if ( mActiveCursor == ACTIVE_CURSOR_PRIMARY ||
272 mActiveCursor == ACTIVE_CURSOR_BOTH )
274 if ( !mPrimaryCursor )
276 CreateCursor( mPrimaryCursor );
277 #ifdef DECORATOR_DEBUG
278 mPrimaryCursor.SetName( "PrimaryCursorActor" );
280 mActiveLayer.Add( mPrimaryCursor);
284 if ( mActiveCursor == ACTIVE_CURSOR_BOTH )
286 if ( !mSecondaryCursor )
288 CreateCursor( mSecondaryCursor );
289 #ifdef DECORATOR_DEBUG
290 mSecondaryCursor.SetName( "SecondaryCursorActor" );
292 mActiveLayer.Add( mSecondaryCursor);
298 bool OnCursorBlinkTimerTick()
301 if ( mPrimaryCursor )
303 mPrimaryCursor.SetVisible( mCursorBlinkStatus );
305 if ( mSecondaryCursor )
307 mSecondaryCursor.SetVisible( mCursorBlinkStatus );
310 mCursorBlinkStatus = !mCursorBlinkStatus;
315 void SetupTouchEvents()
319 mTapDetector = TapGestureDetector::New();
320 mTapDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnTap );
323 if ( !mPanGestureDetector )
325 mPanGestureDetector = PanGestureDetector::New();
326 mPanGestureDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnPan );
330 void CreateActiveLayer()
334 Actor parent = mTextControlParent.Self();
336 mActiveLayer = Layer::New();
337 #ifdef DECORATOR_DEBUG
338 mActiveLayer.SetName ( "ActiveLayerActor" );
341 mActiveLayer.SetParentOrigin( ParentOrigin::CENTER );
342 mActiveLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
343 mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
345 parent.Add( mActiveLayer );
348 mActiveLayer.RaiseToTop();
351 void CreateGrabHandle()
355 if ( !mGrabHandleImage )
357 mGrabHandleImage = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE );
360 mGrabHandle = ImageActor::New( mGrabHandleImage );
361 #ifdef DECORATOR_DEBUG
362 mGrabHandle.SetName( "GrabHandleActor" );
364 mGrabHandle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
365 mGrabHandle.SetDrawMode( DrawMode::OVERLAY );
366 // Area that Grab handle responds to, larger than actual handle so easier to move
367 #ifdef DECORATOR_DEBUG
368 mGrabArea = Toolkit::CreateSolidColorActor( Vector4(0.0f, 0.0f, 0.0f, 0.0f), true, Color::RED, 1 );
369 mGrabArea.SetName( "GrabArea" );
371 mGrabArea = Actor::New();
372 mGrabArea.SetRelayoutEnabled( true );
374 mGrabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
375 mGrabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
376 mGrabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
377 mGrabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
378 mGrabHandle.Add( mGrabArea );
380 mTapDetector.Attach( mGrabArea );
381 mPanGestureDetector.Attach( mGrabArea );
383 mActiveLayer.Add(mGrabHandle);
387 void CreateSelectionHandles()
389 SelectionHandleImpl& primary = mSelectionHandle[ PRIMARY_SELECTION_HANDLE ];
390 if ( !primary.actor )
392 if ( !primary.releasedImage )
394 primary.releasedImage = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE );
397 primary.actor = ImageActor::New( primary.releasedImage );
398 #ifdef DECORATOR_DEBUG
399 primary.actor.SetName("SelectionHandleOne");
401 primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
402 primary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
403 primary.flipped = false;
405 primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
406 primary.grabArea.SetRelayoutEnabled( true );
407 #ifdef DECORATOR_DEBUG
408 primary.grabArea.SetName("SelectionHandleOneGrabArea");
410 primary.grabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
411 primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
412 primary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
414 mTapDetector.Attach( primary.grabArea );
415 mPanGestureDetector.Attach( primary.grabArea );
416 primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
418 primary.actor.Add( primary.grabArea );
419 mActiveLayer.Add( primary.actor );
422 SelectionHandleImpl& secondary = mSelectionHandle[ SECONDARY_SELECTION_HANDLE ];
423 if ( !secondary.actor )
425 if ( !secondary.releasedImage )
427 secondary.releasedImage = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO );
430 secondary.actor = ImageActor::New( secondary.releasedImage );
431 #ifdef DECORATOR_DEBUG
432 secondary.actor.SetName("SelectionHandleTwo");
434 secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text.
435 secondary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
436 secondary.flipped = false;
438 secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
439 secondary.grabArea.SetRelayoutEnabled( true );
440 #ifdef DECORATOR_DEBUG
441 secondary.grabArea.SetName("SelectionHandleTwoGrabArea");
443 secondary.grabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
444 secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
445 secondary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
447 mTapDetector.Attach( secondary.grabArea );
448 mPanGestureDetector.Attach( secondary.grabArea );
449 secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
451 secondary.actor.Add( secondary.grabArea );
452 mActiveLayer.Add( secondary.actor );
455 //SetUpHandlePropertyNotifications(); TODO
458 void CreateHighlight()
460 if ( !mHighlightMeshActor )
462 mHighlightMaterial = Material::New( "HighlightMaterial" );
463 mHighlightMaterial.SetDiffuseColor( mHighlightColor );
465 mHighlightMeshData.SetMaterial( mHighlightMaterial );
466 mHighlightMeshData.SetHasNormals( true );
468 mHighlightMesh = Mesh::New( mHighlightMeshData );
470 mHighlightMeshActor = MeshActor::New( mHighlightMesh );
471 #ifdef DECORATOR_DEBUG
472 mHighlightMeshActor.SetName( "HighlightMeshActor" );
474 mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
475 mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
477 Actor parent = mTextControlParent.Self();
478 parent.Add( mHighlightMeshActor );
482 void UpdateHighlight()
484 // Construct a Mesh with a texture to be used as the highlight 'box' for selected text
486 // Example scenarios where mesh is made from 3, 1, 2, 2 ,3 or 3 quads.
488 // [ TOP ] [ TOP ] [TOP ] [ TOP ] [ TOP ] [ TOP ]
489 // [ MIDDLE ] [BOTTOM] [BOTTOM] [ MIDDLE ] [ MIDDLE ]
490 // [ BOTTOM] [ MIDDLE ] [ MIDDLE ]
491 // [BOTTOM] [ MIDDLE ]
494 // Each quad is created as 2 triangles.
495 // Middle is just 1 quad regardless of its size.
509 if ( mHighlightMesh && mHighlightMaterial && !mHighlightQuadList.empty() )
511 MeshData::VertexContainer vertices;
512 Dali::MeshData::FaceIndices faceIndices;
514 std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
515 std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
517 // vertex position defaults to (0 0 0)
518 MeshData::Vertex vertex;
519 // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor.
522 for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
524 // Add each quad geometry (a sub-selection) to the mesh data.
534 QuadCoordinates& quad = *iter;
536 vertex.x = quad.min.x;
537 vertex.y = quad.min.y;
538 vertices.push_back( vertex );
541 vertex.x = quad.max.x;
542 vertex.y = quad.min.y;
543 vertices.push_back( vertex );
546 vertex.x = quad.min.x;
547 vertex.y = quad.max.y;
548 vertices.push_back( vertex );
550 // bottom-right (v+3)
551 vertex.x = quad.max.x;
552 vertex.y = quad.max.y;
553 vertices.push_back( vertex );
555 // triangle A (3, 1, 0)
556 faceIndices.push_back( v + 3 );
557 faceIndices.push_back( v + 1 );
558 faceIndices.push_back( v );
560 // triangle B (0, 2, 3)
561 faceIndices.push_back( v );
562 faceIndices.push_back( v + 2 );
563 faceIndices.push_back( v + 3 );
565 mHighlightMeshData.SetFaceIndices( faceIndices );
568 BoneContainer bones(0); // passed empty as bones not required
569 mHighlightMeshData.SetData( vertices, faceIndices, bones, mHighlightMaterial );
570 mHighlightMesh.UpdateMeshData( mHighlightMeshData );
574 void OnTap( Actor actor, const TapGesture& tap )
576 if( actor == mGrabHandle )
582 void OnPan( Actor actor, const PanGesture& gesture )
584 if( actor == mGrabArea )
586 if( Gesture::Started == gesture.state )
588 mGrabDisplacementX = mGrabDisplacementY = 0;
591 mGrabDisplacementX += gesture.displacement.x;
592 mGrabDisplacementY += gesture.displacement.y;
594 float x = mCursor[PRIMARY_CURSOR].x + mGrabDisplacementX;
595 float y = mCursor[PRIMARY_CURSOR].y + mCursor[PRIMARY_CURSOR].height*0.5f + mGrabDisplacementY;
597 if( Gesture::Started == gesture.state ||
598 Gesture::Continuing == gesture.state )
600 mObserver.GrabHandleEvent( GRAB_HANDLE_PRESSED, x, y );
602 else if( Gesture::Finished == gesture.state ||
603 Gesture::Cancelled == gesture.state )
605 mObserver.GrabHandleEvent( GRAB_HANDLE_RELEASED, x, y );
610 bool OnHandleOneTouched( Actor actor, const TouchEvent& touch )
616 bool OnHandleTwoTouched( Actor actor, const TouchEvent& touch )
623 Internal::Control& mTextControlParent;
626 Layer mActiveLayer; // Layer for active handles and alike that ensures they are above all else.
628 unsigned int mActiveCursor;
629 bool mActiveGrabHandle;
630 bool mActiveSelection;
631 bool mActiveCopyPastePopup;
633 CursorImpl mCursor[CURSOR_COUNT];
635 Timer mCursorBlinkTimer; // Timer to signal cursor to blink
636 unsigned int mCursorBlinkInterval;
637 float mCursorBlinkDuration;
638 bool mCursorBlinkStatus; // Flag to switch between blink on and blink off
640 ImageActor mPrimaryCursor;
641 ImageActor mSecondaryCursor;
643 ImageActor mGrabHandle;
645 float mGrabDisplacementX;
646 float mGrabDisplacementY;
648 SelectionHandleImpl mSelectionHandle[SELECTION_HANDLE_COUNT];
650 MeshActor mHighlightMeshActor; ///< Mesh Actor to display highlight
651 Mesh mHighlightMesh; ///< Mesh for highlight
652 MeshData mHighlightMeshData; ///< Mesh Data for highlight
653 Material mHighlightMaterial; ///< Material used for highlight
654 Vector4 mHighlightColor; ///< Color of the highlight
655 QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
657 TextSelectionPopup mCopyPastePopup;
660 Image mGrabHandleImage;
662 TapGestureDetector mTapDetector;
663 PanGestureDetector mPanGestureDetector;
665 Rect<int> mBoundingBox;
668 DecoratorPtr Decorator::New( Internal::Control& parent, Observer& observer )
670 return DecoratorPtr( new Decorator(parent, observer) );
673 void Decorator::SetBoundingBox( const Rect<int>& boundingBox )
675 mImpl->mBoundingBox = boundingBox;
678 const Rect<int>& Decorator::GetBoundingBox() const
680 return mImpl->mBoundingBox;
683 void Decorator::Relayout( const Vector2& size, const Vector2& scrollPosition )
685 mImpl->Relayout( size, scrollPosition );
690 void Decorator::SetActiveCursor( ActiveCursor activeCursor )
692 mImpl->mActiveCursor = activeCursor;
695 unsigned int Decorator::GetActiveCursor() const
697 return mImpl->mActiveCursor;
700 void Decorator::SetPosition( Cursor cursor, float x, float y, float height )
702 // Adjust grab handle displacement
703 mImpl->mGrabDisplacementX -= x - mImpl->mCursor[cursor].x;
704 mImpl->mGrabDisplacementY -= y - mImpl->mCursor[cursor].y;
706 mImpl->mCursor[cursor].x = x;
707 mImpl->mCursor[cursor].y = y;
708 mImpl->mCursor[cursor].height = height;
711 void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& height ) const
713 x = mImpl->mCursor[cursor].x;
714 y = mImpl->mCursor[cursor].y;
715 height = mImpl->mCursor[cursor].height;
718 void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
720 mImpl->mCursor[cursor].color = color;
723 const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
725 return mImpl->mCursor[cursor].color;
728 void Decorator::StartCursorBlink()
730 if ( !mImpl->mCursorBlinkTimer )
732 mImpl->mCursorBlinkTimer = Timer::New( mImpl->mCursorBlinkInterval );
733 mImpl->mCursorBlinkTimer.TickSignal().Connect( mImpl, &Decorator::Impl::OnCursorBlinkTimerTick );
736 if ( !mImpl->mCursorBlinkTimer.IsRunning() )
738 mImpl->mCursorBlinkTimer.Start();
742 void Decorator::StopCursorBlink()
744 if ( mImpl->mCursorBlinkTimer )
746 mImpl->mCursorBlinkTimer.Stop();
750 void Decorator::SetCursorBlinkInterval( float seconds )
752 mImpl->mCursorBlinkInterval = seconds*MILLISECONDS; // Convert to milliseconds
755 float Decorator::GetCursorBlinkInterval() const
757 return mImpl->mCursorBlinkInterval;
760 void Decorator::SetCursorBlinkDuration( float seconds )
762 mImpl->mCursorBlinkDuration = seconds;
765 float Decorator::GetCursorBlinkDuration() const
767 return mImpl->mCursorBlinkDuration;
772 void Decorator::SetGrabHandleActive( bool active )
774 mImpl->mActiveGrabHandle = active;
777 bool Decorator::IsGrabHandleActive() const
779 return mImpl->mActiveGrabHandle;
782 void Decorator::SetGrabHandleImage( Dali::Image image )
784 mImpl->mGrabHandleImage = image;
787 Dali::Image Decorator::GetGrabHandleImage() const
789 return mImpl->mGrabHandleImage;
794 void Decorator::SetSelectionActive( bool active )
796 mImpl->mActiveSelection = active;
799 bool Decorator::IsSelectionActive() const
801 return mImpl->mActiveSelection;
804 void Decorator::SetPosition( SelectionHandle handle, float x, float y, float height )
806 mImpl->mSelectionHandle[handle].x = x;
807 mImpl->mSelectionHandle[handle].y = y;
808 mImpl->mSelectionHandle[handle].cursorHeight = height;
811 void Decorator::GetPosition( SelectionHandle handle, float& x, float& y, float& height ) const
813 x = mImpl->mSelectionHandle[handle].x;
814 y = mImpl->mSelectionHandle[handle].y;
815 height = mImpl->mSelectionHandle[handle].cursorHeight;
818 void Decorator::SetImage( SelectionHandle handle, SelectionHandleState state, Dali::Image image )
820 if( SELECTION_HANDLE_PRESSED == state )
822 mImpl->mSelectionHandle[handle].pressedImage = image;
826 mImpl->mSelectionHandle[handle].releasedImage = image;
830 Dali::Image Decorator::GetImage( SelectionHandle handle, SelectionHandleState state ) const
832 if( SELECTION_HANDLE_PRESSED == state )
834 return mImpl->mSelectionHandle[handle].pressedImage;
837 return mImpl->mSelectionHandle[handle].releasedImage;
840 void Decorator::AddHighlight( float x1, float y1, float x2, float y2 )
842 mImpl->mHighlightQuadList.push_back( QuadCoordinates(x1, y1, x2, y2) );
845 void Decorator::ClearHighlights()
847 mImpl->mHighlightQuadList.clear();
850 void Decorator::SetPopupActive( bool active )
852 mImpl->mActiveCopyPastePopup = active;
855 bool Decorator::IsPopupActive() const
857 return mImpl->mActiveCopyPastePopup ;
860 Decorator::~Decorator()
865 Decorator::Decorator( Dali::Toolkit::Internal::Control& parent, Observer& observer )
868 mImpl = new Decorator::Impl( parent, observer );
873 } // namespace Toolkit