From 674b214a1f66823205bce10b3b941b53746c69b9 Mon Sep 17 00:00:00 2001 From: daemyung jang Date: Sat, 5 Jul 2014 15:27:19 +0900 Subject: [PATCH] Add the text input cursor color property. [problem] The cursor color doesn't change when the system theme is changed. [cause] Not implement. [solution] Implement. Change-Id: Ia94b617be365d54aba7e94671a4ed70036e5bd4d Signed-off-by: Adeel Kazmi --- base/dali-toolkit/images/cursor.png | Bin 2821 -> 0 bytes .../controls/text-input/text-input-impl.cpp | 40 ++++++++++----------- .../internal/controls/text-input/text-input-impl.h | 11 +++--- base/dali-toolkit/styles/tizen-dark-theme.json | 3 +- .../public-api/controls/text-input/text-input.h | 4 +-- 5 files changed, 28 insertions(+), 30 deletions(-) delete mode 100644 base/dali-toolkit/images/cursor.png diff --git a/base/dali-toolkit/images/cursor.png b/base/dali-toolkit/images/cursor.png deleted file mode 100644 index 14f288b1983e39fafb22e5bbc5e3710c5487d39b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2821 zcmV+g3;OhlP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZH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?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0000mNkl #include #include +#include #include @@ -51,9 +52,6 @@ const char* DEFAULT_SELECTION_HANDLE_ONE( DALI_IMAGE_DIR "text-input-selection-h 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 char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" ); -const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" ); - -const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f ); const std::size_t CURSOR_BLINK_INTERVAL = 500; ///< Cursor blink interval const float CHARACTER_THRESHOLD( 2.5f ); ///< the threshold of a line. @@ -66,8 +64,9 @@ const Vector3 DEFAULT_HANDLE_ONE_OFFSET(0.0f, -5.0f, 0.0f); ///< const Vector3 DEFAULT_HANDLE_TWO_OFFSET(0.0f, -5.0f, 0.0f); ///< Handle Two's Offset const float TOP_HANDLE_TOP_OFFSET( 34.0f); ///< Offset between top handle and cutCopyPaste pop-up const float BOTTOM_HANDLE_BOTTOM_OFFSET(34.0f); ///< Offset between bottom handle and cutCopyPaste pop-up -const float CURSOR_THICKNESS(6.0f); +const float CURSOR_THICKNESS(4.0f); const Degree CURSOR_ANGLE_OFFSET(2.0f); ///< Offset from the angle of italic angle. +const Vector4 DEFAULT_CURSOR_COLOR(1.0f, 1.0f, 1.0f, 1.0f); const std::string NEWLINE( "\n" ); @@ -211,8 +210,9 @@ const Property::Index TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY = const Property::Index TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+11; const Property::Index TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+12; const Property::Index TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+13; - const Property::Index TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+14; +const Property::Index TextInput::CURSOR_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+15; + namespace Internal { @@ -251,6 +251,8 @@ PropertyRegistration property12( typeRegistration, "select-button-position-prior PropertyRegistration property13( typeRegistration, "select-all-button-position-priority", Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); PropertyRegistration property14( typeRegistration, "clipboard-button-position-priority", Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); PropertyRegistration property15( typeRegistration, "popup-offset-from-text", Toolkit::TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property16( typeRegistration, "cursor-color", Toolkit::TextInput::CURSOR_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty ); + // [TextInput::HighlightInfo] ///////////////////////////////////////////////// @@ -1167,9 +1169,8 @@ void TextInput::OnInitialize() // Create 2 cursors (standard LTR and RTL cursor for when text can be added at // different positions depending on language) - Image mCursorImage = Image::New( DEFAULT_CURSOR ); - mCursor = CreateCursor( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER ); - mCursorRTL = CreateCursor( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER ); + mCursor = CreateCursor(DEFAULT_CURSOR_COLOR); + mCursorRTL = CreateCursor(DEFAULT_CURSOR_COLOR); Actor self = Self(); self.Add( mCursor ); @@ -2823,21 +2824,10 @@ std::size_t TextInput::InsertAt( const Text& newText, const std::size_t insertio return insertedStringLength; } -ImageActor TextInput::CreateCursor( Image cursorImage, const Vector4& border ) +ImageActor TextInput::CreateCursor( const Vector4& color) { ImageActor cursor; - - if ( cursorImage ) - { - cursor = ImageActor::New( cursorImage ); - } - else - { - cursor = ImageActor::New( Image::New( DEFAULT_CURSOR ) ); - } - - cursor.SetStyle(ImageActor::STYLE_NINE_PATCH); - cursor.SetNinePatchBorder( border ); + cursor = CreateSolidColorActor(color); cursor.SetParentOrigin(ParentOrigin::TOP_LEFT); cursor.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER); @@ -5275,6 +5265,10 @@ void TextInput::SetProperty( BaseObject* object, Property::Index propertyIndex, textInputImpl.SetOffsetFromText( value.Get< Vector4 >() ); break; } + case Toolkit::TextInput::CURSOR_COLOR_PROPERTY: + { + textInputImpl.mCursor.SetColor( value.Get< Vector4 >() ); + } } } } @@ -5366,6 +5360,10 @@ Property::Value TextInput::GetProperty( BaseObject* object, Property::Index prop value = textInputImpl.GetOffsetFromText(); break; } + case Toolkit::TextInput::CURSOR_COLOR_PROPERTY: + { + value = textInputImpl.mCursor.GetCurrentColor(); + } } } return value; diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h b/base/dali-toolkit/internal/controls/text-input/text-input-impl.h index d38b7cb..8bc5a2a 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h +++ b/base/dali-toolkit/internal/controls/text-input/text-input-impl.h @@ -866,12 +866,11 @@ public: // Public to allow internal testing. std::size_t InsertAt( const Text& newText, const std::size_t insertionPosition, const std::size_t numberOfCharactersToReplace ); /** - * Creates a cursor from the supplied image - * @param[in] cursorImage the image to be used for the cursor. - * @param[in] border the nine patch border corresponding to the supplied image. - * @return the image actor to be used as the cursor. - */ - ImageActor CreateCursor( Image cursorImage, const Vector4& border ); + * Creates a cursor. + * @param[in] color the cursor color. + * @return the image actor to be used as the cursor. + */ + ImageActor CreateCursor( const Vector4 &color ); /** * Moves cursor to the right diff --git a/base/dali-toolkit/styles/tizen-dark-theme.json b/base/dali-toolkit/styles/tizen-dark-theme.json index fd3d554..a771860 100644 --- a/base/dali-toolkit/styles/tizen-dark-theme.json +++ b/base/dali-toolkit/styles/tizen-dark-theme.json @@ -46,7 +46,8 @@ distributing this software or its derivatives. "paste-button-position-priority":5, "select-button-position-priority":1, "select-all-button-position-priority":2, - "clipboard-button-position-priority":6 + "clipboard-button-position-priority":6, + "cursor-color":"F052" }, "scrollview": { diff --git a/capi/dali-toolkit/public-api/controls/text-input/text-input.h b/capi/dali-toolkit/public-api/controls/text-input/text-input.h index 6cce464..8ecb4d7 100644 --- a/capi/dali-toolkit/public-api/controls/text-input/text-input.h +++ b/capi/dali-toolkit/public-api/controls/text-input/text-input.h @@ -57,15 +57,14 @@ public: static const Property::Index CUT_AND_PASTE_ICON_PRESSED_COLOR_PROPERTY; // Property, name "cut-and-paste-icon-pressed-color", type VECTOR4 static const Property::Index CUT_AND_PASTE_TEXT_COLOR_PROPERTY; // Property, name "cut-and-paste-text-color", type VECTOR4 static const Property::Index CUT_AND_PASTE_TEXT_PRESSED_COLOR_PROPERTY; // Property, name "cut-and-paste-text-pressed-color", type VECTOR4 - static const Property::Index CUT_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "cut-button-position-priority", type unsigned int static const Property::Index COPY_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "copy-button-position-priority", type unsigned int static const Property::Index PASTE_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "paste-button-position-priority", type unsigned int static const Property::Index SELECT_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "select-button-position-priority", type unsigned int static const Property::Index SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "select-all-button-position-priority", type unsigned int static const Property::Index CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "clipboard-button-position-priority", type unsigned int - static const Property::Index POP_UP_OFFSET_FROM_TEXT_PROPERTY; // Property, name "popup-offset-from-text", type VECTOR4 + static const Property::Index CURSOR_COLOR_PROPERTY; // Property, name "cursor-color", type VECTOR4 /** @} */ @@ -287,6 +286,7 @@ public: void SetGrabHandleImage( Image image ); /** + * Depreciated API. * @brief Set the image to be used for the regular left to right cursor. * * @pre The text input actor has been initialised. -- 2.7.4