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>
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/adaptor-framework/timer.h>
25 #include <dali/public-api/actors/image-actor.h>
26 #include <dali/public-api/actors/layer.h>
27 #include <dali/devel-api/actors/mesh-actor.h>
28 #include <dali/public-api/animation/constraint.h>
29 #include <dali/public-api/common/constants.h>
30 #include <dali/public-api/common/stage.h>
31 #include <dali/public-api/events/tap-gesture.h>
32 #include <dali/public-api/events/tap-gesture-detector.h>
33 #include <dali/public-api/events/touch-event.h>
34 #include <dali/public-api/events/pan-gesture.h>
35 #include <dali/public-api/events/pan-gesture-detector.h>
36 #include <dali/devel-api/geometry/mesh.h>
37 #include <dali/devel-api/geometry/mesh-data.h>
38 #include <dali/public-api/images/resource-image.h>
39 #include <dali/public-api/math/rect.h>
40 #include <dali/public-api/math/vector2.h>
41 #include <dali/public-api/math/vector4.h>
42 #include <dali/public-api/object/property-notification.h>
43 #include <dali/public-api/signals/connection-tracker.h>
46 #include <dali-toolkit/public-api/controls/control.h>
47 #include <dali-toolkit/public-api/controls/control-impl.h>
48 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
49 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
50 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
51 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
54 #define DECORATOR_DEBUG
64 #ifdef DECORATOR_DEBUG
65 Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_TEXT_DECORATOR") );
76 const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "insertpoint-icon.png" );
77 const char* DEFAULT_GRAB_HANDLE_IMAGE_PRESSED( DALI_IMAGE_DIR "insertpoint-icon-pressed.png" );
78 const char* DEFAULT_SELECTION_HANDLE_ONE_RELEASED( DALI_IMAGE_DIR "text-input-selection-handle-left.png" );
79 const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" );
80 const char* DEFAULT_SELECTION_HANDLE_TWO_RELEASED( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
81 const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" );
83 const int DEFAULT_POPUP_OFFSET( -100.0f ); // Vertical offset of Popup from cursor or handles position.
85 const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
86 const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
88 const Dali::Vector4 LIGHT_BLUE( (0xb2 / 255.0f), (0xeb / 255.0f), (0xf2 / 255.0f), 0.5f ); // The text highlight color.
90 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
91 const float TO_MILLISECONDS = 1000.f;
92 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
94 const float DISPLAYED_HIGHLIGHT_Z_OFFSET( -0.05f );
96 const unsigned int SCROLL_TICK_INTERVAL = 50u;
98 const float SCROLL_THRESHOLD = 10.f;
99 const float SCROLL_SPEED = 300.f;
100 const float SCROLL_DISTANCE = SCROLL_SPEED * SCROLL_TICK_INTERVAL * TO_SECONDS;
103 * structure to hold coordinates of each quad, which will make up the mesh.
105 struct QuadCoordinates
108 * Default constructor
116 * @param[in] x1 left co-ordinate
117 * @param[in] y1 top co-ordinate
118 * @param[in] x2 right co-ordinate
119 * @param[in] y2 bottom co-ordinate
121 QuadCoordinates(float x1, float y1, float x2, float y2)
127 Dali::Vector2 min; ///< top-left (minimum) position of quad
128 Dali::Vector2 max; ///< bottom-right (maximum) position of quad
131 typedef std::vector<QuadCoordinates> QuadContainer;
134 * @brief Takes a bounding rectangle in the local coordinates of an actor and returns the world coordinates Bounding Box.
135 * @param[in] boundingRectangle local bounding
136 * @param[out] Vector4 World coordinate bounding Box.
138 void LocalToWorldCoordinatesBoundingBox( const Dali::Rect<int>& boundingRectangle, Dali::Vector4& boundingBox )
140 // Convert to world coordinates and store as a Vector4 to be compatible with Property Notifications.
141 Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
143 const float originX = boundingRectangle.x - 0.5f * stageSize.width;
144 const float originY = boundingRectangle.y - 0.5f * stageSize.height;
146 boundingBox = Dali::Vector4( originX,
148 originX + boundingRectangle.width,
149 originY + boundingRectangle.height );
153 } // end of namespace
164 struct Decorator::Impl : public ConnectionTracker
178 : color( Dali::Color::BLACK ),
180 cursorHeight( 0.0f ),
196 grabDisplacementX( 0.f ),
197 grabDisplacementY( 0.f ),
209 float lineHeight; ///< Not the handle height
210 float grabDisplacementX;
211 float grabDisplacementY;
222 offset( DEFAULT_POPUP_OFFSET )
226 TextSelectionPopup actor;
231 Impl( ControllerInterface& controller,
232 TextSelectionPopupCallbackInterface& callbackInterface )
233 : mController( controller ),
234 mEnabledPopupButtons( TextSelectionPopup::NONE ),
235 mTextSelectionPopupCallbackInterface( callbackInterface ),
236 mBoundingBox( Rect<int>() ),
237 mHighlightColor( LIGHT_BLUE ),
238 mHighlightPosition( Vector2::ZERO ),
239 mActiveCursor( ACTIVE_CURSOR_NONE ),
240 mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ),
241 mCursorBlinkDuration( 0.0f ),
242 mHandleScrolling( HANDLE_TYPE_COUNT ),
243 mScrollDirection( SCROLL_NONE ),
244 mScrollThreshold( SCROLL_THRESHOLD ),
245 mScrollSpeed( SCROLL_SPEED ),
246 mScrollDistance( SCROLL_DISTANCE ),
247 mActiveCopyPastePopup( false ),
248 mCursorBlinkStatus( true ),
249 mPrimaryCursorVisible( false ),
250 mSecondaryCursorVisible( false ),
251 mSwapSelectionHandles( false ),
252 mNotifyEndOfScroll( false )
257 * Relayout of the decorations owned by the decorator.
258 * @param[in] size The Size of the UI control the decorator is adding it's decorations to.
260 void Relayout( const Vector2& size )
262 // TODO - Remove this if nothing is active
265 // Show or hide the cursors
269 const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
270 mPrimaryCursorVisible = ( cursor.position.x <= size.width ) && ( cursor.position.x >= 0.f );
271 if( mPrimaryCursorVisible )
273 Vector2 position = cursor.position;
275 mPrimaryCursor.SetPosition( position.x,
277 mPrimaryCursor.SetSize( Size( 1.0f, cursor.cursorHeight ) );
279 mPrimaryCursor.SetVisible( mPrimaryCursorVisible );
281 if( mSecondaryCursor )
283 const CursorImpl& cursor = mCursor[SECONDARY_CURSOR];
284 mSecondaryCursorVisible = ( cursor.position.x <= size.width ) && ( cursor.position.x >= 0.f );
285 if( mSecondaryCursorVisible )
287 mSecondaryCursor.SetPosition( cursor.position.x,
289 mSecondaryCursor.SetSize( Size( 1.0f, cursor.cursorHeight ) );
291 mSecondaryCursor.SetVisible( mSecondaryCursorVisible );
294 // Show or hide the grab handle
295 HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
296 if( grabHandle.active )
298 Vector2 position = grabHandle.position;
300 const bool isVisible = ( position.x <= size.width ) && ( position.x >= 0.f );
308 grabHandle.actor.SetPosition( position.x,
309 position.y + grabHandle.lineHeight );
311 grabHandle.actor.SetVisible( isVisible );
313 else if( grabHandle.actor )
315 UnparentAndReset( grabHandle.actor );
318 // Show or hide the selection handles/highlight
319 HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
320 HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
321 if( primary.active || secondary.active )
323 Vector2 primaryPosition = primary.position;
324 Vector2 secondaryPosition = secondary.position;
326 const bool isPrimaryVisible = ( primaryPosition.x <= size.width ) && ( primaryPosition.x >= 0.f );
327 const bool isSecondaryVisible = ( secondaryPosition.x <= size.width ) && ( secondaryPosition.x >= 0.f );
329 if( isPrimaryVisible || isSecondaryVisible )
333 CreateSelectionHandles();
335 if( isPrimaryVisible )
337 primary.actor.SetPosition( primaryPosition.x,
338 primaryPosition.y + primary.lineHeight );
341 if( isSecondaryVisible )
343 secondary.actor.SetPosition( secondaryPosition.x,
344 secondaryPosition.y + secondary.lineHeight );
347 primary.actor.SetVisible( isPrimaryVisible );
348 secondary.actor.SetVisible( isSecondaryVisible );
355 UnparentAndReset( primary.actor );
356 UnparentAndReset( secondary.actor );
357 UnparentAndReset( mHighlightMeshActor );
360 if ( mActiveCopyPastePopup )
362 // todo Swap UnparentAndReset for DeterminePositionPopup() if mCopyPastePopup.actor valid Once the issue with the labels disappearing is fixed.
363 UnparentAndReset( mCopyPastePopup.actor );
364 if ( !mCopyPastePopup.actor )
366 mCopyPastePopup.actor = TextSelectionPopup::New( mEnabledPopupButtons, &mTextSelectionPopupCallbackInterface );
367 #ifdef DECORATOR_DEBUG
368 mCopyPastePopup.actor.SetName("mCopyPastePopup");
370 mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
371 mCopyPastePopup.actor.OnRelayoutSignal().Connect( this, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
372 mActiveLayer.Add ( mCopyPastePopup.actor );
377 if ( mCopyPastePopup.actor )
379 UnparentAndReset( mCopyPastePopup.actor );
384 void UpdatePositions( const Vector2& scrollOffset )
386 mCursor[PRIMARY_CURSOR].position += scrollOffset;
387 mCursor[SECONDARY_CURSOR].position += scrollOffset;
388 mHandle[ GRAB_HANDLE ].position += scrollOffset;
389 mHandle[ LEFT_SELECTION_HANDLE ].position += scrollOffset;
390 mHandle[ RIGHT_SELECTION_HANDLE ].position += scrollOffset;
391 mHighlightPosition += scrollOffset;
394 void DeterminePositionPopup()
396 if ( !mActiveCopyPastePopup )
401 if ( mHandle[LEFT_SELECTION_HANDLE].active || mHandle[RIGHT_SELECTION_HANDLE].active )
403 float minHandleXPosition = std::min ( mHandle[LEFT_SELECTION_HANDLE].position.x, mHandle[RIGHT_SELECTION_HANDLE].position.x );
404 float maxHandleXPosition = std::max ( mHandle[LEFT_SELECTION_HANDLE].position.x, mHandle[RIGHT_SELECTION_HANDLE].position.x );
406 float minHandleYPosition = std::min ( mHandle[LEFT_SELECTION_HANDLE].position.y, mHandle[RIGHT_SELECTION_HANDLE].position.y );
408 mCopyPastePopup.position.x = minHandleXPosition + ( ( maxHandleXPosition - minHandleXPosition ) *0.5f );
409 mCopyPastePopup.position.y = minHandleYPosition + mCopyPastePopup.offset;
413 mCopyPastePopup.position = Vector3( mCursor[PRIMARY_CURSOR].position.x, mCursor[PRIMARY_CURSOR].position.y -100.0f , 0.0f ); //todo 100 to be an offset Property
416 Vector3 popupSize = Vector3( mCopyPastePopup.actor.GetRelayoutSize( Dimension::WIDTH ), mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT ), 0.0f );
418 GetConstrainedPopupPosition( mCopyPastePopup.position, popupSize, AnchorPoint::CENTER, mActiveLayer, mBoundingBox );
420 SetUpPopupPositionNotifications();
422 mCopyPastePopup.actor.SetPosition( mCopyPastePopup.position );
425 void PopupRelayoutComplete( Actor actor )
427 // Size negotiation for CopyPastePopup complete so can get the size and constrain position within bounding box.
428 mCopyPastePopup.actor.OnRelayoutSignal().Disconnect( this, &Decorator::Impl::PopupRelayoutComplete );
430 DeterminePositionPopup();
433 void CreateCursor( ImageActor& cursor, const Vector4& color )
435 cursor = CreateSolidColorActor( color );
436 cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one.
437 cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
440 // Add or Remove cursor(s) from parent
443 if( mActiveCursor == ACTIVE_CURSOR_NONE )
445 UnparentAndReset( mPrimaryCursor );
446 UnparentAndReset( mSecondaryCursor );
450 /* Create Primary and or Secondary Cursor(s) if active and add to parent */
451 if ( mActiveCursor == ACTIVE_CURSOR_PRIMARY ||
452 mActiveCursor == ACTIVE_CURSOR_BOTH )
454 if ( !mPrimaryCursor )
456 CreateCursor( mPrimaryCursor, mCursor[PRIMARY_CURSOR].color );
457 #ifdef DECORATOR_DEBUG
458 mPrimaryCursor.SetName( "PrimaryCursorActor" );
460 mActiveLayer.Add( mPrimaryCursor );
464 if ( mActiveCursor == ACTIVE_CURSOR_BOTH )
466 if ( !mSecondaryCursor )
468 CreateCursor( mSecondaryCursor, mCursor[SECONDARY_CURSOR].color );
469 #ifdef DECORATOR_DEBUG
470 mSecondaryCursor.SetName( "SecondaryCursorActor" );
472 mActiveLayer.Add( mSecondaryCursor );
477 UnparentAndReset( mSecondaryCursor );
482 bool OnCursorBlinkTimerTick()
485 if ( mPrimaryCursor )
487 mPrimaryCursor.SetVisible( mPrimaryCursorVisible && mCursorBlinkStatus );
489 if ( mSecondaryCursor )
491 mSecondaryCursor.SetVisible( mSecondaryCursorVisible && mCursorBlinkStatus );
494 mCursorBlinkStatus = !mCursorBlinkStatus;
499 void SetupTouchEvents()
503 mTapDetector = TapGestureDetector::New();
504 mTapDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnTap );
507 if ( !mPanGestureDetector )
509 mPanGestureDetector = PanGestureDetector::New();
510 mPanGestureDetector.DetectedSignal().Connect( this, &Decorator::Impl::OnPan );
514 void CreateActiveLayer()
518 mActiveLayer = Layer::New();
519 #ifdef DECORATOR_DEBUG
520 mActiveLayer.SetName ( "ActiveLayerActor" );
523 mActiveLayer.SetParentOrigin( ParentOrigin::CENTER );
524 mActiveLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
525 mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
527 // Add the active layer telling the controller it doesn't need clipping.
528 mController.AddDecoration( mActiveLayer, false );
531 mActiveLayer.RaiseToTop();
534 void CreateGrabHandle()
536 HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
537 if( !grabHandle.actor )
539 if( !mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] )
541 mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_RELEASED );
543 if( !mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] )
545 mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_PRESSED );
548 grabHandle.actor = ImageActor::New( mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] );
549 grabHandle.actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
550 grabHandle.actor.SetDrawMode( DrawMode::OVERLAY );
551 // Area that Grab handle responds to, larger than actual handle so easier to move
552 #ifdef DECORATOR_DEBUG
553 grabHandle.actor.SetName( "GrabHandleActor" );
554 if ( Dali::Internal::gLogFilter->IsEnabledFor( Debug::Verbose ) )
556 grabHandle.grabArea = Toolkit::CreateSolidColorActor( Vector4(0.0f, 0.0f, 0.0f, 0.0f), true, Color::RED, 1 );
557 grabHandle.grabArea.SetName( "GrabArea" );
561 grabHandle.grabArea = Actor::New();
562 grabHandle.grabArea.SetName( "GrabArea" );
565 grabHandle.grabArea = Actor::New();
568 grabHandle.grabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
569 grabHandle.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
570 grabHandle.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
571 grabHandle.grabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
572 grabHandle.actor.Add( grabHandle.grabArea );
574 grabHandle.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched );
575 mTapDetector.Attach( grabHandle.grabArea );
576 mPanGestureDetector.Attach( grabHandle.grabArea );
578 mActiveLayer.Add( grabHandle.actor );
582 void CreateSelectionHandles()
584 HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
587 if( !mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
589 mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_RELEASED );
591 if( !mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] )
593 mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_PRESSED );
596 primary.actor = ImageActor::New( mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
597 #ifdef DECORATOR_DEBUG
598 primary.actor.SetName("SelectionHandleOne");
600 primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
601 primary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
602 primary.flipped = false;
604 primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
605 #ifdef DECORATOR_DEBUG
606 primary.grabArea.SetName("SelectionHandleOneGrabArea");
608 primary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
609 primary.grabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
610 primary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
611 primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
613 mTapDetector.Attach( primary.grabArea );
614 mPanGestureDetector.Attach( primary.grabArea );
615 primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
617 primary.actor.Add( primary.grabArea );
618 mActiveLayer.Add( primary.actor );
621 HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
622 if( !secondary.actor )
624 if( !mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
626 mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_RELEASED );
628 if( !mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] )
630 mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_PRESSED );
633 secondary.actor = ImageActor::New( mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
634 #ifdef DECORATOR_DEBUG
635 secondary.actor.SetName("SelectionHandleTwo");
637 secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text.
638 secondary.actor.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
639 secondary.flipped = false;
641 secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
642 #ifdef DECORATOR_DEBUG
643 secondary.grabArea.SetName("SelectionHandleTwoGrabArea");
645 secondary.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
646 secondary.grabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
647 secondary.grabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
648 secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
650 mTapDetector.Attach( secondary.grabArea );
651 mPanGestureDetector.Attach( secondary.grabArea );
652 secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
654 secondary.actor.Add( secondary.grabArea );
655 mActiveLayer.Add( secondary.actor );
659 void CreateHighlight()
661 if ( !mHighlightMeshActor )
663 mHighlightMaterial = Material::New( "HighlightMaterial" );
664 mHighlightMaterial.SetDiffuseColor( mHighlightColor );
666 mHighlightMeshData.SetMaterial( mHighlightMaterial );
667 mHighlightMeshData.SetHasNormals( true );
669 mHighlightMesh = Mesh::New( mHighlightMeshData );
671 mHighlightMeshActor = MeshActor::New( mHighlightMesh );
672 #ifdef DECORATOR_DEBUG
673 mHighlightMeshActor.SetName( "HighlightMeshActor" );
675 mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
677 // Add the highlight box telling the controller it needs clipping.
678 mController.AddDecoration( mHighlightMeshActor, true );
681 mHighlightMeshActor.SetPosition( mHighlightPosition.x, mHighlightPosition.y, DISPLAYED_HIGHLIGHT_Z_OFFSET );
684 void UpdateHighlight()
686 // Construct a Mesh with a texture to be used as the highlight 'box' for selected text
688 // Example scenarios where mesh is made from 3, 1, 2, 2 ,3 or 3 quads.
690 // [ TOP ] [ TOP ] [TOP ] [ TOP ] [ TOP ] [ TOP ]
691 // [ MIDDLE ] [BOTTOM] [BOTTOM] [ MIDDLE ] [ MIDDLE ]
692 // [ BOTTOM] [ MIDDLE ] [ MIDDLE ]
693 // [BOTTOM] [ MIDDLE ]
696 // Each quad is created as 2 triangles.
697 // Middle is just 1 quad regardless of its size.
711 if ( mHighlightMesh && mHighlightMaterial && !mHighlightQuadList.empty() )
713 MeshData::VertexContainer vertices;
714 Dali::MeshData::FaceIndices faceIndices;
716 std::vector<QuadCoordinates>::iterator iter = mHighlightQuadList.begin();
717 std::vector<QuadCoordinates>::iterator endIter = mHighlightQuadList.end();
719 // vertex position defaults to (0 0 0)
720 MeshData::Vertex vertex;
721 // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor.
724 for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
726 // Add each quad geometry (a sub-selection) to the mesh data.
736 QuadCoordinates& quad = *iter;
738 vertex.x = quad.min.x;
739 vertex.y = quad.min.y;
740 vertices.push_back( vertex );
743 vertex.x = quad.max.x;
744 vertex.y = quad.min.y;
745 vertices.push_back( vertex );
748 vertex.x = quad.min.x;
749 vertex.y = quad.max.y;
750 vertices.push_back( vertex );
752 // bottom-right (v+3)
753 vertex.x = quad.max.x;
754 vertex.y = quad.max.y;
755 vertices.push_back( vertex );
757 // triangle A (3, 1, 0)
758 faceIndices.push_back( v + 3 );
759 faceIndices.push_back( v + 1 );
760 faceIndices.push_back( v );
762 // triangle B (0, 2, 3)
763 faceIndices.push_back( v );
764 faceIndices.push_back( v + 2 );
765 faceIndices.push_back( v + 3 );
767 mHighlightMeshData.SetFaceIndices( faceIndices );
770 BoneContainer bones(0); // passed empty as bones not required
771 mHighlightMeshData.SetData( vertices, faceIndices, bones, mHighlightMaterial );
772 mHighlightMesh.UpdateMeshData( mHighlightMeshData );
776 void OnTap( Actor actor, const TapGesture& tap )
778 if( actor == mHandle[GRAB_HANDLE].actor )
784 void DoPan( HandleImpl& handle, HandleType type, const PanGesture& gesture )
786 if( Gesture::Started == gesture.state )
788 handle.grabDisplacementX = handle.grabDisplacementY = 0;
791 handle.grabDisplacementX += gesture.displacement.x;
792 handle.grabDisplacementY += gesture.displacement.y;
794 const float x = handle.position.x + handle.grabDisplacementX;
795 const float y = handle.position.y + handle.lineHeight*0.5f + handle.grabDisplacementY;
797 if( Gesture::Started == gesture.state ||
798 Gesture::Continuing == gesture.state )
801 mController.GetTargetSize( targetSize );
803 if( x < mScrollThreshold )
805 mScrollDirection = SCROLL_RIGHT;
806 mHandleScrolling = type;
809 else if( x > targetSize.width - mScrollThreshold )
811 mScrollDirection = SCROLL_LEFT;
812 mHandleScrolling = type;
817 mHandleScrolling = HANDLE_TYPE_COUNT;
819 mController.DecorationEvent( type, HANDLE_PRESSED, x, y );
822 else if( Gesture::Finished == gesture.state ||
823 Gesture::Cancelled == gesture.state )
826 ( mScrollTimer.IsRunning() || mNotifyEndOfScroll ) )
828 mNotifyEndOfScroll = false;
829 mHandleScrolling = HANDLE_TYPE_COUNT;
831 mController.DecorationEvent( type, HANDLE_STOP_SCROLLING, x, y );
835 mController.DecorationEvent( type, HANDLE_RELEASED, x, y );
838 if( GRAB_HANDLE == type )
840 handle.actor.SetImage( mHandleImages[type][HANDLE_IMAGE_RELEASED] );
844 HandleType selectionHandleType = type;
846 if( mSwapSelectionHandles != handle.flipped )
848 selectionHandleType = ( LEFT_SELECTION_HANDLE == type ) ? RIGHT_SELECTION_HANDLE : LEFT_SELECTION_HANDLE;
851 handle.actor.SetImage( mHandleImages[selectionHandleType][HANDLE_IMAGE_RELEASED] );
853 handle.pressed = false;
857 void OnPan( Actor actor, const PanGesture& gesture )
859 HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
860 HandleImpl& primarySelectionHandle = mHandle[LEFT_SELECTION_HANDLE];
861 HandleImpl& secondarySelectionHandle = mHandle[RIGHT_SELECTION_HANDLE];
863 if( actor == grabHandle.grabArea )
865 DoPan( grabHandle, GRAB_HANDLE, gesture );
867 else if( actor == primarySelectionHandle.grabArea )
869 DoPan( primarySelectionHandle, LEFT_SELECTION_HANDLE, gesture );
871 else if( actor == secondarySelectionHandle.grabArea )
873 DoPan( secondarySelectionHandle, RIGHT_SELECTION_HANDLE, gesture );
877 bool OnGrabHandleTouched( Actor actor, const TouchEvent& event )
879 // Switch between pressed/release grab-handle images
880 if( event.GetPointCount() > 0 &&
881 mHandle[GRAB_HANDLE].actor )
883 const TouchPoint& point = event.GetPoint(0);
885 if( TouchPoint::Down == point.state )
887 mHandle[GRAB_HANDLE].pressed = true;
888 Image imagePressed = mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED];
891 mHandle[GRAB_HANDLE].actor.SetImage( imagePressed );
894 else if( TouchPoint::Up == point.state )
896 mHandle[GRAB_HANDLE].pressed = false;
897 Image imageReleased = mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED];
900 mHandle[GRAB_HANDLE].actor.SetImage( imageReleased );
905 // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
909 bool OnHandleOneTouched( Actor actor, const TouchEvent& event )
911 // Switch between pressed/release selection handle images
912 if( event.GetPointCount() > 0 &&
913 mHandle[LEFT_SELECTION_HANDLE].actor )
915 const TouchPoint& point = event.GetPoint(0);
917 const bool flip = mSwapSelectionHandles != mHandle[LEFT_SELECTION_HANDLE].flipped;
918 if( TouchPoint::Down == point.state )
920 mHandle[LEFT_SELECTION_HANDLE].pressed = true;
921 Image imagePressed = mHandleImages[flip ? RIGHT_SELECTION_HANDLE : LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED];
924 mHandle[LEFT_SELECTION_HANDLE].actor.SetImage( imagePressed );
927 else if( TouchPoint::Up == point.state )
929 mHandle[LEFT_SELECTION_HANDLE].pressed = false;
930 Image imageReleased = mHandleImages[flip ? RIGHT_SELECTION_HANDLE : LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED];
933 mHandle[LEFT_SELECTION_HANDLE].actor.SetImage( imageReleased );
938 // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
942 bool OnHandleTwoTouched( Actor actor, const TouchEvent& event )
944 // Switch between pressed/release selection handle images
945 if( event.GetPointCount() > 0 &&
946 mHandle[RIGHT_SELECTION_HANDLE].actor )
948 const TouchPoint& point = event.GetPoint(0);
950 const bool flip = mSwapSelectionHandles != mHandle[RIGHT_SELECTION_HANDLE].flipped;
951 if( TouchPoint::Down == point.state )
953 Image imagePressed = mHandleImages[flip ? LEFT_SELECTION_HANDLE : RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED];
954 mHandle[RIGHT_SELECTION_HANDLE].pressed = true;
957 mHandle[RIGHT_SELECTION_HANDLE].actor.SetImage( imagePressed );
960 else if( TouchPoint::Up == point.state )
962 Image imageReleased = mHandleImages[flip ? LEFT_SELECTION_HANDLE : RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED];
963 mHandle[RIGHT_SELECTION_HANDLE].pressed = false;
966 mHandle[RIGHT_SELECTION_HANDLE].actor.SetImage( imageReleased );
971 // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area
977 float AlternatePopUpPositionRelativeToCursor()
979 float alternativePosition=0.0f;;
981 if ( mPrimaryCursor ) // Secondary cursor not used for paste
983 Cursor cursor = PRIMARY_CURSOR;
984 alternativePosition = mCursor[cursor].position.y;
987 const float popupHeight = 120.0f; // todo Set as a MaxSize Property in Control or retrieve from CopyPastePopup class.
989 if( mHandle[GRAB_HANDLE].active )
991 // If grab handle enabled then position pop-up below the grab handle.
992 const Vector2 grabHandleSize( 59.0f, 56.0f ); // todo
993 const float BOTTOM_HANDLE_BOTTOM_OFFSET = 1.5; //todo Should be a property
994 alternativePosition += grabHandleSize.height + popupHeight + BOTTOM_HANDLE_BOTTOM_OFFSET ;
998 alternativePosition += popupHeight;
1001 return alternativePosition;
1004 void PopUpLeavesVerticalBoundary( PropertyNotification& source )
1006 float alternativeYPosition=0.0f;
1007 // todo use AlternatePopUpPositionRelativeToSelectionHandles() if text is highlighted
1008 // if can't be positioned above, then position below row.
1009 alternativeYPosition = AlternatePopUpPositionRelativeToCursor();
1011 mCopyPastePopup.actor.SetY( alternativeYPosition );
1015 void SetUpPopupPositionNotifications( )
1017 // Note Property notifications ignore any set anchor point so conditions must allow for this. Default is Top Left.
1019 // Exceeding vertical boundary
1021 Vector4 worldCoordinatesBoundingBox;
1022 LocalToWorldCoordinatesBoundingBox( mBoundingBox, worldCoordinatesBoundingBox );
1024 float popupHeight = mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT);
1026 PropertyNotification verticalExceedNotification = mCopyPastePopup.actor.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
1027 OutsideCondition( worldCoordinatesBoundingBox.y + popupHeight * 0.5f,
1028 worldCoordinatesBoundingBox.w - popupHeight * 0.5f ) );
1030 verticalExceedNotification.NotifySignal().Connect( this, &Decorator::Impl::PopUpLeavesVerticalBoundary );
1033 void GetConstrainedPopupPosition( Vector3& requiredPopupPosition, Vector3& popupSize, Vector3 anchorPoint, Actor& parent, Rect<int>& boundingBox )
1035 DALI_ASSERT_DEBUG ( "Popup parent not on stage" && parent.OnStage() )
1037 // Parent must already by added to Stage for these Get calls to work
1038 Vector3 parentAnchorPoint = parent.GetCurrentAnchorPoint();
1039 Vector3 parentWorldPositionLeftAnchor = parent.GetCurrentWorldPosition() - parent.GetCurrentSize()*parentAnchorPoint;
1040 Vector3 popupWorldPosition = parentWorldPositionLeftAnchor + requiredPopupPosition; // Parent World position plus popup local position gives World Position
1041 Vector3 popupDistanceFromAnchorPoint = popupSize*anchorPoint;
1043 // Bounding rectangle is supplied as screen coordinates, bounding will be done in world coordinates.
1044 Vector4 boundingRectangleWorld;
1045 LocalToWorldCoordinatesBoundingBox( boundingBox, boundingRectangleWorld );
1047 // Calculate distance to move popup (in local space) so fits within the boundary
1048 float xOffSetToKeepWithinBounds = 0.0f;
1049 if( popupWorldPosition.x - popupDistanceFromAnchorPoint.x < boundingRectangleWorld.x )
1051 xOffSetToKeepWithinBounds = boundingRectangleWorld.x - ( popupWorldPosition.x - popupDistanceFromAnchorPoint.x );
1053 else if ( popupWorldPosition.x + popupDistanceFromAnchorPoint.x > boundingRectangleWorld.z )
1055 xOffSetToKeepWithinBounds = boundingRectangleWorld.z - ( popupWorldPosition.x + popupDistanceFromAnchorPoint.x );
1058 // Ensure initial display of Popup is in alternative position if can not fit above. As Property notification will be a frame behind.
1059 if ( popupWorldPosition.y - popupDistanceFromAnchorPoint.y < boundingRectangleWorld.y )
1061 requiredPopupPosition.y = AlternatePopUpPositionRelativeToCursor();
1064 requiredPopupPosition.x = requiredPopupPosition.x + xOffSetToKeepWithinBounds;
1066 // Prevent pixel mis-alignment by rounding down.
1067 requiredPopupPosition.x = static_cast<int>( requiredPopupPosition.x );
1068 requiredPopupPosition.y = static_cast<int>( requiredPopupPosition.y );
1072 void FlipSelectionHandleImages()
1076 CreateSelectionHandles();
1078 HandleImpl& leftHandle = mHandle[LEFT_SELECTION_HANDLE];
1079 HandleImpl& rightHandle = mHandle[RIGHT_SELECTION_HANDLE];
1081 const HandleImageType leftImageType = leftHandle.pressed ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
1082 const HandleImageType rightImageType = rightHandle.pressed ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED;
1083 const bool leftFlipped = mSwapSelectionHandles != leftHandle.flipped;
1084 const bool rightFlipped = mSwapSelectionHandles != rightHandle.flipped;
1086 leftHandle.actor.SetImage( leftFlipped ? mHandleImages[RIGHT_SELECTION_HANDLE][leftImageType] : mHandleImages[LEFT_SELECTION_HANDLE][leftImageType] );
1088 leftHandle.actor.SetAnchorPoint( leftFlipped ? AnchorPoint::TOP_LEFT : AnchorPoint::TOP_RIGHT );
1090 rightHandle.actor.SetImage( rightFlipped ? mHandleImages[LEFT_SELECTION_HANDLE][rightImageType] : mHandleImages[RIGHT_SELECTION_HANDLE][rightImageType] );
1092 rightHandle.actor.SetAnchorPoint( rightFlipped ? AnchorPoint::TOP_RIGHT : AnchorPoint::TOP_LEFT );
1095 void SetScrollThreshold( float threshold )
1097 mScrollThreshold = threshold;
1100 float GetScrollThreshold() const
1102 return mScrollThreshold;
1105 void SetScrollSpeed( float speed )
1107 mScrollSpeed = speed;
1108 mScrollDistance = speed * SCROLL_TICK_INTERVAL * TO_SECONDS;
1111 float GetScrollSpeed() const
1113 return mScrollSpeed;
1116 void NotifyEndOfScroll()
1122 mNotifyEndOfScroll = true;
1127 * Creates and starts a timer to scroll the text when handles are close to the edges of the text.
1129 * It only starts the timer if it's already created.
1131 void StartScrollTimer()
1135 mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL );
1136 mScrollTimer.TickSignal().Connect( this, &Decorator::Impl::OnScrollTimerTick );
1139 if( !mScrollTimer.IsRunning() )
1141 mScrollTimer.Start();
1146 * Stops the timer used to scroll the text.
1148 void StopScrollTimer()
1152 mScrollTimer.Stop();
1157 * Callback called by the timer used to scroll the text.
1159 * It calculates and sets a new scroll position.
1161 bool OnScrollTimerTick()
1163 if( HANDLE_TYPE_COUNT != mHandleScrolling )
1165 mController.DecorationEvent( mHandleScrolling,
1167 mScrollDirection == SCROLL_RIGHT ? mScrollDistance : -mScrollDistance,
1174 ControllerInterface& mController;
1176 TapGestureDetector mTapDetector;
1177 PanGestureDetector mPanGestureDetector;
1178 Timer mCursorBlinkTimer; ///< Timer to signal cursor to blink
1179 Timer mScrollTimer; ///< Timer used to scroll the text when the grab handle is moved close to the edges.
1181 Layer mActiveLayer; ///< Layer for active handles and alike that ensures they are above all else.
1182 ImageActor mPrimaryCursor;
1183 ImageActor mSecondaryCursor;
1184 MeshActor mHighlightMeshActor; ///< Mesh Actor to display highlight
1186 PopupImpl mCopyPastePopup;
1187 TextSelectionPopup::Buttons mEnabledPopupButtons; /// Bit mask of currently enabled Popup buttons
1188 TextSelectionPopupCallbackInterface& mTextSelectionPopupCallbackInterface;
1190 Image mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
1192 Mesh mHighlightMesh; ///< Mesh for highlight
1193 MeshData mHighlightMeshData; ///< Mesh Data for highlight
1194 Material mHighlightMaterial; ///< Material used for highlight
1196 CursorImpl mCursor[CURSOR_COUNT];
1197 HandleImpl mHandle[HANDLE_TYPE_COUNT];
1198 QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
1200 Rect<int> mBoundingBox;
1201 Vector4 mHighlightColor; ///< Color of the highlight
1202 Vector2 mHighlightPosition; ///< The position of the highlight actor.
1204 unsigned int mActiveCursor;
1205 unsigned int mCursorBlinkInterval;
1206 float mCursorBlinkDuration;
1207 HandleType mHandleScrolling; ///< The handle which is scrolling.
1208 ScrollDirection mScrollDirection; ///< The direction of the scroll.
1209 float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
1210 float mScrollSpeed; ///< The scroll speed in pixels per second.
1211 float mScrollDistance; ///< Distance the text scrolls during a scroll interval.
1213 bool mActiveCopyPastePopup : 1;
1214 bool mCursorBlinkStatus : 1; ///< Flag to switch between blink on and blink off.
1215 bool mPrimaryCursorVisible : 1; ///< Whether the primary cursor is visible.
1216 bool mSecondaryCursorVisible : 1; ///< Whether the secondary cursor is visible.
1217 bool mSwapSelectionHandles : 1; ///< Whether to swap the selection handle images.
1218 bool mNotifyEndOfScroll : 1; ///< Whether to notify the end of the scroll.
1221 DecoratorPtr Decorator::New( ControllerInterface& controller,
1222 TextSelectionPopupCallbackInterface& callbackInterface )
1224 return DecoratorPtr( new Decorator( controller,
1225 callbackInterface ) );
1228 void Decorator::SetBoundingBox( const Rect<int>& boundingBox )
1230 mImpl->mBoundingBox = boundingBox;
1233 const Rect<int>& Decorator::GetBoundingBox() const
1235 return mImpl->mBoundingBox;
1238 void Decorator::Relayout( const Vector2& size )
1240 mImpl->Relayout( size );
1243 void Decorator::UpdatePositions( const Vector2& scrollOffset )
1245 mImpl->UpdatePositions( scrollOffset );
1250 void Decorator::SetActiveCursor( ActiveCursor activeCursor )
1252 mImpl->mActiveCursor = activeCursor;
1255 unsigned int Decorator::GetActiveCursor() const
1257 return mImpl->mActiveCursor;
1260 void Decorator::SetPosition( Cursor cursor, float x, float y, float cursorHeight, float lineHeight )
1262 mImpl->mCursor[cursor].position.x = x;
1263 mImpl->mCursor[cursor].position.y = y;
1264 mImpl->mCursor[cursor].cursorHeight = cursorHeight;
1265 mImpl->mCursor[cursor].lineHeight = lineHeight;
1268 void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& cursorHeight, float& lineHeight ) const
1270 x = mImpl->mCursor[cursor].position.x;
1271 y = mImpl->mCursor[cursor].position.y;
1272 cursorHeight = mImpl->mCursor[cursor].cursorHeight;
1273 lineHeight = mImpl->mCursor[cursor].lineHeight;
1276 const Vector2& Decorator::GetPosition( Cursor cursor ) const
1278 return mImpl->mCursor[cursor].position;
1281 void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
1283 mImpl->mCursor[cursor].color = color;
1286 const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
1288 return mImpl->mCursor[cursor].color;
1291 void Decorator::StartCursorBlink()
1293 if ( !mImpl->mCursorBlinkTimer )
1295 mImpl->mCursorBlinkTimer = Timer::New( mImpl->mCursorBlinkInterval );
1296 mImpl->mCursorBlinkTimer.TickSignal().Connect( mImpl, &Decorator::Impl::OnCursorBlinkTimerTick );
1299 if ( !mImpl->mCursorBlinkTimer.IsRunning() )
1301 mImpl->mCursorBlinkTimer.Start();
1305 void Decorator::StopCursorBlink()
1307 if ( mImpl->mCursorBlinkTimer )
1309 mImpl->mCursorBlinkTimer.Stop();
1313 void Decorator::SetCursorBlinkInterval( float seconds )
1315 mImpl->mCursorBlinkInterval = static_cast<unsigned int>( seconds * TO_MILLISECONDS ); // Convert to milliseconds
1318 float Decorator::GetCursorBlinkInterval() const
1320 return static_cast<float>( mImpl->mCursorBlinkInterval ) * TO_SECONDS;
1323 void Decorator::SetCursorBlinkDuration( float seconds )
1325 mImpl->mCursorBlinkDuration = seconds;
1328 float Decorator::GetCursorBlinkDuration() const
1330 return mImpl->mCursorBlinkDuration;
1335 void Decorator::SetHandleActive( HandleType handleType, bool active )
1337 mImpl->mHandle[handleType].active = active;
1340 bool Decorator::IsHandleActive( HandleType handleType ) const
1342 return mImpl->mHandle[handleType].active ;
1345 void Decorator::SetHandleImage( HandleType handleType, HandleImageType handleImageType, Dali::Image image )
1347 mImpl->mHandleImages[handleType][handleImageType] = image;
1350 Dali::Image Decorator::GetHandleImage( HandleType handleType, HandleImageType handleImageType ) const
1352 return mImpl->mHandleImages[handleType][handleImageType];
1355 void Decorator::SetPosition( HandleType handleType, float x, float y, float height )
1357 // Adjust grab handle displacement
1358 Impl::HandleImpl& handle = mImpl->mHandle[handleType];
1360 handle.grabDisplacementX -= x - handle.position.x;
1361 handle.grabDisplacementY -= y - handle.position.y;
1363 handle.position.x = x;
1364 handle.position.y = y;
1365 handle.lineHeight = height;
1368 void Decorator::GetPosition( HandleType handleType, float& x, float& y, float& height ) const
1370 Impl::HandleImpl& handle = mImpl->mHandle[handleType];
1372 x = handle.position.x;
1373 y = handle.position.y;
1374 height = handle.lineHeight;
1377 const Vector2& Decorator::GetPosition( HandleType handleType ) const
1379 return mImpl->mHandle[handleType].position;
1382 void Decorator::SwapSelectionHandlesEnabled( bool enable )
1384 mImpl->mSwapSelectionHandles = enable;
1386 mImpl->FlipSelectionHandleImages();
1389 void Decorator::AddHighlight( float x1, float y1, float x2, float y2 )
1391 mImpl->mHighlightQuadList.push_back( QuadCoordinates(x1, y1, x2, y2) );
1394 void Decorator::ClearHighlights()
1396 mImpl->mHighlightQuadList.clear();
1397 mImpl->mHighlightPosition = Vector2::ZERO;
1400 void Decorator::SetHighlightColor( const Vector4& color )
1402 mImpl->mHighlightColor = color;
1405 const Vector4& Decorator::GetHighlightColor() const
1407 return mImpl->mHighlightColor;
1410 void Decorator::SetPopupActive( bool active )
1412 mImpl->mActiveCopyPastePopup = active;
1415 bool Decorator::IsPopupActive() const
1417 return mImpl->mActiveCopyPastePopup ;
1420 void Decorator::SetEnabledPopupButtons( TextSelectionPopup::Buttons& enabledButtonsBitMask )
1422 mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
1425 TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()
1427 return mImpl->mEnabledPopupButtons;
1432 void Decorator::SetScrollThreshold( float threshold )
1434 mImpl->SetScrollThreshold( threshold );
1437 float Decorator::GetScrollThreshold() const
1439 return mImpl->GetScrollThreshold();
1442 void Decorator::SetScrollSpeed( float speed )
1444 mImpl->SetScrollSpeed( speed );
1447 float Decorator::GetScrollSpeed() const
1449 return mImpl->GetScrollSpeed();
1452 void Decorator::NotifyEndOfScroll()
1454 mImpl->NotifyEndOfScroll();
1457 Decorator::~Decorator()
1462 Decorator::Decorator( ControllerInterface& controller,
1463 TextSelectionPopupCallbackInterface& callbackInterface )
1466 mImpl = new Decorator::Impl( controller, callbackInterface );
1471 } // namespace Toolkit