From: Bowon Ryu Date: Thu, 18 Jan 2024 09:19:17 +0000 (+0900) Subject: [Tizen] Fix decorator color update issue X-Git-Tag: accepted/tizen/8.0/unified/20240125.160903~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F22%2F304622%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Fix decorator color update issue After a text decorator is created, changing the related color causes only the property to be changed. This patch fixes an issue where the actual actor's color was not changed. Change-Id: I4778d9a51fa0cd128e24a4362354cebb81b2b2e9 Signed-off-by: Bowon Ryu --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 5f33099..202ca99 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -170,8 +170,8 @@ static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField) textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap); textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap); textField.SetProperty(Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap); - textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap); - textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap); + textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, "image.png"); + textField.SetProperty(Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image.png"); } /* @@ -5820,4 +5820,71 @@ int utcDaliTextFieldGetTextBoundingRectangle(void) TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle); END_TEST; +} + + +int utcDaliTextFieldDecoratorColor(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldDecoratorColor"); + TextField textField = TextField::New(); + DALI_TEST_CHECK(textField); + LoadMarkerImages(application, textField); + application.GetScene().Add(textField); + + // Render and notify + application.SendNotification(); + application.Render(); + + textField.SetProperty(TextField::Property::TEXT, "العالم Hello"); + textField.SetProperty(TextField::Property::POINT_SIZE, 10.f); + textField.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f)); + textField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + textField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE); + + application.SendNotification(); + application.Render(); + + textField.SetKeyInputFocus(); + + application.SendNotification(); + application.Render(); + + // Create a tap event to touch the text field. + TestGenerateTap(application, 1.0f, 25.0f, 100); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Double tap to select a word. + TestGenerateTap(application, 1.0f, 25.0f, 200); + + application.SendNotification(); + application.Render(); + + // At this point, the text decorator's primary/secondary cursor, grab/left/right handle and highlight actor were all created. + // Check some properties for coverage. + textField.SetProperty(TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::PRIMARY_CURSOR_COLOR), Color::RED, TEST_LOCATION); + + textField.SetProperty(TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::SECONDARY_CURSOR_COLOR), Color::BLUE, TEST_LOCATION); + + textField.SetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN); + DALI_TEST_EQUALS(textField.GetProperty(DevelTextField::Property::GRAB_HANDLE_COLOR), Color::GREEN, TEST_LOCATION); + + textField.SetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::SELECTION_HIGHLIGHT_COLOR), Color::GREEN, TEST_LOCATION); + + textField.SetProperty(TextField::Property::CURSOR_WIDTH, 3); + DALI_TEST_EQUALS(textField.GetProperty(TextField::Property::CURSOR_WIDTH), 3, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + END_TEST; } \ No newline at end of file diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 5ab098a..cda3996 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -2056,6 +2056,15 @@ const float Decorator::GetGlyphOffset(Cursor cursor) const void Decorator::SetCursorColor(Cursor cursor, const Dali::Vector4& color) { mImpl->mCursor[cursor].color = color; + + if(cursor == PRIMARY_CURSOR && mImpl->mPrimaryCursor) + { + mImpl->mPrimaryCursor.SetBackgroundColor(color); + } + else if(cursor == SECONDARY_CURSOR && mImpl->mSecondaryCursor) + { + mImpl->mSecondaryCursor.SetBackgroundColor(color); + } } const Dali::Vector4& Decorator::GetColor(Cursor cursor) const @@ -2116,6 +2125,15 @@ float Decorator::GetCursorBlinkDuration() const void Decorator::SetCursorWidth(int width) { mImpl->mCursorWidth = static_cast(width); + + if(mImpl->mPrimaryCursorVisible && mImpl->mPrimaryCursor) + { + mImpl->mPrimaryCursor.SetProperty(Actor::Property::SIZE, Size(mImpl->mCursorWidth, mImpl->mCursor[PRIMARY_CURSOR].cursorHeight)); + } + if(mImpl->mSecondaryCursorVisible && mImpl->mSecondaryCursor) + { + mImpl->mSecondaryCursor.SetProperty(Actor::Property::SIZE, Size(mImpl->mCursorWidth, mImpl->mCursor[SECONDARY_CURSOR].cursorHeight)); + } } int Decorator::GetCursorWidth() const @@ -2193,6 +2211,23 @@ const std::string& Decorator::GetHandleImage(HandleType handleType, HandleImageT void Decorator::SetHandleColor(const Vector4& color) { mImpl->mHandleColor = color; + + Impl::HandleImpl& grabHandle = mImpl->mHandle[GRAB_HANDLE]; + Impl::HandleImpl& primaryHandle = mImpl->mHandle[LEFT_SELECTION_HANDLE]; + Impl::HandleImpl& secondaryHandle = mImpl->mHandle[RIGHT_SELECTION_HANDLE]; + + if(grabHandle.actor) + { + grabHandle.actor.SetProperty(Actor::Property::COLOR, color); + } + if(primaryHandle.actor) + { + primaryHandle.actor.SetProperty(Actor::Property::COLOR, color); + } + if(secondaryHandle.actor) + { + secondaryHandle.actor.SetProperty(Actor::Property::COLOR, color); + } } const Vector4& Decorator::GetHandleColor() const @@ -2279,6 +2314,11 @@ void Decorator::ResizeHighlightQuads(unsigned int numberOfQuads) void Decorator::SetHighlightColor(const Vector4& color) { mImpl->mHighlightColor = color; + + if(mImpl->mHighlightActor) + { + mImpl->mHighlightActor.SetProperty(Actor::Property::COLOR, color); + } } const Vector4& Decorator::GetHighlightColor() const