From: Paul Wisbey Date: Wed, 22 Apr 2015 14:25:30 +0000 (+0100) Subject: TextField property updates X-Git-Tag: dali_1.0.40~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=6af7f672f096ad4de44568a48810b509379408e8 TextField property updates Change-Id: I5ee0b8ef3e7e0b9760a4731f05fb479dfe123be8 --- diff --git a/dali-toolkit/images/insertpoint-icon-pressed.png b/dali-toolkit/images/insertpoint-icon-pressed.png new file mode 100644 index 0000000..171b737 Binary files /dev/null and b/dali-toolkit/images/insertpoint-icon-pressed.png differ diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 48ee476..5074cdc 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -79,22 +79,33 @@ BaseHandle Create() // 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() @@ -186,7 +197,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { float pointSize = value.Get< float >(); - if( impl.mController->GetDefaultPointSize() != pointSize /*TODO - epsilon*/ ) + if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) ) { impl.mController->SetDefaultPointSize( pointSize ); impl.RequestTextRelayout(); @@ -199,6 +210,73 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr 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 ) @@ -245,43 +323,95 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr 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 >() ); + 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 >() ); } break; } @@ -331,6 +461,50 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde 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 ) @@ -368,31 +542,107 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } 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; } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index f247c61..44bd0ae 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -173,7 +173,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { 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(); diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 2098a5f..6d348cb 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -72,7 +72,8 @@ Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLog 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" ); @@ -87,10 +88,12 @@ const float TO_SECONDS = 1.f / TO_MILLISECONDS; 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. */ @@ -192,9 +195,6 @@ struct Decorator::Impl : public ConnectionTracker ImageActor actor; Actor grabArea; - Image pressedImage; - Image releasedImage; - Vector2 position; float lineHeight; ///< Not the handle height bool flipped; @@ -213,7 +213,7 @@ struct Decorator::Impl : public ConnectionTracker mScrollDirection( SCROLL_NONE ), mScrollThreshold( SCROLL_THRESHOLD ), mScrollSpeed( SCROLL_SPEED ), - mScrollInterval( SCROLL_TICK_INTERVAL ), + mScrollDistance( SCROLL_DISTANCE ), mActiveGrabHandle( false ), mActiveSelection( false ), mActiveCopyPastePopup( false ), @@ -352,9 +352,9 @@ struct Decorator::Impl : public ConnectionTracker 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 ); } @@ -375,7 +375,7 @@ struct Decorator::Impl : public ConnectionTracker { if ( !mPrimaryCursor ) { - CreateCursor( mPrimaryCursor ); + CreateCursor( mPrimaryCursor, mCursor[PRIMARY_CURSOR].color ); #ifdef DECORATOR_DEBUG mPrimaryCursor.SetName( "PrimaryCursorActor" ); #endif @@ -387,7 +387,7 @@ struct Decorator::Impl : public ConnectionTracker { if ( !mSecondaryCursor ) { - CreateCursor( mSecondaryCursor ); + CreateCursor( mSecondaryCursor, mCursor[SECONDARY_CURSOR].color ); #ifdef DECORATOR_DEBUG mSecondaryCursor.SetName( "SecondaryCursorActor" ); #endif @@ -458,12 +458,16 @@ struct Decorator::Impl : public ConnectionTracker { 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 @@ -501,12 +505,12 @@ struct Decorator::Impl : public ConnectionTracker 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 @@ -533,12 +537,12 @@ struct Decorator::Impl : public ConnectionTracker 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 @@ -696,6 +700,7 @@ struct Decorator::Impl : public ConnectionTracker if( Gesture::Started == gesture.state ) { mGrabDisplacementX = mGrabDisplacementY = 0; + mGrabHandle.SetImage( mGrabHandleImagePressed ); } mGrabDisplacementX += gesture.displacement.x; @@ -739,6 +744,8 @@ struct Decorator::Impl : public ConnectionTracker { mObserver.GrabHandleEvent( GRAB_HANDLE_RELEASED, x, y ); } + + mGrabHandle.SetImage( mGrabHandleImageReleased ); } } } @@ -866,6 +873,7 @@ struct Decorator::Impl : public ConnectionTracker void SetScrollSpeed( float speed ) { mScrollSpeed = speed; + mScrollDistance = speed * SCROLL_TICK_INTERVAL * TO_SECONDS; } float GetScrollSpeed() const @@ -873,16 +881,6 @@ struct Decorator::Impl : public ConnectionTracker return mScrollSpeed; } - void SetScrollTickInterval( float seconds ) - { - mScrollInterval = static_cast( seconds * TO_MILLISECONDS ); - } - - float GetScrollTickInterval() const - { - return static_cast( mScrollInterval ) * TO_SECONDS; - } - /** * Creates and starts a timer to scroll the text when handles are close to the edges of the text. * @@ -892,7 +890,7 @@ struct Decorator::Impl : public ConnectionTracker { if( !mScrollTimer ) { - mScrollTimer = Timer::New( mScrollInterval ); + mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL ); mScrollTimer.TickSignal().Connect( this, &Decorator::Impl::OnScrollTimerTick ); } @@ -921,7 +919,7 @@ struct Decorator::Impl : public ConnectionTracker bool OnScrollTimerTick() { mObserver.GrabHandleEvent( GRAB_HANDLE_SCROLLING, - mScrollDirection == SCROLL_RIGHT ? mScrollSpeed : -mScrollSpeed, + mScrollDirection == SCROLL_RIGHT ? mScrollDistance : -mScrollDistance, 0.f ); return true; } @@ -943,15 +941,22 @@ struct Decorator::Impl : public ConnectionTracker 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 mBoundingBox; Vector4 mHighlightColor; ///< Color of the highlight @@ -962,7 +967,8 @@ struct Decorator::Impl : public ConnectionTracker 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; @@ -1102,14 +1108,26 @@ bool Decorator::IsGrabHandleActive() const 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 **/ @@ -1138,26 +1156,48 @@ void Decorator::GetPosition( SelectionHandle handle, float& x, float& y, float& 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 ) @@ -1170,6 +1210,16 @@ void Decorator::ClearHighlights() 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; @@ -1202,16 +1252,6 @@ float Decorator::GetScrollSpeed() const return mImpl->GetScrollSpeed(); } -void Decorator::SetScrollTickInterval( float seconds ) -{ - mImpl->SetScrollTickInterval( seconds ); -} - -float Decorator::GetScrollTickInterval() const -{ - return mImpl->GetScrollTickInterval(); -} - Decorator::~Decorator() { delete mImpl; diff --git a/dali-toolkit/internal/text/decorator/text-decorator.h b/dali-toolkit/internal/text/decorator/text-decorator.h index 588d224..e8bc5cf 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.h +++ b/dali-toolkit/internal/text/decorator/text-decorator.h @@ -71,6 +71,13 @@ enum GrabHandleState 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 { @@ -297,16 +304,18 @@ public: /** * @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. @@ -345,20 +354,34 @@ public: /** * @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. @@ -376,6 +399,20 @@ public: 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 */ diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 74d9abf..6baf19e 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -105,8 +105,8 @@ EventData::EventData( DecoratorPtr decorator ) mDecoratorUpdated( false ), mCursorBlinkEnabled( true ), mGrabHandleEnabled( true ), - mGrabHandlePopupEnabled( true ), - mSelectionEnabled( true ), + mGrabHandlePopupEnabled( false ), + mSelectionEnabled( false ), mHorizontalScrollingEnabled( true ), mVerticalScrollingEnabled( false ), mUpdateCursorPosition( false ), diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.h b/dali-toolkit/public-api/controls/text-controls/text-field.h index 3736a2f..8eac8f7 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-field.h +++ b/dali-toolkit/public-api/controls/text-controls/text-field.h @@ -55,22 +55,33 @@ public: { 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 }; };