From: Agnelo Vaz Date: Fri, 3 Jul 2015 15:59:25 +0000 (+0100) Subject: TextField Styling upgrade, Builder to use filenames X-Git-Tag: dali_1.0.48~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F04%2F42904%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git TextField Styling upgrade, Builder to use filenames Change-Id: Iaa66bbf675e988ecf2a5f757de07f2a33c14f31d Signed-off-by: Agnelo Vaz --- diff --git a/dali-toolkit/images/cursor_handler_center.png b/dali-toolkit/images/cursor_handler_center.png new file mode 100755 index 0000000..d9841f8 Binary files /dev/null and b/dali-toolkit/images/cursor_handler_center.png differ diff --git a/dali-toolkit/images/selection_handle_left.png b/dali-toolkit/images/selection_handle_left.png new file mode 100755 index 0000000..dea269c Binary files /dev/null and b/dali-toolkit/images/selection_handle_left.png differ diff --git a/dali-toolkit/images/selection_handle_right.png b/dali-toolkit/images/selection_handle_right.png new file mode 100755 index 0000000..ea5ac91 Binary files /dev/null and b/dali-toolkit/images/selection_handle_right.png differ diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index d4a2a3e..0371491 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -67,6 +67,8 @@ Integration::Log::Filter* gFilterScript = Integration::Log::Filter::New(Debug:: namespace { +#define TOKEN_STRING(x) #x + const std::string KEYNAME_STYLES = "styles"; const std::string KEYNAME_TYPE = "type"; const std::string KEYNAME_ACTORS = "actors"; @@ -1357,6 +1359,13 @@ Builder::Builder() : mSlotDelegate( this ) { mParser = Dali::Toolkit::JsonParser::New(); + + Property::Map defaultDirs; + defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ] = DALI_IMAGE_DIR; + defaultDirs[ TOKEN_STRING(DALI_SOUND_DIR) ] = DALI_SOUND_DIR; + defaultDirs[ TOKEN_STRING(DALI_STYLE_DIR) ] = DALI_STYLE_DIR; + + AddConstants( defaultDirs ); } Builder::~Builder() 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 b2a0b50..991848b 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -108,7 +108,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "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, "grab-handle-pressed-image", STRING, 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 ) @@ -347,7 +347,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr const Vector4 color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); - impl.mDecorator->SetColor( PRIMARY_CURSOR, color ); + impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color ); impl.RequestTextRelayout(); } break; @@ -359,7 +359,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr const Vector4 color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); - impl.mDecorator->SetColor( SECONDARY_CURSOR, color ); + impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color ); impl.RequestTextRelayout(); } break; diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index db7596a..59507cd 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -47,9 +47,9 @@ namespace // todo Move this to adaptor?? #define GET_LOCALE_TEXT(string) dgettext("elementary", string) -const Dali::Vector4 DEFAULT_POPUP_LINE_COLOR( Dali::Vector4( 0.69f, 0.93f, 0.93f, 1.0f ) ); +const Dali::Vector4 DEFAULT_POPUP_DIVIDER_COLOR( Dali::Vector4( 0.23f, 0.72f, 0.8f, 0.11f ) ); const Dali::Vector4 DEFAULT_OPTION_ICON( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); -const Dali::Vector4 DEFAULT_OPTION_ICON_PRESSED( Dali::Vector4( 0.12f, 0.56f, 1.0f, 1.0f ) ); +const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 0.11f ) ); const std::string DEFAULT_POPUP_BACKGROUND_IMAGE( DALI_IMAGE_DIR "selection-popup-bg#.png" ); const std::string OPTION_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" ); @@ -702,7 +702,7 @@ Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::But ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE ); divider.SetSize( size ); divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); - divider.SetColor( mLineColor ); + divider.SetColor( mDividerColor ); mToolbar.AddDivider( divider ); } } @@ -763,9 +763,9 @@ TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* cal mOptionDividerSize( Size( 2.0f, 0.0f) ), mEnabledButtons( Toolkit::TextSelectionPopup::NONE ), mCallbackInterface( callbackInterface ), - mLineColor( DEFAULT_POPUP_LINE_COLOR ), + mDividerColor( DEFAULT_POPUP_DIVIDER_COLOR ), mIconColor( DEFAULT_OPTION_ICON ), - mPressedColor( DEFAULT_OPTION_ICON_PRESSED ), + mPressedColor( DEFAULT_OPTION_PRESSED_COLOR ), mSelectOptionPriority( 1 ), mSelectAllOptionPriority ( 2 ), mCutOptionPriority ( 4 ), diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h index c409983..9882764 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h @@ -259,7 +259,7 @@ private: // Data Toolkit::TextSelectionPopup::Buttons mEnabledButtons; // stores enabled buttons Toolkit::TextSelectionPopupCallbackInterface* mCallbackInterface; - Vector4 mLineColor; // Color of the line around the text input popup + Vector4 mDividerColor; // Color of the divider between buttons Vector4 mIconColor; // Color of the popup icon. Vector4 mPressedColor; // Color of the popup option when pressed. diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index cf450ef..9a1b7cd 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -104,12 +104,9 @@ Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLog namespace { -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_RELEASED( DALI_IMAGE_DIR "text-input-selection-handle-left.png" ); -const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" ); -const char* DEFAULT_SELECTION_HANDLE_TWO_RELEASED( DALI_IMAGE_DIR "text-input-selection-handle-right.png" ); -const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.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. @@ -118,6 +115,8 @@ const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f ); const Dali::Vector4 LIGHT_BLUE( (0xb2 / 255.0f), (0xeb / 255.0f), (0xf2 / 255.0f), 0.5f ); // The text highlight color. +const Dali::Vector4 HANDLE_COLOR( 0.0f, (183.0f / 255.0f), (229.0f / 255.0f), 1.0f ); + const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval const float TO_MILLISECONDS = 1000.f; const float TO_SECONDS = 1.f / TO_MILLISECONDS; @@ -264,6 +263,7 @@ struct Decorator::Impl : public ConnectionTracker : mController( controller ), mEnabledPopupButtons( TextSelectionPopup::NONE ), mTextSelectionPopupCallbackInterface( callbackInterface ), + mHandleColor( HANDLE_COLOR ), mBoundingBox( Rect() ), mHighlightColor( LIGHT_BLUE ), mHighlightPosition( Vector2::ZERO ), @@ -578,10 +578,6 @@ struct Decorator::Impl : public ConnectionTracker { mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_RELEASED ); } - if( !mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] ) - { - mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_GRAB_HANDLE_IMAGE_PRESSED ); - } grabHandle.actor = ImageActor::New( mHandleImages[GRAB_HANDLE][HANDLE_IMAGE_RELEASED] ); grabHandle.actor.SetSortModifier( DECORATION_DEPTH_INDEX ); @@ -608,6 +604,7 @@ struct Decorator::Impl : public ConnectionTracker grabHandle.grabArea.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); grabHandle.grabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE ); grabHandle.actor.Add( grabHandle.grabArea ); + grabHandle.actor.SetColor( mHandleColor ); grabHandle.grabArea.TouchedSignal().Connect( this, &Decorator::Impl::OnGrabHandleTouched ); mTapDetector.Attach( grabHandle.grabArea ); @@ -626,10 +623,6 @@ struct Decorator::Impl : public ConnectionTracker { mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_RELEASED ); } - if( !mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) - { - mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE_PRESSED ); - } primary.actor = ImageActor::New( mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] ); #ifdef DECORATOR_DEBUG @@ -638,6 +631,7 @@ struct Decorator::Impl : public ConnectionTracker primary.actor.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text. primary.actor.SetSortModifier( DECORATION_DEPTH_INDEX ); primary.flipped = false; + primary.actor.SetColor( mHandleColor ); primary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move #ifdef DECORATOR_DEBUG @@ -663,10 +657,6 @@ struct Decorator::Impl : public ConnectionTracker { mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_RELEASED ); } - if( !mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) - { - mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO_PRESSED ); - } secondary.actor = ImageActor::New( mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_RELEASED] ); #ifdef DECORATOR_DEBUG @@ -675,6 +665,7 @@ struct Decorator::Impl : public ConnectionTracker secondary.actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // Change to BOTTOM_LEFT if Look'n'Feel requires handle above text. secondary.actor.SetSortModifier( DECORATION_DEPTH_INDEX ); secondary.flipped = false; + secondary.actor.SetColor( mHandleColor ); secondary.grabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move #ifdef DECORATOR_DEBUG @@ -1093,8 +1084,10 @@ struct Decorator::Impl : public ConnectionTracker HandleImpl& leftHandle = mHandle[LEFT_SELECTION_HANDLE]; HandleImpl& rightHandle = mHandle[RIGHT_SELECTION_HANDLE]; - const HandleImageType leftImageType = leftHandle.pressed ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED; - const HandleImageType rightImageType = rightHandle.pressed ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED; + // If handle pressed and pressed image exists then use pressed image else stick with released image + const HandleImageType leftImageType = ( leftHandle.pressed && mHandleImages[LEFT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED; + const HandleImageType rightImageType = ( rightHandle.pressed && mHandleImages[RIGHT_SELECTION_HANDLE][HANDLE_IMAGE_PRESSED] ) ? HANDLE_IMAGE_PRESSED : HANDLE_IMAGE_RELEASED; + const bool leftFlipped = mSwapSelectionHandles != leftHandle.flipped; const bool rightFlipped = mSwapSelectionHandles != rightHandle.flipped; @@ -1207,7 +1200,7 @@ struct Decorator::Impl : public ConnectionTracker TextSelectionPopupCallbackInterface& mTextSelectionPopupCallbackInterface; Image mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT]; - Image mCursorImage; + Vector4 mHandleColor; CursorImpl mCursor[CURSOR_COUNT]; HandleImpl mHandle[HANDLE_TYPE_COUNT]; @@ -1294,7 +1287,7 @@ const Vector2& Decorator::GetPosition( Cursor cursor ) const return mImpl->mCursor[cursor].position; } -void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color ) +void Decorator::SetCursorColor( Cursor cursor, const Dali::Vector4& color ) { mImpl->mCursor[cursor].color = color; } @@ -1382,6 +1375,16 @@ Dali::Image Decorator::GetHandleImage( HandleType handleType, HandleImageType ha return mImpl->mHandleImages[handleType][handleImageType]; } +void Decorator::SetHandleColor( const Vector4& color ) +{ + mImpl->mHandleColor = color; +} + +const Vector4& Decorator::GetHandleColor() const +{ + return mImpl->mHandleColor; +} + void Decorator::SetPosition( HandleType handleType, float x, float y, float height ) { // Adjust grab handle displacement diff --git a/dali-toolkit/internal/text/decorator/text-decorator.h b/dali-toolkit/internal/text/decorator/text-decorator.h index f38c467..927fb83 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.h +++ b/dali-toolkit/internal/text/decorator/text-decorator.h @@ -257,7 +257,7 @@ public: * @param[in] cursor Whether this color is for the primary or secondary cursor. * @param[in] color The color to use. */ - void SetColor( Cursor cursor, const Dali::Vector4& color ); + void SetCursorColor( Cursor cursor, const Dali::Vector4& color ); /** * @brief Retrieves the color for a cursor. @@ -343,6 +343,20 @@ public: Dali::Image GetHandleImage( HandleType handleType, HandleImageType handleImageType ) const; /** + * @brief Sets the color of the handles + * + * @param[in] color The color to use. + */ + void SetHandleColor( const Vector4& color ); + + /** + * @brief Retrieves the handles color. + * + * @return The color of the handles. + */ + const Vector4& GetHandleColor() const; + + /** * @brief Sets the position of a selection handle. * * @param[in] handleType The handle to set. @@ -397,14 +411,14 @@ public: /** * @brief Sets the selection highlight color. * - * @param[in] image The image to use. + * @param[in] color The color to use. */ void SetHighlightColor( const Vector4& color ); /** * @brief Retrieves the selection highlight color. * - * @return The image. + * @return The color of the highlight */ const Vector4& GetHighlightColor() const; diff --git a/dali-toolkit/styles/dali-toolkit-default-theme.json b/dali-toolkit/styles/dali-toolkit-default-theme.json index fcfae07..bc12cec 100644 --- a/dali-toolkit/styles/dali-toolkit-default-theme.json +++ b/dali-toolkit/styles/dali-toolkit-default-theme.json @@ -47,7 +47,13 @@ distributing this software or its derivatives. { "font-family":"HelveticaNeue", "font-style":"Regular", - "point-size":18 + "point-size":18, + "primary-cursor-color":[0.0,0.71,0.9,1.0], + "secondary-cursor-color":[0.0,0.71,0.9,1.0], + "selection-highlight-color":[0.75,0.96,1.0,1.0], + "grab-handle-image":"{DALI_IMAGE_DIR}cursor_handler_center.png", + "selection-handle-image-left":"{DALI_IMAGE_DIR}selection_handle_left.png", + "selection-handle-image-right":"{DALI_IMAGE_DIR}selection_handle_right.png" }, "scrollview": { diff --git a/dali-toolkit/styles/mobile/dali-toolkit-default-theme.json b/dali-toolkit/styles/mobile/dali-toolkit-default-theme.json index 7c4099e..e46b5e5 100644 --- a/dali-toolkit/styles/mobile/dali-toolkit-default-theme.json +++ b/dali-toolkit/styles/mobile/dali-toolkit-default-theme.json @@ -62,6 +62,12 @@ distributing this software or its derivatives. { "font-family":"SamsungSans", "font-style":"Regular" + "primary-cursor-color":[1.0,0.71,0.9,1.0], + "secondary-cursor-color":[1.0,0.71,0.9,1.0], + "selection-highlight-color":[0.75,0.96,1.0,1.0], + "grab-handle-image":"{DALI_IMAGE_DIR}cursor_handler_center.png", + "selection-handle-image-left":"{DALI_IMAGE_DIR}selection_handle_left.png", + "selection-handle-image-right":"{DALI_IMAGE_DIR}selection_handle_right.png" }, "textfield-font-size-0":