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/integration-api/debug.h>
24 #include <dali/public-api/adaptor-framework/timer.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/common/stage.h>
27 #include <dali/public-api/events/touch-event.h>
28 #include <dali/public-api/events/pan-gesture.h>
29 #include <dali/public-api/images/resource-image.h>
30 #include <dali/public-api/object/property-notification.h>
32 #include <dali/devel-api/rendering/geometry.h>
33 #include <dali/devel-api/rendering/renderer.h>
36 #include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
37 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
40 #define DECORATOR_DEBUG
44 #define MAKE_SHADER(A)#A
48 const char* VERTEX_SHADER = MAKE_SHADER(
49 attribute mediump vec2 aPosition;
50 uniform mediump mat4 uMvpMatrix;
51 uniform mediump vec3 uSize;
55 mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
56 position.xyz *= uSize;
57 gl_Position = uMvpMatrix * position;
61 const char* FRAGMENT_SHADER = MAKE_SHADER(
62 uniform lowp vec4 uColor;
66 gl_FragColor = uColor;
77 #ifdef DECORATOR_DEBUG
78 Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_TEXT_DECORATOR") );
89 const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "cursor_handler_center.png" );
90 const char* DEFAULT_SELECTION_HANDLE_ONE_RELEASED( DALI_IMAGE_DIR "selection_handle_left.png" );
91 const char* DEFAULT_SELECTION_HANDLE_TWO_RELEASED( DALI_IMAGE_DIR "selection_handle_right.png" );
93 const int DEFAULT_POPUP_OFFSET( -100.0f ); // Vertical offset of Popup from cursor or handles position.
95 const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
96 const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
98 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. TODO: due some problems, maybe with the blending function in the text clipping, the color is fully opaque.
100 const Dali::Vector4 HANDLE_COLOR( 0.0f, (183.0f / 255.0f), (229.0f / 255.0f), 1.0f );
102 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
103 const float TO_MILLISECONDS = 1000.f;
104 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
106 const unsigned int SCROLL_TICK_INTERVAL = 50u;
108 const float SCROLL_THRESHOLD = 10.f;
109 const float SCROLL_SPEED = 300.f;
110 const float SCROLL_DISTANCE = SCROLL_SPEED * SCROLL_TICK_INTERVAL * TO_SECONDS;
113 * structure to hold coordinates of each quad, which will make up the mesh.
115 struct QuadCoordinates
118 * Default constructor
126 * @param[in] x1 left co-ordinate
127 * @param[in] y1 top co-ordinate
128 * @param[in] x2 right co-ordinate
129 * @param[in] y2 bottom co-ordinate
131 QuadCoordinates(float x1, float y1, float x2, float y2)
137 Dali::Vector2 min; ///< top-left (minimum) position of quad
138 Dali::Vector2 max; ///< bottom-right (maximum) position of quad
141 typedef std::vector<QuadCoordinates> QuadContainer;
144 * @brief Takes a bounding rectangle in the local coordinates of an actor and returns the world coordinates Bounding Box.
145 * @param[in] boundingRectangle local bounding
146 * @param[out] Vector4 World coordinate bounding Box.
148 void LocalToWorldCoordinatesBoundingBox( const Dali::Rect<int>& boundingRectangle, Dali::Vector4& boundingBox )
150 // Convert to world coordinates and store as a Vector4 to be compatible with Property Notifications.
151 Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
153 const float originX = boundingRectangle.x - 0.5f * stageSize.width;
154 const float originY = boundingRectangle.y - 0.5f * stageSize.height;
156 boundingBox = Dali::Vector4( originX,
158 originX + boundingRectangle.width,
159 originY + boundingRectangle.height );
163 } // end of namespace
174 struct Decorator::Impl : public ConnectionTracker
188 : color( Dali::Color::BLACK ),
190 cursorHeight( 0.0f ),
206 grabDisplacementX( 0.f ),
207 grabDisplacementY( 0.f ),
219 float lineHeight; ///< Not the handle height
220 float grabDisplacementX;
221 float grabDisplacementY;
232 offset( DEFAULT_POPUP_OFFSET )
236 TextSelectionPopup actor;
241 Impl( ControllerInterface& controller,
242 TextSelectionPopupCallbackInterface& callbackInterface )
243 : mController( controller ),
244 mEnabledPopupButtons( TextSelectionPopup::NONE ),
245 mTextSelectionPopupCallbackInterface( callbackInterface ),
246 mHandleColor( HANDLE_COLOR ),
247 mBoundingBox( Rect<int>() ),
248 mHighlightColor( LIGHT_BLUE ),
249 mHighlightPosition( Vector2::ZERO ),
250 mActiveCursor( ACTIVE_CURSOR_NONE ),
251 mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ),
252 mCursorBlinkDuration( 0.0f ),
253 mHandleScrolling( HANDLE_TYPE_COUNT ),
254 mScrollDirection( SCROLL_NONE ),
255 mScrollThreshold( SCROLL_THRESHOLD ),
256 mScrollSpeed( SCROLL_SPEED ),
257 mScrollDistance( SCROLL_DISTANCE ),
259 mActiveCopyPastePopup( false ),
260 mCursorBlinkStatus( true ),
261 mPrimaryCursorVisible( false ),
262 mSecondaryCursorVisible( false ),
263 mSwapSelectionHandles( false ),
264 mNotifyEndOfScroll( false )
266 mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
267 mQuadIndexFormat[ "indices" ] = Property::INTEGER;
268 mHighlightMaterial = Material::New( Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ) );
272 * Relayout of the decorations owned by the decorator.
273 * @param[in] size The Size of the UI control the decorator is adding it's decorations to.
275 void Relayout( const Vector2& size )
277 // TODO - Remove this if nothing is active
280 // Show or hide the cursors
285 const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
286 mPrimaryCursorVisible = ( cursor.position.x <= size.width ) && ( cursor.position.x >= 0.f );
287 if( mPrimaryCursorVisible )
289 Vector2 position = cursor.position;
291 mPrimaryCursor.SetPosition( position.x,
293 mPrimaryCursor.SetSize( Size( 1.0f, cursor.cursorHeight ) );
295 mPrimaryCursor.SetVisible( mPrimaryCursorVisible );
297 if( mSecondaryCursor )
299 const CursorImpl& cursor = mCursor[SECONDARY_CURSOR];
300 mSecondaryCursorVisible = ( cursor.position.x <= size.width ) && ( cursor.position.x >= 0.f );
301 if( mSecondaryCursorVisible )
303 mSecondaryCursor.SetPosition( cursor.position.x,
305 mSecondaryCursor.SetSize( Size( 1.0f, cursor.cursorHeight ) );
307 mSecondaryCursor.SetVisible( mSecondaryCursorVisible );
310 // Show or hide the grab handle
311 HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
312 if( grabHandle.active )
314 Vector2 position = grabHandle.position;
316 const bool isVisible = ( position.x <= size.width ) && ( position.x >= 0.f );
324 grabHandle.actor.SetPosition( position.x,
325 grabHandle.lineHeight ); // TODO : Fix for multiline.
327 grabHandle.actor.SetVisible( isVisible );
329 else if( grabHandle.actor )
331 grabHandle.actor.Unparent();
334 // Show or hide the selection handles/highlight
335 HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
336 HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
337 if( primary.active || secondary.active )
339 Vector2 primaryPosition = primary.position;
340 Vector2 secondaryPosition = secondary.position;
342 const bool isPrimaryVisible = ( primaryPosition.x <= size.width ) && ( primaryPosition.x >= 0.f );
343 const bool isSecondaryVisible = ( secondaryPosition.x <= size.width ) && ( secondaryPosition.x >= 0.f );
345 if( isPrimaryVisible || isSecondaryVisible )
349 CreateSelectionHandles();
351 if( isPrimaryVisible )
353 primary.actor.SetPosition( primaryPosition.x,
354 primary.lineHeight ); // TODO : Fix for multiline.
357 if( isSecondaryVisible )
359 secondary.actor.SetPosition( secondaryPosition.x,
360 secondary.lineHeight ); // TODO : Fix for multiline.
363 primary.actor.SetVisible( isPrimaryVisible );
364 secondary.actor.SetVisible( isSecondaryVisible );
373 primary.actor.Unparent();
375 if( secondary.actor )
377 secondary.actor.Unparent();
379 if( mHighlightActor )
381 mHighlightActor.Unparent();
385 if( mActiveCopyPastePopup )
387 if( !mCopyPastePopup.actor.GetParent() )
389 mActiveLayer.Add( mCopyPastePopup.actor );
392 mCopyPastePopup.actor.RaiseAbove( mActiveLayer );
396 if( mCopyPastePopup.actor )
398 mCopyPastePopup.actor.Unparent();
403 void UpdatePositions( const Vector2& scrollOffset )
405 mCursor[PRIMARY_CURSOR].position += scrollOffset;
406 mCursor[SECONDARY_CURSOR].position += scrollOffset;
407 mHandle[ GRAB_HANDLE ].position += scrollOffset;
408 mHandle[ LEFT_SELECTION_HANDLE ].position += scrollOffset;
409 mHandle[ RIGHT_SELECTION_HANDLE ].position += scrollOffset;
410 mHighlightPosition += scrollOffset;
411 DeterminePositionPopup();
414 void DeterminePositionPopup()
416 if ( !mActiveCopyPastePopup )
421 if ( mHandle[LEFT_SELECTION_HANDLE].active || mHandle[RIGHT_SELECTION_HANDLE].active )
423 float minHandleXPosition = std::min ( mHandle[LEFT_SELECTION_HANDLE].position.x, mHandle[RIGHT_SELECTION_HANDLE].position.x );
424 float maxHandleXPosition = std::max ( mHandle[LEFT_SELECTION_HANDLE].position.x, mHandle[RIGHT_SELECTION_HANDLE].position.x );
426 float minHandleYPosition = std::min ( mHandle[LEFT_SELECTION_HANDLE].position.y, mHandle[RIGHT_SELECTION_HANDLE].position.y );
428 mCopyPastePopup.position.x = minHandleXPosition + ( ( maxHandleXPosition - minHandleXPosition ) *0.5f );
429 mCopyPastePopup.position.y = minHandleYPosition + mCopyPastePopup.offset;
433 mCopyPastePopup.position = Vector3( mCursor[PRIMARY_CURSOR].position.x, mCursor[PRIMARY_CURSOR].position.y -100.0f , 0.0f ); //todo 100 to be an offset Property
436 Vector3 popupSize = Vector3( mCopyPastePopup.actor.GetRelayoutSize( Dimension::WIDTH ), mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT ), 0.0f );
438 GetConstrainedPopupPosition( mCopyPastePopup.position, popupSize, AnchorPoint::CENTER, mActiveLayer, mBoundingBox );
440 SetUpPopupPositionNotifications();
442 mCopyPastePopup.actor.SetPosition( mCopyPastePopup.position );
445 void PopupRelayoutComplete( Actor actor )
447 // Size negotiation for CopyPastePopup complete so can get the size and constrain position within bounding box.
448 mCopyPastePopup.actor.OnRelayoutSignal().Disconnect( this, &Decorator::Impl::PopupRelayoutComplete );
450 DeterminePositionPopup();
453 void CreateCursor( ImageActor& cursor, const Vector4& color )
455 cursor = CreateSolidColorActor( color );
456 cursor.SetSortModifier( DECORATION_DEPTH_INDEX );
457 cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one.
458 cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
461 // Add or Remove cursor(s) from parent
464 if( mActiveCursor == ACTIVE_CURSOR_NONE )
468 mPrimaryCursor.Unparent();
470 if( mSecondaryCursor )
472 mSecondaryCursor.Unparent();
477 // Create Primary and or Secondary Cursor(s) if active and add to parent
478 if ( mActiveCursor == ACTIVE_CURSOR_PRIMARY ||
479 mActiveCursor == ACTIVE_CURSOR_BOTH )
481 if ( !mPrimaryCursor )
483 CreateCursor( mPrimaryCursor, mCursor[PRIMARY_CURSOR].color );
484 #ifdef DECORATOR_DEBUG
485 mPrimaryCursor.SetName( "PrimaryCursorActor" );
489 if( !mPrimaryCursor.GetParent() )
491 mActiveLayer.Add( mPrimaryCursor );
495 if ( mActiveCursor == ACTIVE_CURSOR_BOTH )
497 if ( !mSecondaryCursor )
499 CreateCursor( mSecondaryCursor, mCursor[SECONDARY_CURSOR].color );
500 #ifdef DECORATOR_DEBUG
501 mSecondaryCursor.SetName( "SecondaryCursorActor" );
505 if( !mSecondaryCursor.GetParent() )
507 mActiveLayer.Add( mSecondaryCursor );
512 if( mSecondaryCursor )
514 mSecondaryCursor.Unparent();
520 bool OnCursorBlinkTimerTick()
523 if ( mPrimaryCursor )
525 mPrimaryCursor.SetVisible( mPrimaryCursorVisible && mCursorBlinkStatus );
527 if ( mSecondaryCursor )
529 mSecondaryCursor.SetVisible( mSecondaryCursorVisible && mCursorBlinkStatus );
532 mCursorBlinkStatus = !mCursorBlinkStatus;
537 void SetupTouchEvents()
541 mTapDetector = TapGestureDetector::New();
542 mTapDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnTap );
545 if ( !mPanGestureDetector )
547 mPanGestureDetector = PanGestureDetector::New();
548 mPanGestureDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnPan );
552 void CreateActiveLayer()
556 mActiveLayer = Layer::New();
557 #ifdef DECORATOR_DEBUG
558 mActiveLayer.SetName ( "ActiveLayerActor" );
561 mActiveLayer.SetParentOrigin( ParentOrigin::CENTER );
562 mActiveLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
563 mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
565 // Add the active layer telling the controller it doesn't need clipping.
566 mController.AddDecoration( mActiveLayer, false );
569 mActiveLayer.RaiseToTop();
572 void CreateGrabHandle()
574 HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
575 if( !grabHandle.actor )
577 if( !mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] )
579 mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_RELEASED );
582 grabHandle.actor = ImageActor::New( mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] );
583 grabHandle.actor.SetSortModifier( DECORATION_DEPTH_INDEX );
584 grabHandle.actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
585 // Area that Grab handle responds to, larger than actual handle so easier to move
586 #ifdef DECORATOR_DEBUG
587 grabHandle.actor.SetName( "GrabHandleActor" );
588 if ( Dali::Internal::gLogFilter->IsEnabledFor( Debug::Verbose ) )
590 grabHandle.grabArea = Toolkit::CreateSolidColorActor( Vector4(0.0f, 0.0f, 0.0f, 0.0f), true, Color::RED, 1 );
591 grabHandle.grabArea.SetName( "GrabArea" );
595 grabHandle.grabArea = Actor::New();
596 grabHandle.grabArea.SetName( "GrabArea" );
599 grabHandle.grabArea = Actor::New();
602 grabHandle.grabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
603 grabHandle.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
604 grabHandle.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
605 grabHandle.grabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
606 grabHandle.actor.Add( grabHandle.grabArea );
607 grabHandle.actor.SetColor( mHandleColor );
609 grabHandle.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
610 mTapDetector.Attach( grabHandle.grabArea );
611 mPanGestureDetector.Attach( grabHandle.grabArea );
613 mActiveLayer.Add( grabHandle.actor );
616 if( !grabHandle.actor.GetParent() )
618 mActiveLayer.Add( grabHandle.actor );
622 void CreateSelectionHandles()
624 HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
627 if( !mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
629 mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_RELEASED );
632 primary.actor = ImageActor::New( mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
633 #ifdef DECORATOR_DEBUG
634 primary.actor.SetName("SelectionHandleOne");
636 primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
637 primary.actor.SetSortModifier( DECORATION_DEPTH_INDEX );
638 primary.flipped = false;
639 primary.actor.SetColor( mHandleColor );
641 primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
642 #ifdef DECORATOR_DEBUG
643 primary.grabArea.SetName("SelectionHandleOneGrabArea");
645 primary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
646 primary.grabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
647 primary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
648 primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
650 mTapDetector.Attach( primary.grabArea );
651 mPanGestureDetector.Attach( primary.grabArea );
652 primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
654 primary.actor.Add( primary.grabArea );
657 if( !primary.actor.GetParent() )
659 mActiveLayer.Add( primary.actor );
662 HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
663 if( !secondary.actor )
665 if( !mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
667 mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_RELEASED );
670 secondary.actor = ImageActor::New( mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
671 #ifdef DECORATOR_DEBUG
672 secondary.actor.SetName("SelectionHandleTwo");
674 secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text.
675 secondary.actor.SetSortModifier( DECORATION_DEPTH_INDEX );
676 secondary.flipped = false;
677 secondary.actor.SetColor( mHandleColor );
679 secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
680 #ifdef DECORATOR_DEBUG
681 secondary.grabArea.SetName("SelectionHandleTwoGrabArea");
683 secondary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
684 secondary.grabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
685 secondary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
686 secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
688 mTapDetector.Attach( secondary.grabArea );
689 mPanGestureDetector.Attach( secondary.grabArea );
690 secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
692 secondary.actor.Add( secondary.grabArea );
695 if( !secondary.actor.GetParent() )
697 mActiveLayer.Add( secondary.actor );
701 void CreateHighlight()
703 if( !mHighlightActor )
705 mHighlightActor = Actor::New();
707 #ifdef DECORATOR_DEBUG
708 mHighlightActor.SetName( "HighlightActor" );
710 mHighlightActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
711 mHighlightActor.SetSize( 1.0f, 1.0f );
712 mHighlightActor.SetColor( mHighlightColor );
713 mHighlightActor.SetColorMode( USE_OWN_COLOR );
716 // Add the highlight box telling the controller it needs clipping.
717 mController.AddDecoration( mHighlightActor, true );
720 void UpdateHighlight()
722 if ( mHighlightActor )
724 if( !mHighlightQuadList.empty() )
726 Vector< Vector2 > vertices;
727 Vector< unsigned int> indices;
730 std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
731 std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
733 for( std::size_t v = 0; iter != endIter; ++iter,v+=4 )
736 QuadCoordinates& quad = *iter;
739 vertex.x = quad.min.x;
740 vertex.y = quad.min.y;
741 vertices.PushBack( vertex );
744 vertex.x = quad.max.x;
745 vertex.y = quad.min.y;
746 vertices.PushBack( vertex );
749 vertex.x = quad.min.x;
750 vertex.y = quad.max.y;
751 vertices.PushBack( vertex );
753 // bottom-right (v+3)
754 vertex.x = quad.max.x;
755 vertex.y = quad.max.y;
756 vertices.PushBack( vertex );
758 // triangle A (3, 1, 0)
759 indices.PushBack( v + 3 );
760 indices.PushBack( v + 1 );
761 indices.PushBack( v );
763 // triangle B (0, 2, 3)
764 indices.PushBack( v );
765 indices.PushBack( v + 2 );
766 indices.PushBack( v + 3 );
771 mQuadVertices.SetSize( vertices.Size() );
775 mQuadVertices = PropertyBuffer::New( mQuadVertexFormat, vertices.Size() );
780 mQuadIndices.SetSize( indices.Size() );
784 mQuadIndices = PropertyBuffer::New( mQuadIndexFormat, indices.Size() );
787 mQuadVertices.SetData( &vertices[ 0 ] );
788 mQuadIndices.SetData( &indices[ 0 ] );
792 mQuadGeometry = Geometry::New();
793 mQuadGeometry.AddVertexBuffer( mQuadVertices );
795 mQuadGeometry.SetIndexBuffer( mQuadIndices );
797 if( !mHighlightRenderer )
799 mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightMaterial );
800 mHighlightActor.AddRenderer( mHighlightRenderer );
804 mHighlightActor.SetPosition( mHighlightPosition.x,
805 mHighlightPosition.y );
807 mHighlightQuadList.clear();
809 mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
813 void OnTap( Actor actor, const TapGesture& tap )
815 if( actor == mHandle[GRAB_HANDLE].actor )
821 void DoPan( HandleImpl& handle, HandleType type, const PanGesture& gesture )
823 if( Gesture::Started == gesture.state )
825 handle.grabDisplacementX = handle.grabDisplacementY = 0;
828 handle.grabDisplacementX += gesture.displacement.x;
829 handle.grabDisplacementY += gesture.displacement.y;
831 const float x = handle.position.x + handle.grabDisplacementX;
832 const float y = handle.position.y + handle.lineHeight*0.5f + handle.grabDisplacementY;
834 if( Gesture::Started == gesture.state ||
835 Gesture::Continuing == gesture.state )
838 mController.GetTargetSize( targetSize );
840 if( x < mScrollThreshold )
842 mScrollDirection = SCROLL_RIGHT;
843 mHandleScrolling = type;
846 else if( x > targetSize.width - mScrollThreshold )
848 mScrollDirection = SCROLL_LEFT;
849 mHandleScrolling = type;
854 mHandleScrolling = HANDLE_TYPE_COUNT;
856 mController.DecorationEvent( type, HANDLE_PRESSED, x, y );
859 else if( Gesture::Finished == gesture.state ||
860 Gesture::Cancelled == gesture.state )
863 ( mScrollTimer.IsRunning() || mNotifyEndOfScroll ) )
865 mNotifyEndOfScroll = false;
866 mHandleScrolling = HANDLE_TYPE_COUNT;
868 mController.DecorationEvent( type, HANDLE_STOP_SCROLLING, x, y );
872 mController.DecorationEvent( type, HANDLE_RELEASED, x, y );
875 if( GRAB_HANDLE == type )
877 handle.actor.SetImage( mHandleImages[type][HANDLE_IMAGE_RELEASED] );
881 HandleType selectionHandleType = type;
883 if( mSwapSelectionHandles != handle.flipped )
885 selectionHandleType = ( LEFT_SELECTION_HANDLE == type ) ? RIGHT_SELECTION_HANDLE : LEFT_SELECTION_HANDLE;
888 handle.actor.SetImage( mHandleImages[selectionHandleType][HANDLE_IMAGE_RELEASED] );
890 handle.pressed = false;
894 void OnPan( Actor actor, const PanGesture& gesture )
896 HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
897 HandleImpl& primarySelectionHandle = mHandle[LEFT_SELECTION_HANDLE];
898 HandleImpl& secondarySelectionHandle = mHandle[RIGHT_SELECTION_HANDLE];
900 if( actor == grabHandle.grabArea )
902 DoPan( grabHandle, GRAB_HANDLE, gesture );
904 else if( actor == primarySelectionHandle.grabArea )
906 DoPan( primarySelectionHandle, LEFT_SELECTION_HANDLE, gesture );
908 else if( actor == secondarySelectionHandle.grabArea )
910 DoPan( secondarySelectionHandle, RIGHT_SELECTION_HANDLE, gesture );
914 bool OnGrabHandleTouched( Actor actor, const TouchEvent& event )
916 // Switch between pressed/release grab-handle images
917 if( event.GetPointCount() > 0 &&
918 mHandle[GRAB_HANDLE].actor )
920 const TouchPoint& point = event.GetPoint(0);
922 if( TouchPoint::Down == point.state )
924 mHandle[GRAB_HANDLE].pressed = true;
925 Image imagePressed = mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED];
928 mHandle[GRAB_HANDLE].actor.SetImage( imagePressed );
931 else if( ( TouchPoint::Up == point.state ) ||
932 ( TouchPoint::Interrupted == point.state ) )
934 mHandle[GRAB_HANDLE].pressed = false;
935 Image imageReleased = mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED];
938 mHandle[GRAB_HANDLE].actor.SetImage( imageReleased );
943 // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
947 bool OnHandleOneTouched( Actor actor, const TouchEvent& event )
949 // Switch between pressed/release selection handle images
950 if( event.GetPointCount() > 0 &&
951 mHandle[LEFT_SELECTION_HANDLE].actor )
953 const TouchPoint& point = event.GetPoint(0);
955 const bool flip = mSwapSelectionHandles != mHandle[LEFT_SELECTION_HANDLE].flipped;
956 if( TouchPoint::Down == point.state )
958 mHandle[LEFT_SELECTION_HANDLE].pressed = true;
959 Image imagePressed = mHandleImages[flip ? RIGHT_SELECTION_HANDLE : LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED];
962 mHandle[LEFT_SELECTION_HANDLE].actor.SetImage( imagePressed );
965 else if( ( TouchPoint::Up == point.state ) ||
966 ( TouchPoint::Interrupted == point.state ) )
968 mHandle[LEFT_SELECTION_HANDLE].pressed = false;
969 Image imageReleased = mHandleImages[flip ? RIGHT_SELECTION_HANDLE : LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED];
972 mHandle[LEFT_SELECTION_HANDLE].actor.SetImage( imageReleased );
977 // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
981 bool OnHandleTwoTouched( Actor actor, const TouchEvent& event )
983 // Switch between pressed/release selection handle images
984 if( event.GetPointCount() > 0 &&
985 mHandle[RIGHT_SELECTION_HANDLE].actor )
987 const TouchPoint& point = event.GetPoint(0);
989 const bool flip = mSwapSelectionHandles != mHandle[RIGHT_SELECTION_HANDLE].flipped;
990 if( TouchPoint::Down == point.state )
992 Image imagePressed = mHandleImages[flip ? LEFT_SELECTION_HANDLE : RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED];
993 mHandle[RIGHT_SELECTION_HANDLE].pressed = true;
996 mHandle[RIGHT_SELECTION_HANDLE].actor.SetImage( imagePressed );
999 else if( ( TouchPoint::Up == point.state ) ||
1000 ( TouchPoint::Interrupted == point.state ) )
1002 Image imageReleased = mHandleImages[flip ? LEFT_SELECTION_HANDLE : RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED];
1003 mHandle[RIGHT_SELECTION_HANDLE].pressed = false;
1006 mHandle[RIGHT_SELECTION_HANDLE].actor.SetImage( imageReleased );
1011 // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
1017 float AlternatePopUpPositionRelativeToCursor()
1019 float alternativePosition=0.0f;;
1021 if ( mPrimaryCursor ) // Secondary cursor not used for paste
1023 Cursor cursor = PRIMARY_CURSOR;
1024 alternativePosition = mCursor[cursor].position.y;
1027 const float popupHeight = 120.0f; // todo Set as a MaxSize Property in Control or retrieve from CopyPastePopup class.
1029 if( mHandle[GRAB_HANDLE].active )
1031 // If grab handle enabled then position pop-up below the grab handle.
1032 const Vector2 grabHandleSize( 59.0f, 56.0f ); // todo
1033 const float BOTTOM_HANDLE_BOTTOM_OFFSET = 1.5; //todo Should be a property
1034 alternativePosition += grabHandleSize.height + popupHeight + BOTTOM_HANDLE_BOTTOM_OFFSET ;
1038 alternativePosition += popupHeight;
1041 return alternativePosition;
1044 void PopUpLeavesVerticalBoundary( PropertyNotification& source )
1046 float alternativeYPosition=0.0f;
1047 // todo use AlternatePopUpPositionRelativeToSelectionHandles() if text is highlighted
1048 // if can't be positioned above, then position below row.
1049 alternativeYPosition = AlternatePopUpPositionRelativeToCursor();
1051 mCopyPastePopup.actor.SetY( alternativeYPosition );
1055 void SetUpPopupPositionNotifications( )
1057 // Note Property notifications ignore any set anchor point so conditions must allow for this. Default is Top Left.
1059 // Exceeding vertical boundary
1061 Vector4 worldCoordinatesBoundingBox;
1062 LocalToWorldCoordinatesBoundingBox( mBoundingBox, worldCoordinatesBoundingBox );
1064 float popupHeight = mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT);
1066 PropertyNotification verticalExceedNotification = mCopyPastePopup.actor.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
1067 OutsideCondition( worldCoordinatesBoundingBox.y + popupHeight * 0.5f,
1068 worldCoordinatesBoundingBox.w - popupHeight * 0.5f ) );
1070 verticalExceedNotification.NotifySignal().Connect( this, &Decorator::Impl::PopUpLeavesVerticalBoundary );
1073 void GetConstrainedPopupPosition( Vector3& requiredPopupPosition, Vector3& popupSize, Vector3 anchorPoint, Actor& parent, Rect<int>& boundingBox )
1075 DALI_ASSERT_DEBUG ( "Popup parent not on stage" && parent.OnStage() )
1077 // Parent must already by added to Stage for these Get calls to work
1078 Vector3 parentAnchorPoint = parent.GetCurrentAnchorPoint();
1079 Vector3 parentWorldPositionLeftAnchor = parent.GetCurrentWorldPosition() - parent.GetCurrentSize()*parentAnchorPoint;
1080 Vector3 popupWorldPosition = parentWorldPositionLeftAnchor + requiredPopupPosition; // Parent World position plus popup local position gives World Position
1081 Vector3 popupDistanceFromAnchorPoint = popupSize*anchorPoint;
1083 // Bounding rectangle is supplied as screen coordinates, bounding will be done in world coordinates.
1084 Vector4 boundingRectangleWorld;
1085 LocalToWorldCoordinatesBoundingBox( boundingBox, boundingRectangleWorld );
1087 // Calculate distance to move popup (in local space) so fits within the boundary
1088 float xOffSetToKeepWithinBounds = 0.0f;
1089 if( popupWorldPosition.x - popupDistanceFromAnchorPoint.x < boundingRectangleWorld.x )
1091 xOffSetToKeepWithinBounds = boundingRectangleWorld.x - ( popupWorldPosition.x - popupDistanceFromAnchorPoint.x );
1093 else if ( popupWorldPosition.x + popupDistanceFromAnchorPoint.x > boundingRectangleWorld.z )
1095 xOffSetToKeepWithinBounds = boundingRectangleWorld.z - ( popupWorldPosition.x + popupDistanceFromAnchorPoint.x );
1098 // Ensure initial display of Popup is in alternative position if can not fit above. As Property notification will be a frame behind.
1099 if ( popupWorldPosition.y - popupDistanceFromAnchorPoint.y < boundingRectangleWorld.y )
1101 requiredPopupPosition.y = AlternatePopUpPositionRelativeToCursor();
1104 requiredPopupPosition.x = requiredPopupPosition.x + xOffSetToKeepWithinBounds;
1106 // Prevent pixel mis-alignment by rounding down.
1107 requiredPopupPosition.x = static_cast<int>( requiredPopupPosition.x );
1108 requiredPopupPosition.y = static_cast<int>( requiredPopupPosition.y );
1112 void FlipSelectionHandleImages()
1116 CreateSelectionHandles();
1118 HandleImpl& leftHandle = mHandle[LEFT_SELECTION_HANDLE];
1119 HandleImpl& rightHandle = mHandle[RIGHT_SELECTION_HANDLE];
1121 // If handle pressed and pressed image exists then use pressed image else stick with released image
1122 const HandleImageType leftImageType = ( leftHandle.pressed && mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
1123 const HandleImageType rightImageType = ( rightHandle.pressed && mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
1125 const bool leftFlipped = mSwapSelectionHandles != leftHandle.flipped;
1126 const bool rightFlipped = mSwapSelectionHandles != rightHandle.flipped;
1128 leftHandle.actor.SetImage( leftFlipped ? mHandleImages[RIGHT_SELECTION_HANDLE][leftImageType] : mHandleImages[LEFT_SELECTION_HANDLE][leftImageType] );
1130 leftHandle.actor.SetAnchorPoint( leftFlipped ? AnchorPoint::TOP_LEFT : AnchorPoint::TOP_RIGHT );
1132 rightHandle.actor.SetImage( rightFlipped ? mHandleImages[LEFT_SELECTION_HANDLE][rightImageType] : mHandleImages[RIGHT_SELECTION_HANDLE][rightImageType] );
1134 rightHandle.actor.SetAnchorPoint( rightFlipped ? AnchorPoint::TOP_RIGHT : AnchorPoint::TOP_LEFT );
1137 void SetScrollThreshold( float threshold )
1139 mScrollThreshold = threshold;
1142 float GetScrollThreshold() const
1144 return mScrollThreshold;
1147 void SetScrollSpeed( float speed )
1149 mScrollSpeed = speed;
1150 mScrollDistance = speed * SCROLL_TICK_INTERVAL * TO_SECONDS;
1153 float GetScrollSpeed() const
1155 return mScrollSpeed;
1158 void NotifyEndOfScroll()
1164 mNotifyEndOfScroll = true;
1169 * Creates and starts a timer to scroll the text when handles are close to the edges of the text.
1171 * It only starts the timer if it's already created.
1173 void StartScrollTimer()
1177 mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL );
1178 mScrollTimer.TickSignal().Connect( this, &Decorator::Impl::OnScrollTimerTick );
1181 if( !mScrollTimer.IsRunning() )
1183 mScrollTimer.Start();
1188 * Stops the timer used to scroll the text.
1190 void StopScrollTimer()
1194 mScrollTimer.Stop();
1199 * Callback called by the timer used to scroll the text.
1201 * It calculates and sets a new scroll position.
1203 bool OnScrollTimerTick()
1205 if( HANDLE_TYPE_COUNT != mHandleScrolling )
1207 mController.DecorationEvent( mHandleScrolling,
1209 mScrollDirection == SCROLL_RIGHT ? mScrollDistance : -mScrollDistance,
1216 ControllerInterface& mController;
1218 TapGestureDetector mTapDetector;
1219 PanGestureDetector mPanGestureDetector;
1220 Timer mCursorBlinkTimer; ///< Timer to signal cursor to blink
1221 Timer mScrollTimer; ///< Timer used to scroll the text when the grab handle is moved close to the edges.
1223 Layer mActiveLayer; ///< Layer for active handles and alike that ensures they are above all else.
1224 ImageActor mPrimaryCursor;
1225 ImageActor mSecondaryCursor;
1227 Actor mHighlightActor; ///< Actor to display highlight
1228 Renderer mHighlightRenderer;
1229 Material mHighlightMaterial; ///< Material used for highlight
1230 Property::Map mQuadVertexFormat;
1231 Property::Map mQuadIndexFormat;
1232 PopupImpl mCopyPastePopup;
1233 TextSelectionPopup::Buttons mEnabledPopupButtons; /// Bit mask of currently enabled Popup buttons
1234 TextSelectionPopupCallbackInterface& mTextSelectionPopupCallbackInterface;
1236 Image mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
1237 Vector4 mHandleColor;
1239 CursorImpl mCursor[CURSOR_COUNT];
1240 HandleImpl mHandle[HANDLE_TYPE_COUNT];
1242 PropertyBuffer mQuadVertices;
1243 PropertyBuffer mQuadIndices;
1244 Geometry mQuadGeometry;
1245 QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
1247 Rect<int> mBoundingBox;
1248 Vector4 mHighlightColor; ///< Color of the highlight
1249 Vector2 mHighlightPosition; ///< The position of the highlight actor.
1251 unsigned int mActiveCursor;
1252 unsigned int mCursorBlinkInterval;
1253 float mCursorBlinkDuration;
1254 HandleType mHandleScrolling; ///< The handle which is scrolling.
1255 ScrollDirection mScrollDirection; ///< The direction of the scroll.
1256 float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
1257 float mScrollSpeed; ///< The scroll speed in pixels per second.
1258 float mScrollDistance; ///< Distance the text scrolls during a scroll interval.
1259 int mTextDepth; ///< The depth used to render the text.
1261 bool mActiveCopyPastePopup : 1;
1262 bool mCursorBlinkStatus : 1; ///< Flag to switch between blink on and blink off.
1263 bool mPrimaryCursorVisible : 1; ///< Whether the primary cursor is visible.
1264 bool mSecondaryCursorVisible : 1; ///< Whether the secondary cursor is visible.
1265 bool mSwapSelectionHandles : 1; ///< Whether to swap the selection handle images.
1266 bool mNotifyEndOfScroll : 1; ///< Whether to notify the end of the scroll.
1269 DecoratorPtr Decorator::New( ControllerInterface& controller,
1270 TextSelectionPopupCallbackInterface& callbackInterface )
1272 return DecoratorPtr( new Decorator( controller,
1273 callbackInterface ) );
1276 void Decorator::SetBoundingBox( const Rect<int>& boundingBox )
1278 mImpl->mBoundingBox = boundingBox;
1281 const Rect<int>& Decorator::GetBoundingBox() const
1283 return mImpl->mBoundingBox;
1286 void Decorator::Relayout( const Vector2& size )
1288 mImpl->Relayout( size );
1291 void Decorator::UpdatePositions( const Vector2& scrollOffset )
1293 mImpl->UpdatePositions( scrollOffset );
1298 void Decorator::SetActiveCursor( ActiveCursor activeCursor )
1300 mImpl->mActiveCursor = activeCursor;
1303 unsigned int Decorator::GetActiveCursor() const
1305 return mImpl->mActiveCursor;
1308 void Decorator::SetPosition( Cursor cursor, float x, float y, float cursorHeight, float lineHeight )
1310 mImpl->mCursor[cursor].position.x = x;
1311 mImpl->mCursor[cursor].position.y = y;
1312 mImpl->mCursor[cursor].cursorHeight = cursorHeight;
1313 mImpl->mCursor[cursor].lineHeight = lineHeight;
1316 void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& cursorHeight, float& lineHeight ) const
1318 x = mImpl->mCursor[cursor].position.x;
1319 y = mImpl->mCursor[cursor].position.y;
1320 cursorHeight = mImpl->mCursor[cursor].cursorHeight;
1321 lineHeight = mImpl->mCursor[cursor].lineHeight;
1324 const Vector2& Decorator::GetPosition( Cursor cursor ) const
1326 return mImpl->mCursor[cursor].position;
1329 void Decorator::SetCursorColor( Cursor cursor, const Dali::Vector4& color )
1331 mImpl->mCursor[cursor].color = color;
1334 const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
1336 return mImpl->mCursor[cursor].color;
1339 void Decorator::StartCursorBlink()
1341 if ( !mImpl->mCursorBlinkTimer )
1343 mImpl->mCursorBlinkTimer = Timer::New( mImpl->mCursorBlinkInterval );
1344 mImpl->mCursorBlinkTimer.TickSignal().Connect( mImpl, &Decorator::Impl::OnCursorBlinkTimerTick );
1347 if ( !mImpl->mCursorBlinkTimer.IsRunning() )
1349 mImpl->mCursorBlinkTimer.Start();
1353 void Decorator::StopCursorBlink()
1355 if ( mImpl->mCursorBlinkTimer )
1357 mImpl->mCursorBlinkTimer.Stop();
1361 void Decorator::SetCursorBlinkInterval( float seconds )
1363 mImpl->mCursorBlinkInterval = static_cast<unsigned int>( seconds * TO_MILLISECONDS ); // Convert to milliseconds
1366 float Decorator::GetCursorBlinkInterval() const
1368 return static_cast<float>( mImpl->mCursorBlinkInterval ) * TO_SECONDS;
1371 void Decorator::SetCursorBlinkDuration( float seconds )
1373 mImpl->mCursorBlinkDuration = seconds;
1376 float Decorator::GetCursorBlinkDuration() const
1378 return mImpl->mCursorBlinkDuration;
1383 void Decorator::SetHandleActive( HandleType handleType, bool active )
1385 mImpl->mHandle[handleType].active = active;
1389 // TODO: this is a work-around.
1390 // The problem is the handle actor does not receive the touch event with the Interrupt
1391 // state when the power button is pressed and the application goes to background.
1392 mImpl->mHandle[handleType].pressed = false;
1393 Image imageReleased = mImpl->mHandleImages[handleType][HANDLE_IMAGE_RELEASED];
1394 ImageActor imageActor = mImpl->mHandle[handleType].actor;
1395 if( imageReleased && imageActor )
1397 imageActor.SetImage( imageReleased );
1402 bool Decorator::IsHandleActive( HandleType handleType ) const
1404 return mImpl->mHandle[handleType].active ;
1407 void Decorator::SetHandleImage( HandleType handleType, HandleImageType handleImageType, Dali::Image image )
1409 mImpl->mHandleImages[handleType][handleImageType] = image;
1412 Dali::Image Decorator::GetHandleImage( HandleType handleType, HandleImageType handleImageType ) const
1414 return mImpl->mHandleImages[handleType][handleImageType];
1417 void Decorator::SetHandleColor( const Vector4& color )
1419 mImpl->mHandleColor = color;
1422 const Vector4& Decorator::GetHandleColor() const
1424 return mImpl->mHandleColor;
1427 void Decorator::SetPosition( HandleType handleType, float x, float y, float height )
1429 // Adjust grab handle displacement
1430 Impl::HandleImpl& handle = mImpl->mHandle[handleType];
1432 handle.grabDisplacementX -= x - handle.position.x;
1433 handle.grabDisplacementY -= y - handle.position.y;
1435 handle.position.x = x;
1436 handle.position.y = y;
1437 handle.lineHeight = height;
1440 void Decorator::GetPosition( HandleType handleType, float& x, float& y, float& height ) const
1442 Impl::HandleImpl& handle = mImpl->mHandle[handleType];
1444 x = handle.position.x;
1445 y = handle.position.y;
1446 height = handle.lineHeight;
1449 const Vector2& Decorator::GetPosition( HandleType handleType ) const
1451 return mImpl->mHandle[handleType].position;
1454 void Decorator::SwapSelectionHandlesEnabled( bool enable )
1456 mImpl->mSwapSelectionHandles = enable;
1458 mImpl->FlipSelectionHandleImages();
1461 void Decorator::AddHighlight( float x1, float y1, float x2, float y2 )
1463 mImpl->mHighlightQuadList.push_back( QuadCoordinates(x1, y1, x2, y2) );
1466 void Decorator::ClearHighlights()
1468 mImpl->mHighlightQuadList.clear();
1469 mImpl->mHighlightPosition = Vector2::ZERO;
1472 void Decorator::SetHighlightColor( const Vector4& color )
1474 mImpl->mHighlightColor = color;
1477 const Vector4& Decorator::GetHighlightColor() const
1479 return mImpl->mHighlightColor;
1482 void Decorator::SetTextDepth( int textDepth )
1484 mImpl->mTextDepth = textDepth;
1487 void Decorator::SetPopupActive( bool active )
1489 mImpl->mActiveCopyPastePopup = active;
1492 bool Decorator::IsPopupActive() const
1494 return mImpl->mActiveCopyPastePopup ;
1497 void Decorator::SetEnabledPopupButtons( TextSelectionPopup::Buttons& enabledButtonsBitMask )
1499 mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
1501 UnparentAndReset( mImpl->mCopyPastePopup.actor );
1502 mImpl->mCopyPastePopup.actor = TextSelectionPopup::New( mImpl->mEnabledPopupButtons,
1503 &mImpl->mTextSelectionPopupCallbackInterface );
1504 #ifdef DECORATOR_DEBUG
1505 mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
1507 mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
1508 mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
1510 if( mImpl->mActiveLayer )
1512 mImpl->mActiveLayer.Add( mImpl->mCopyPastePopup.actor );
1513 mImpl->mCopyPastePopup.actor.ShowPopup();
1517 TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()
1519 return mImpl->mEnabledPopupButtons;
1524 void Decorator::SetScrollThreshold( float threshold )
1526 mImpl->SetScrollThreshold( threshold );
1529 float Decorator::GetScrollThreshold() const
1531 return mImpl->GetScrollThreshold();
1534 void Decorator::SetScrollSpeed( float speed )
1536 mImpl->SetScrollSpeed( speed );
1539 float Decorator::GetScrollSpeed() const
1541 return mImpl->GetScrollSpeed();
1544 void Decorator::NotifyEndOfScroll()
1546 mImpl->NotifyEndOfScroll();
1549 Decorator::~Decorator()
1554 Decorator::Decorator( ControllerInterface& controller,
1555 TextSelectionPopupCallbackInterface& callbackInterface )
1558 mImpl = new Decorator::Impl( controller, callbackInterface );
1563 } // namespace Toolkit