projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adding Selection Markers to TextField
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
text
/
decorator
/
text-decorator.cpp
diff --git
a/dali-toolkit/internal/text/decorator/text-decorator.cpp
b/dali-toolkit/internal/text/decorator/text-decorator.cpp
index
a22cc90
..
5c45bf3
100644
(file)
--- a/
dali-toolkit/internal/text/decorator/text-decorator.cpp
+++ b/
dali-toolkit/internal/text/decorator/text-decorator.cpp
@@
-20,39
+20,21
@@
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#include <dali/public-api/actors/actor.h>
+
#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/public-api/adaptor-framework/timer.h>
-#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/common/constants.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/common/stage.h>
-#include <dali/public-api/events/tap-gesture.h>
-#include <dali/public-api/events/tap-gesture-detector.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/events/pan-gesture.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/events/pan-gesture.h>
-#include <dali/public-api/events/pan-gesture-detector.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/images/resource-image.h>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/math/vector4.h>
#include <dali/public-api/object/property-notification.h>
#include <dali/public-api/object/property-notification.h>
-#include <dali/public-api/signals/connection-tracker.h>
-#include <dali/devel-api/object/property-buffer.h>
#include <dali/devel-api/rendering/geometry.h>
#include <dali/devel-api/rendering/geometry.h>
-#include <dali/devel-api/rendering/material.h>
#include <dali/devel-api/rendering/renderer.h>
#include <dali/devel-api/rendering/renderer.h>
-#include <dali/devel-api/rendering/shader.h>
// INTERNAL INCLUDES
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
-#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/public-api/controls/buttons/push-button.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
-#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
-#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
#ifdef DEBUG_ENABLED
#define DECORATOR_DEBUG
#ifdef DEBUG_ENABLED
#define DECORATOR_DEBUG
@@
-105,8
+87,6
@@
namespace
{
const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "cursor_handler_center.png" );
{
const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "cursor_handler_center.png" );
-const char* DEFAULT_SELECTION_HANDLE_ONE_RELEASED( DALI_IMAGE_DIR "selection_handle_left.png" );
-const char* DEFAULT_SELECTION_HANDLE_TWO_RELEASED( DALI_IMAGE_DIR "selection_handle_right.png" );
const int DEFAULT_POPUP_OFFSET( -100.0f ); // Vertical offset of Popup from cursor or handles position.
const int DEFAULT_POPUP_OFFSET( -100.0f ); // Vertical offset of Popup from cursor or handles position.
@@
-232,6
+212,7
@@
struct Decorator::Impl : public ConnectionTracker
ImageActor actor;
Actor grabArea;
ImageActor actor;
Actor grabArea;
+ ImageActor markerActor;
Vector2 position;
float lineHeight; ///< Not the handle height
Vector2 position;
float lineHeight; ///< Not the handle height
@@
-273,6
+254,7
@@
struct Decorator::Impl : public ConnectionTracker
mScrollThreshold( SCROLL_THRESHOLD ),
mScrollSpeed( SCROLL_SPEED ),
mScrollDistance( SCROLL_DISTANCE ),
mScrollThreshold( SCROLL_THRESHOLD ),
mScrollSpeed( SCROLL_SPEED ),
mScrollDistance( SCROLL_DISTANCE ),
+ mTextDepth( 0u ),
mActiveCopyPastePopup( false ),
mCursorBlinkStatus( true ),
mPrimaryCursorVisible( false ),
mActiveCopyPastePopup( false ),
mCursorBlinkStatus( true ),
mPrimaryCursorVisible( false ),
@@
-296,6
+278,7
@@
struct Decorator::Impl : public ConnectionTracker
// Show or hide the cursors
CreateCursors();
// Show or hide the cursors
CreateCursors();
+
if( mPrimaryCursor )
{
const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
if( mPrimaryCursor )
{
const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
@@
-338,7
+321,7
@@
struct Decorator::Impl : public ConnectionTracker
CreateGrabHandle();
grabHandle.actor.SetPosition( position.x,
CreateGrabHandle();
grabHandle.actor.SetPosition( position.x,
- position.y + grabHandle.lineHeight );
+ position.y + grabHandle.lineHeight );
// TODO : Fix for multiline.
}
grabHandle.actor.SetVisible( isVisible );
}
}
grabHandle.actor.SetVisible( isVisible );
}
@@
-367,13
+350,17
@@
struct Decorator::Impl : public ConnectionTracker
if( isPrimaryVisible )
{
primary.actor.SetPosition( primaryPosition.x,
if( isPrimaryVisible )
{
primary.actor.SetPosition( primaryPosition.x,
- primaryPosition.y + primary.lineHeight );
+ primaryPosition.y + primary.lineHeight ); // TODO : Fix for multiline.
+
+ SetSelectionHandleMarkerSize( primary );
}
if( isSecondaryVisible )
{
secondary.actor.SetPosition( secondaryPosition.x,
}
if( isSecondaryVisible )
{
secondary.actor.SetPosition( secondaryPosition.x,
- secondaryPosition.y + secondary.lineHeight );
+ secondaryPosition.y + secondary.lineHeight ); // TODO : Fix for multiline.
+
+ SetSelectionHandleMarkerSize( secondary );
}
}
primary.actor.SetVisible( isPrimaryVisible );
}
}
primary.actor.SetVisible( isPrimaryVisible );
@@
-400,18
+387,13
@@
struct Decorator::Impl : public ConnectionTracker
if( mActiveCopyPastePopup )
{
if( mActiveCopyPastePopup )
{
- if( !mCopyPastePopup.actor.GetParent() )
- {
- mActiveLayer.Add( mCopyPastePopup.actor );
- }
-
- mCopyPastePopup.actor.RaiseAbove( mActiveLayer );
+ ShowPopup();
}
else
{
if( mCopyPastePopup.actor )
{
}
else
{
if( mCopyPastePopup.actor )
{
- mCopyPastePopup.actor.
Unparent
();
+ mCopyPastePopup.actor.
HidePopup
();
}
}
}
}
}
}
@@
-427,6
+409,22
@@
struct Decorator::Impl : public ConnectionTracker
DeterminePositionPopup();
}
DeterminePositionPopup();
}
+ void ShowPopup()
+ {
+ if ( !mCopyPastePopup.actor )
+ {
+ return;
+ }
+
+ if( !mCopyPastePopup.actor.GetParent() )
+ {
+ mActiveLayer.Add( mCopyPastePopup.actor );
+ }
+
+ mCopyPastePopup.actor.RaiseAbove( mActiveLayer );
+ mCopyPastePopup.actor.ShowPopup();
+ }
+
void DeterminePositionPopup()
{
if ( !mActiveCopyPastePopup )
void DeterminePositionPopup()
{
if ( !mActiveCopyPastePopup )
@@
-461,7
+459,6
@@
struct Decorator::Impl : public ConnectionTracker
void PopupRelayoutComplete( Actor actor )
{
// Size negotiation for CopyPastePopup complete so can get the size and constrain position within bounding box.
void PopupRelayoutComplete( Actor actor )
{
// Size negotiation for CopyPastePopup complete so can get the size and constrain position within bounding box.
- mCopyPastePopup.actor.OnRelayoutSignal().Disconnect( this, &Decorator::Impl::PopupRelayoutComplete );
DeterminePositionPopup();
}
DeterminePositionPopup();
}
@@
-585,6
+582,15
@@
struct Decorator::Impl : public ConnectionTracker
mActiveLayer.RaiseToTop();
}
mActiveLayer.RaiseToTop();
}
+ void SetSelectionHandleMarkerSize( HandleImpl& handle )
+ {
+ if ( handle.markerActor )
+ {
+ handle.markerActor.SetResizePolicy ( ResizePolicy::FIXED, Dimension::HEIGHT );
+ handle.markerActor.SetSize( 0, handle.lineHeight );
+ }
+ }
+
void CreateGrabHandle()
{
HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
void CreateGrabHandle()
{
HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
@@
-635,16
+641,32
@@
struct Decorator::Impl : public ConnectionTracker
}
}
}
}
- void Create
SelectionHandles(
)
+ void Create
HandleMarker( HandleImpl& handle, Image& image, HandleType handleType
)
{
{
- HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
- if( !primary.actor )
+ if ( image)
{
{
- if( !mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
+ handle.markerActor = ImageActor::New( image );
+ handle.markerActor.SetColor( mHandleColor );
+ handle.actor.Add( handle.markerActor );
+
+ if ( LEFT_SELECTION_HANDLE == handleType )
{
{
- mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_RELEASED );
+ handle.markerActor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
+ handle.markerActor.SetParentOrigin( ParentOrigin::TOP_RIGHT );
}
}
+ else if ( RIGHT_SELECTION_HANDLE == handleType )
+ {
+ handle.markerActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
+ handle.markerActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ }
+ }
+ }
+ void CreateSelectionHandles()
+ {
+ HandleImpl& primary = mHandle[ LEFT_SELECTION_HANDLE ];
+ if( !primary.actor )
+ {
primary.actor = ImageActor::New( mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
#ifdef DECORATOR_DEBUG
primary.actor.SetName("SelectionHandleOne");
primary.actor = ImageActor::New( mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
#ifdef DECORATOR_DEBUG
primary.actor.SetName("SelectionHandleOne");
@@
-668,6
+690,8
@@
struct Decorator::Impl : public ConnectionTracker
primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
primary.actor.Add( primary.grabArea );
primary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleOneTouched );
primary.actor.Add( primary.grabArea );
+
+ CreateHandleMarker( primary, mHandleImages[LEFT_SELECTION_HANDLE_MARKER][HANDLE_IMAGE_RELEASED], LEFT_SELECTION_HANDLE );
}
if( !primary.actor.GetParent() )
}
if( !primary.actor.GetParent() )
@@
-678,11
+702,6
@@
struct Decorator::Impl : public ConnectionTracker
HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
if( !secondary.actor )
{
HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
if( !secondary.actor )
{
- if( !mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] )
- {
- mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_RELEASED );
- }
-
secondary.actor = ImageActor::New( mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
#ifdef DECORATOR_DEBUG
secondary.actor.SetName("SelectionHandleTwo");
secondary.actor = ImageActor::New( mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] );
#ifdef DECORATOR_DEBUG
secondary.actor.SetName("SelectionHandleTwo");
@@
-706,6
+725,8
@@
struct Decorator::Impl : public ConnectionTracker
secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
secondary.actor.Add( secondary.grabArea );
secondary.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnHandleTwoTouched );
secondary.actor.Add( secondary.grabArea );
+
+ CreateHandleMarker( secondary, mHandleImages[RIGHT_SELECTION_HANDLE_MARKER][HANDLE_IMAGE_RELEASED], RIGHT_SELECTION_HANDLE );
}
if( !secondary.actor.GetParent() )
}
if( !secondary.actor.GetParent() )
@@
-803,24
+824,25
@@
struct Decorator::Impl : public ConnectionTracker
mQuadVertices.SetData( &vertices[ 0 ] );
mQuadIndices.SetData( &indices[ 0 ] );
mQuadVertices.SetData( &vertices[ 0 ] );
mQuadIndices.SetData( &indices[ 0 ] );
- mQuadGeometry = Geometry::New();
- mQuadGeometry.AddVertexBuffer( mQuadVertices );
- mQuadGeometry.SetIndexBuffer( mQuadIndices );
-
- if( mHighlightRenderer )
+ if( !mQuadGeometry )
{
{
- mHighlightRenderer.SetGeometry( mQuadGeometry );
+ mQuadGeometry = Geometry::New();
+ mQuadGeometry.AddVertexBuffer( mQuadVertices );
}
}
- else
+ mQuadGeometry.SetIndexBuffer( mQuadIndices );
+
+ if( !mHighlightRenderer )
{
mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightMaterial );
mHighlightActor.AddRenderer( mHighlightRenderer );
}
{
mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightMaterial );
mHighlightActor.AddRenderer( mHighlightRenderer );
}
-
- mHighlightActor.SetPosition( mHighlightPosition.x,
- mHighlightPosition.y );
}
}
+ mHighlightActor.SetPosition( mHighlightPosition.x,
+ mHighlightPosition.y );
+
+ mHighlightQuadList.clear();
+
mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
}
}
mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
}
}
@@
-1147,6
+1169,15
@@
struct Decorator::Impl : public ConnectionTracker
rightHandle.actor.SetImage( rightFlipped ? mHandleImages[LEFT_SELECTION_HANDLE][rightImageType] : mHandleImages[RIGHT_SELECTION_HANDLE][rightImageType] );
rightHandle.actor.SetAnchorPoint( rightFlipped ? AnchorPoint::TOP_RIGHT : AnchorPoint::TOP_LEFT );
rightHandle.actor.SetImage( rightFlipped ? mHandleImages[LEFT_SELECTION_HANDLE][rightImageType] : mHandleImages[RIGHT_SELECTION_HANDLE][rightImageType] );
rightHandle.actor.SetAnchorPoint( rightFlipped ? AnchorPoint::TOP_RIGHT : AnchorPoint::TOP_LEFT );
+
+ if ( leftHandle.markerActor )
+ {
+ leftHandle.markerActor.SetImage( leftFlipped ? mHandleImages[RIGHT_SELECTION_HANDLE_MARKER][leftImageType] : mHandleImages[LEFT_SELECTION_HANDLE_MARKER][leftImageType] );
+ }
+ if ( rightHandle.markerActor )
+ {
+ rightHandle.markerActor.SetImage( rightFlipped ? mHandleImages[LEFT_SELECTION_HANDLE_MARKER][rightImageType] : mHandleImages[RIGHT_SELECTION_HANDLE_MARKER][rightImageType] );
+ }
}
void SetScrollThreshold( float threshold )
}
void SetScrollThreshold( float threshold )
@@
-1513,19
+1544,17
@@
void Decorator::SetEnabledPopupButtons( TextSelectionPopup::Buttons& enabledButt
{
mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
{
mImpl->mEnabledPopupButtons = enabledButtonsBitMask;
- UnparentAndReset( mImpl->mCopyPastePopup.actor );
- mImpl->mCopyPastePopup.actor = TextSelectionPopup::New( mImpl->mEnabledPopupButtons,
-
&mImpl->mTextSelectionPopupCallbackInterface );
+ if ( !mImpl->mCopyPastePopup.actor )
+ {
+
mImpl->mCopyPastePopup.actor = TextSelectionPopup::New(
&mImpl->mTextSelectionPopupCallbackInterface );
#ifdef DECORATOR_DEBUG
#ifdef DECORATOR_DEBUG
- mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
+
mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
#endif
#endif
- mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
- mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
-
- if( mImpl->mActiveLayer )
- {
- mImpl->mActiveLayer.Add( mImpl->mCopyPastePopup.actor );
+ mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
+ mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
}
}
+
+ mImpl->mCopyPastePopup.actor.EnableButtons( mImpl->mEnabledPopupButtons );
}
TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()
}
TextSelectionPopup::Buttons& Decorator::GetEnabledPopupButtons()