// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "rendering-backend", INTEGER, RENDERING_BACKEND )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder-text", STRING, PLACEHOLDER_TEXT )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text", STRING, TEXT )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-family", STRING, FONT_FAMILY )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-style", STRING, FONT_STYLE )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "point-size", FLOAT, POINT_SIZE )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceed-policy", INTEGER, EXCEED_POLICY )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primary-cursor-color", VECTOR4, PRIMARY_CURSOR_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondary-cursor-color", VECTOR4, SECONDARY_CURSOR_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enable-cursor-blink", BOOLEAN, ENABLE_CURSOR_BLINK )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-interval", FLOAT, CURSOR_BLINK_INTERVAL )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-duration", FLOAT, CURSOR_BLINK_DURATION )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-image", STRING, GRAB_HANDLE_IMAGE )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decoration-bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontal-alignment", STRING, HORIZONTAL_ALIGNMENT )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "vertical-alignment", STRING, VERTICAL_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "rendering-backend", INTEGER, RENDERING_BACKEND )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder-text", STRING, PLACEHOLDER_TEXT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text", STRING, TEXT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-family", STRING, FONT_FAMILY )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-style", STRING, FONT_STYLE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "point-size", FLOAT, POINT_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceed-policy", INTEGER, EXCEED_POLICY )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontal-alignment", STRING, HORIZONTAL_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "vertical-alignment", STRING, VERTICAL_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text-color", VECTOR4, TEXT_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow-offset", VECTOR2, SHADOW_OFFSET )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow-color", VECTOR4, SHADOW_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primary-cursor-color", VECTOR4, PRIMARY_CURSOR_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondary-cursor-color", VECTOR4, SECONDARY_CURSOR_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enable-cursor-blink", BOOLEAN, ENABLE_CURSOR_BLINK )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-interval", FLOAT, CURSOR_BLINK_INTERVAL )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-duration", FLOAT, CURSOR_BLINK_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-image", STRING, GRAB_HANDLE_IMAGE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-pressed-image", VECTOR4, GRAB_HANDLE_PRESSED_IMAGE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-threshold", FLOAT, SCROLL_THRESHOLD )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-speed", FLOAT, SCROLL_SPEED )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-left", STRING, SELECTION_HANDLE_IMAGE_LEFT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-right", STRING, SELECTION_HANDLE_IMAGE_RIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-left", STRING, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-right", STRING, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-highlight-color", STRING, SELECTION_HIGHLIGHT_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decoration-bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
DALI_TYPE_REGISTRATION_END()
{
float pointSize = value.Get< float >();
- if( impl.mController->GetDefaultPointSize() != pointSize /*TODO - epsilon*/ )
+ if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
{
impl.mController->SetDefaultPointSize( pointSize );
impl.RequestTextRelayout();
impl.mExceedPolicy = value.Get< int >();
break;
}
+ case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+ if( engine.GetHorizontalAlignment() != alignment )
+ {
+ engine.SetHorizontalAlignment( alignment );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+ if( engine.GetVerticalAlignment() != alignment )
+ {
+ engine.SetVerticalAlignment( alignment );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::TEXT_COLOR:
+ {
+ if ( impl.mController )
+ {
+ Vector4 textColor = value.Get< Vector4 >();
+ if ( impl.mController->GetTextColor() != textColor )
+ {
+ impl.mController->SetTextColor( textColor );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SHADOW_OFFSET:
+ {
+ if( impl.mController )
+ {
+ Vector2 shadowOffset = value.Get< Vector2 >();
+ if ( impl.mController->GetShadowOffset() != shadowOffset )
+ {
+ impl.mController->SetShadowOffset( shadowOffset );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SHADOW_COLOR:
+ {
+ if( impl.mController )
+ {
+ Vector4 shadowColor = value.Get< Vector4 >();
+ if ( impl.mController->GetShadowColor() != shadowColor )
+ {
+ impl.mController->SetShadowColor( shadowColor );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
if( impl.mDecorator )
if( impl.mDecorator )
{
- impl.mDecorator->SetGrabHandleImage( image );
+ impl.mDecorator->SetGrabHandleImage( GRAB_HANDLE_IMAGE_RELEASED, image );
}
break;
}
- case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
{
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
if( impl.mDecorator )
{
- impl.mDecorator->SetBoundingBox( value.Get< Rect<int> >() );
+ impl.mDecorator->SetGrabHandleImage( GRAB_HANDLE_IMAGE_PRESSED, image );
}
break;
}
- case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
+ case Toolkit::TextField::Property::SCROLL_THRESHOLD:
{
- LayoutEngine& engine = impl.mController->GetLayoutEngine();
- const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+ float threshold = value.Get< float >();
- if( engine.GetHorizontalAlignment() != alignment )
+ if( impl.mDecorator )
{
- engine.SetHorizontalAlignment( alignment );
- impl.RequestTextRelayout();
+ impl.mDecorator->SetScrollThreshold( threshold );
}
break;
}
- case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
+ case Toolkit::TextField::Property::SCROLL_SPEED:
{
- LayoutEngine& engine = impl.mController->GetLayoutEngine();
- const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+ float speed = value.Get< float >();
- if( engine.GetVerticalAlignment() != alignment )
+ if( impl.mDecorator )
{
- engine.SetVerticalAlignment( alignment );
- impl.RequestTextRelayout();
+ impl.mDecorator->SetScrollSpeed( speed );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_RELEASED, image );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetRightSelectionImage( SELECTION_HANDLE_RELEASED, image );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_PRESSED, image );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_PRESSED, image );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
+ {
+ Vector4 color = value.Get< Vector4 >();
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetHighlightColor( color );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetBoundingBox( value.Get< Rect<int> >() );
}
break;
}
value = impl.mExceedPolicy;
break;
}
+ case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
+ {
+ if( impl.mController )
+ {
+ value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
+ {
+ if( impl.mController )
+ {
+ value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::TEXT_COLOR:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->GetTextColor();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SHADOW_OFFSET:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->GetShadowOffset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SHADOW_COLOR:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->GetShadowColor();
+ }
+ break;
+ }
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
if( impl.mDecorator )
}
break;
}
- case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
{
if( impl.mDecorator )
{
- value = impl.mDecorator->GetBoundingBox();
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetGrabHandleImage( GRAB_HANDLE_IMAGE_RELEASED ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
}
break;
}
- case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
+ case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
{
- if( impl.mController )
+ if( impl.mDecorator )
{
- value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetGrabHandleImage( GRAB_HANDLE_IMAGE_PRESSED ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
}
break;
}
- case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
+ case Toolkit::TextField::Property::SCROLL_THRESHOLD:
{
- if( impl.mController )
+ if( impl.mDecorator )
{
- value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ value = impl.mDecorator->GetScrollThreshold();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SCROLL_SPEED:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetScrollSpeed();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
+ {
+ if( impl.mDecorator )
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetLeftSelectionImage( SELECTION_HANDLE_RELEASED ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
+ {
+ if( impl.mDecorator )
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetRightSelectionImage( SELECTION_HANDLE_RELEASED ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
+ {
+ if( impl.mDecorator )
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetLeftSelectionImage( SELECTION_HANDLE_PRESSED ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
+ {
+ if( impl.mDecorator )
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetRightSelectionImage( SELECTION_HANDLE_PRESSED ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetHighlightColor();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetBoundingBox();
}
break;
}
{
float pointSize = value.Get< float >();
- if( fabsf(impl.mController->GetDefaultPointSize() - pointSize) > Math::MACHINE_EPSILON_1 )
+ if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
{
impl.mController->SetDefaultPointSize( pointSize );
impl.RequestTextRelayout();
namespace
{
-const char* DEFAULT_GRAB_HANDLE_IMAGE( DALI_IMAGE_DIR "insertpoint-icon.png" );
+const char* DEFAULT_GRAB_HANDLE_IMAGE_RELEASED( DALI_IMAGE_DIR "insertpoint-icon.png" );
+const char* DEFAULT_GRAB_HANDLE_IMAGE_PRESSED( DALI_IMAGE_DIR "insertpoint-icon-pressed.png" );
const char* DEFAULT_SELECTION_HANDLE_ONE( DALI_IMAGE_DIR "text-input-selection-handle-left.png" );
const char* DEFAULT_SELECTION_HANDLE_TWO( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
//const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" );
const float DISPLAYED_HIGHLIGHT_Z_OFFSET( -0.05f );
-const float SCROLL_THRESHOLD = 10.f;
-const float SCROLL_SPEED = 15.f;
const unsigned int SCROLL_TICK_INTERVAL = 50u;
+const float SCROLL_THRESHOLD = 10.f;
+const float SCROLL_SPEED = 300.f;
+const float SCROLL_DISTANCE = SCROLL_SPEED * SCROLL_TICK_INTERVAL * TO_SECONDS;
+
/**
* structure to hold coordinates of each quad, which will make up the mesh.
*/
ImageActor actor;
Actor grabArea;
- Image pressedImage;
- Image releasedImage;
-
Vector2 position;
float lineHeight; ///< Not the handle height
bool flipped;
mScrollDirection( SCROLL_NONE ),
mScrollThreshold( SCROLL_THRESHOLD ),
mScrollSpeed( SCROLL_SPEED ),
- mScrollInterval( SCROLL_TICK_INTERVAL ),
+ mScrollDistance( SCROLL_DISTANCE ),
mActiveGrabHandle( false ),
mActiveSelection( false ),
mActiveCopyPastePopup( false ),
mCopyPastePopup.SetPosition( popupPosition ); //todo grabhandle(cursor) or selection handle positions to be used
}
- void CreateCursor( ImageActor& cursor )
+ void CreateCursor( ImageActor& cursor, const Vector4& color )
{
- cursor = CreateSolidColorActor( Color::WHITE );
+ cursor = CreateSolidColorActor( color );
cursor.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Need to set the default parent origin as CreateSolidColorActor() sets a different one.
cursor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
}
{
if ( !mPrimaryCursor )
{
- CreateCursor( mPrimaryCursor );
+ CreateCursor( mPrimaryCursor, mCursor[PRIMARY_CURSOR].color );
#ifdef DECORATOR_DEBUG
mPrimaryCursor.SetName( "PrimaryCursorActor" );
#endif
{
if ( !mSecondaryCursor )
{
- CreateCursor( mSecondaryCursor );
+ CreateCursor( mSecondaryCursor, mCursor[SECONDARY_CURSOR].color );
#ifdef DECORATOR_DEBUG
mSecondaryCursor.SetName( "SecondaryCursorActor" );
#endif
{
if( !mGrabHandle )
{
- if ( !mGrabHandleImage )
+ if ( !mGrabHandleImageReleased )
{
- mGrabHandleImage = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE );
+ mGrabHandleImageReleased = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_RELEASED );
+ }
+ if ( !mGrabHandleImagePressed )
+ {
+ mGrabHandleImagePressed = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_PRESSED );
}
- mGrabHandle = ImageActor::New( mGrabHandleImage );
+ mGrabHandle = ImageActor::New( mGrabHandleImageReleased );
mGrabHandle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
mGrabHandle.SetDrawMode( DrawMode::OVERLAY );
// Area that Grab handle responds to, larger than actual handle so easier to move
SelectionHandleImpl& primary = mSelectionHandle[ PRIMARY_SELECTION_HANDLE ];
if ( !primary.actor )
{
- if ( !primary.releasedImage )
+ if ( !mSelectionReleasedLeft )
{
- primary.releasedImage = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE );
+ mSelectionReleasedLeft = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE );
}
- primary.actor = ImageActor::New( primary.releasedImage );
+ primary.actor = ImageActor::New( mSelectionReleasedLeft );
#ifdef DECORATOR_DEBUG
primary.actor.SetName("SelectionHandleOne");
#endif
SelectionHandleImpl& secondary = mSelectionHandle[ SECONDARY_SELECTION_HANDLE ];
if ( !secondary.actor )
{
- if ( !secondary.releasedImage )
+ if ( !mSelectionReleasedRight )
{
- secondary.releasedImage = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO );
+ mSelectionReleasedRight = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO );
}
- secondary.actor = ImageActor::New( secondary.releasedImage );
+ secondary.actor = ImageActor::New( mSelectionReleasedRight );
#ifdef DECORATOR_DEBUG
secondary.actor.SetName("SelectionHandleTwo");
#endif
if( Gesture::Started == gesture.state )
{
mGrabDisplacementX = mGrabDisplacementY = 0;
+ mGrabHandle.SetImage( mGrabHandleImagePressed );
}
mGrabDisplacementX += gesture.displacement.x;
{
mObserver.GrabHandleEvent( GRAB_HANDLE_RELEASED, x, y );
}
+
+ mGrabHandle.SetImage( mGrabHandleImageReleased );
}
}
}
void SetScrollSpeed( float speed )
{
mScrollSpeed = speed;
+ mScrollDistance = speed * SCROLL_TICK_INTERVAL * TO_SECONDS;
}
float GetScrollSpeed() const
return mScrollSpeed;
}
- void SetScrollTickInterval( float seconds )
- {
- mScrollInterval = static_cast<unsigned int>( seconds * TO_MILLISECONDS );
- }
-
- float GetScrollTickInterval() const
- {
- return static_cast<float>( mScrollInterval ) * TO_SECONDS;
- }
-
/**
* Creates and starts a timer to scroll the text when handles are close to the edges of the text.
*
{
if( !mScrollTimer )
{
- mScrollTimer = Timer::New( mScrollInterval );
+ mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL );
mScrollTimer.TickSignal().Connect( this, &Decorator::Impl::OnScrollTimerTick );
}
bool OnScrollTimerTick()
{
mObserver.GrabHandleEvent( GRAB_HANDLE_SCROLLING,
- mScrollDirection == SCROLL_RIGHT ? mScrollSpeed : -mScrollSpeed,
+ mScrollDirection == SCROLL_RIGHT ? mScrollDistance : -mScrollDistance,
0.f );
return true;
}
TextSelectionPopup mCopyPastePopup;
Image mCursorImage;
- Image mGrabHandleImage;
+ Image mGrabHandleImageReleased;
+ Image mGrabHandleImagePressed;
Mesh mHighlightMesh; ///< Mesh for highlight
MeshData mHighlightMeshData; ///< Mesh Data for highlight
Material mHighlightMaterial; ///< Material used for highlight
CursorImpl mCursor[CURSOR_COUNT];
SelectionHandleImpl mSelectionHandle[SELECTION_HANDLE_COUNT];
+
QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
+ Image mSelectionReleasedLeft; ///< Selection handle images
+ Image mSelectionReleasedRight;
+ Image mSelectionPressedLeft;
+ Image mSelectionPressedRight;
+
Rect<int> mBoundingBox;
Vector4 mHighlightColor; ///< Color of the highlight
float mGrabDisplacementY;
ScrollDirection mScrollDirection; ///< The direction of the scroll.
float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
- float mScrollSpeed; ///< Distance the text scrolls during a scroll interval.
+ float mScrollSpeed; ///< The scroll speed in pixels per second.
+ float mScrollDistance; ///< Distance the text scrolls during a scroll interval.
unsigned int mScrollInterval; ///< Time in milliseconds of a scroll interval.
bool mActiveGrabHandle : 1;
return mImpl->mActiveGrabHandle;
}
-void Decorator::SetGrabHandleImage( Dali::Image image )
+void Decorator::SetGrabHandleImage( GrabHandleImageType type, Dali::Image image )
{
- mImpl->mGrabHandleImage = image;
+ if( GRAB_HANDLE_IMAGE_PRESSED == type )
+ {
+ mImpl->mGrabHandleImagePressed = image;
+ }
+ else
+ {
+ mImpl->mGrabHandleImageReleased = image;
+ }
}
-Dali::Image Decorator::GetGrabHandleImage() const
+Dali::Image Decorator::GetGrabHandleImage( GrabHandleImageType type ) const
{
- return mImpl->mGrabHandleImage;
+ if( GRAB_HANDLE_IMAGE_PRESSED == type )
+ {
+ return mImpl->mGrabHandleImagePressed;
+ }
+
+ return mImpl->mGrabHandleImageReleased;
}
/** Selection **/
height = mImpl->mSelectionHandle[handle].lineHeight;
}
-void Decorator::SetImage( SelectionHandle handle, SelectionHandleState state, Dali::Image image )
+void Decorator::SetLeftSelectionImage( SelectionHandleState state, Dali::Image image )
{
if( SELECTION_HANDLE_PRESSED == state )
{
- mImpl->mSelectionHandle[handle].pressedImage = image;
+ mImpl->mSelectionPressedLeft = image;
}
else
{
- mImpl->mSelectionHandle[handle].releasedImage = image;
+ mImpl->mSelectionReleasedLeft = image;
}
}
-Dali::Image Decorator::GetImage( SelectionHandle handle, SelectionHandleState state ) const
+Dali::Image Decorator::GetLeftSelectionImage( SelectionHandleState state ) const
{
if( SELECTION_HANDLE_PRESSED == state )
{
- return mImpl->mSelectionHandle[handle].pressedImage;
+ return mImpl->mSelectionPressedLeft;
}
- return mImpl->mSelectionHandle[handle].releasedImage;
+ return mImpl->mSelectionReleasedLeft;
+}
+
+void Decorator::SetRightSelectionImage( SelectionHandleState state, Dali::Image image )
+{
+ if( SELECTION_HANDLE_PRESSED == state )
+ {
+ mImpl->mSelectionPressedRight = image;
+ }
+ else
+ {
+ mImpl->mSelectionReleasedRight = image;
+ }
+}
+
+Dali::Image Decorator::GetRightSelectionImage( SelectionHandleState state ) const
+{
+ if( SELECTION_HANDLE_PRESSED == state )
+ {
+ return mImpl->mSelectionPressedRight;
+ }
+
+ return mImpl->mSelectionReleasedRight;
}
void Decorator::AddHighlight( float x1, float y1, float x2, float y2 )
mImpl->mHighlightQuadList.clear();
}
+void Decorator::SetHighlightColor( const Vector4& color )
+{
+ mImpl->mHighlightColor = color;
+}
+
+const Vector4& Decorator::GetHighlightColor() const
+{
+ return mImpl->mHighlightColor;
+}
+
void Decorator::SetPopupActive( bool active )
{
mImpl->mActiveCopyPastePopup = active;
return mImpl->GetScrollSpeed();
}
-void Decorator::SetScrollTickInterval( float seconds )
-{
- mImpl->SetScrollTickInterval( seconds );
-}
-
-float Decorator::GetScrollTickInterval() const
-{
- return mImpl->GetScrollTickInterval();
-}
-
Decorator::~Decorator()
{
delete mImpl;
GRAB_HANDLE_STOP_SCROLLING
};
+// Used to set different grab handle images
+enum GrabHandleImageType
+{
+ GRAB_HANDLE_IMAGE_PRESSED,
+ GRAB_HANDLE_IMAGE_RELEASED
+};
+
// The set the selection-handle positions etc.
enum SelectionHandle
{
/**
* @brief Sets the image for the grab handle.
*
+ * @param[in] type A different image can be set for the pressed/released states.
* @param[in] image The image to use.
*/
- void SetGrabHandleImage( Dali::Image image );
+ void SetGrabHandleImage( GrabHandleImageType type, Dali::Image image );
/**
* @brief Retrieves the image for the grab handle.
*
+ * @param[in] type A different image can be set for the pressed/released states.
* @return The grab handle image.
*/
- Dali::Image GetGrabHandleImage() const;
+ Dali::Image GetGrabHandleImage( GrabHandleImageType type ) const;
/**
* @brief Sets whether the selection handles and highlight are active.
/**
* @brief Sets the image for one of the selection handles.
*
- * @param[in] handle The selection handle.
* @param[in] state A different image can be set for the pressed/released states.
* @param[in] image The image to use.
*/
- void SetImage( SelectionHandle handle, SelectionHandleState state, Dali::Image image );
+ void SetLeftSelectionImage( SelectionHandleState state, Dali::Image image );
/**
* @brief Retrieves the image for a selection handle.
*
- * @param[in] handle The selection handle.
* @param[in] state A different image can be set for the pressed/released states.
* @return The image.
*/
- Dali::Image GetImage( SelectionHandle handle, SelectionHandleState state ) const;
+ Dali::Image GetLeftSelectionImage( SelectionHandleState state ) const;
+
+ /**
+ * @brief Sets the image for one of the selection handles.
+ *
+ * @param[in] state A different image can be set for the pressed/released states.
+ * @param[in] image The image to use.
+ */
+ void SetRightSelectionImage( SelectionHandleState state, Dali::Image image );
+
+ /**
+ * @brief Retrieves the image for a selection handle.
+ *
+ * @param[in] state A different image can be set for the pressed/released states.
+ * @return The image.
+ */
+ Dali::Image GetRightSelectionImage( SelectionHandleState state ) const;
/**
* @brief Adds a quad to the existing selection highlights.
void ClearHighlights();
/**
+ * @brief Sets the selection highlight color.
+ *
+ * @param[in] image The image to use.
+ */
+ void SetHighlightColor( const Vector4& color );
+
+ /**
+ * @brief Retrieves the selection highlight color.
+ *
+ * @return The image.
+ */
+ const Vector4& GetHighlightColor() const;
+
+ /**
* @brief Set the Selection Popup to show or hide via the active flaf
* @param[in] active true to show, false to hide
*/
mDecoratorUpdated( false ),
mCursorBlinkEnabled( true ),
mGrabHandleEnabled( true ),
- mGrabHandlePopupEnabled( true ),
- mSelectionEnabled( true ),
+ mGrabHandlePopupEnabled( false ),
+ mSelectionEnabled( false ),
mHorizontalScrollingEnabled( true ),
mVerticalScrollingEnabled( false ),
mUpdateCursorPosition( false ),
{
enum
{
- RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
- PLACEHOLDER_TEXT, ///< name "placeholder-text", The text to display when the TextField is empty, type STRING
- TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
- FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
- FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
- POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
- EXCEED_POLICY, ///< name "exceed-policy" Specifies how the text is truncated when it does not fit, type INT
- PRIMARY_CURSOR_COLOR, ///< name "primary-cursor-color", The color to apply to the primary cursor, type VECTOR4
- SECONDARY_CURSOR_COLOR, ///< name "secondary-cursor-color", The color to apply to the secondary cursor, type VECTOR4
- ENABLE_CURSOR_BLINK, ///< name "enable-cursor-blink", Whether the cursor should blink or not, type BOOLEAN
- CURSOR_BLINK_INTERVAL, ///< name "cursor-blink-interval", The time interval between cursor on/off states, type FLOAT
- CURSOR_BLINK_DURATION, ///< name "cursor-blink-duration", The cursor will stop blinking after this duration (if non-zero), type FLOAT
- GRAB_HANDLE_IMAGE, ///< name "grab-handle-image", The image to display for grab handle, type STRING
- DECORATION_BOUNDING_BOX, ///< name "decoration-bounding-box", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE
- HORIZONTAL_ALIGNMENT, ///< name "horizontal-alignment", The line horizontal alignment, type STRING, values "BEGIN", "CENTER", "END"
- VERTICAL_ALIGNMENT ///< name "vertical-alignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM"
+ RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
+ PLACEHOLDER_TEXT, ///< name "placeholder-text", The text to display when the TextField is empty, type STRING
+ TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
+ FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
+ FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
+ POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
+ EXCEED_POLICY, ///< name "exceed-policy" Specifies how the text is truncated when it does not fit, type INT
+ HORIZONTAL_ALIGNMENT, ///< name "horizontal-alignment", The line horizontal alignment, type STRING, values "BEGIN", "CENTER", "END"
+ VERTICAL_ALIGNMENT, ///< name "vertical-alignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM"
+ TEXT_COLOR, ///< name "text-color", The text color, type VECTOR4
+ SHADOW_OFFSET, ///< name "shadow-offset", The drop shadow offset 0 indicates no shadow, type VECTOR2
+ SHADOW_COLOR, ///< name "shadow-color", The color of a drop shadow, type VECTOR4
+ PRIMARY_CURSOR_COLOR, ///< name "primary-cursor-color", The color to apply to the primary cursor, type VECTOR4
+ SECONDARY_CURSOR_COLOR, ///< name "secondary-cursor-color", The color to apply to the secondary cursor, type VECTOR4
+ ENABLE_CURSOR_BLINK, ///< name "enable-cursor-blink", Whether the cursor should blink or not, type BOOLEAN
+ CURSOR_BLINK_INTERVAL, ///< name "cursor-blink-interval", The time interval in seconds between cursor on/off states, type FLOAT
+ CURSOR_BLINK_DURATION, ///< name "cursor-blink-duration", The cursor will stop blinking after this number of seconds (if non-zero), type FLOAT
+ GRAB_HANDLE_IMAGE, ///< name "grab-handle-image", The image to display for the grab handle, type STRING
+ GRAB_HANDLE_PRESSED_IMAGE, ///< name "grab-handle-pressed-image", The image to display when the grab handle is pressed, type STRING
+ SCROLL_THRESHOLD, ///< name "scroll-threshold" Scrolling will occur if the cursor is this close to the control border, type FLOAT
+ SCROLL_SPEED, ///< name "scroll-speed" The scroll speed in pixels per second, type FLOAT
+ SELECTION_HANDLE_IMAGE_LEFT, ///< name "selection-handle-image-left", The image to display for the left selection handle, type STRING
+ SELECTION_HANDLE_IMAGE_RIGHT, ///< name "selection-handle-image-right", The image to display for the right selection handle, type STRING
+ SELECTION_HANDLE_PRESSED_IMAGE_LEFT, ///< name "selection-handle-pressed-image-left" The image to display when the left selection handle is pressed, type STRING
+ SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, ///< name "selection-handle-pressed-image-right" The image to display when the right selection handle is pressed, type STRING
+ SELECTION_HIGHLIGHT_COLOR, ///< name "selection-highlight-color" The color of the selection highlight, type VECTOR4
+ DECORATION_BOUNDING_BOX ///< name "decoration-bounding-box", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE
};
};