From: joogab.yun Date: Tue, 27 Jul 2021 18:40:45 +0000 (+0900) Subject: Set TapGesture only if there is an anchor. X-Git-Tag: dali_2.0.38~6^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=91a31a5bdf35ebea5818c3809467b6fb74a547a2 Set TapGesture only if there is an anchor. Change-Id: I3787911cbedda12b5d781e8de6b16902c23186e7 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index e91c2b8..f4655ab 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -1788,7 +1788,34 @@ int UtcDaliToolkitTextlabelAnchorClicked(void) application.Render(); // Create a tap event to touch the text label. - TestGenerateTap(application, 5.0f, 25.0f); + TestGenerateTap(application, 5.0f, 25.0f, 100); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(gAnchorClickedCallBackCalled); + DALI_TEST_CHECK(anchorClickedSignal); + + // reset + gAnchorClickedCallBackCalled = false; + anchorClickedSignal = false; + label.SetProperty(TextLabel::Property::TEXT, ""); + label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false); + + application.SendNotification(); + application.Render(); + + // sets anchor text + label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); + label.SetProperty(TextLabel::Property::TEXT, "TIZEN"); + label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f)); + label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + application.SendNotification(); + application.Render(); + + // Create a tap event to touch the text label. + TestGenerateTap(application, 5.0f, 25.0f, 200); application.SendNotification(); application.Render(); @@ -1798,7 +1825,7 @@ int UtcDaliToolkitTextlabelAnchorClicked(void) gAnchorClickedCallBackNotCalled = true; // Tap the outside of anchor, callback should not be called. - TestGenerateTap(application, 150.f, 100.f); + TestGenerateTap(application, 150.f, 100.f, 300); application.SendNotification(); application.Render(); 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 263b879..21e13c8 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -266,6 +266,17 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro case Toolkit::TextLabel::Property::TEXT: { impl.mController->SetText(value.Get()); + + if(impl.mController->HasAnchors()) + { + // Forward input events to controller + impl.EnableGestureDetection(static_cast(GestureType::TAP)); + } + else + { + impl.DisableGestureDetection(static_cast(GestureType::TAP)); + } + break; } case Toolkit::TextLabel::Property::FONT_FAMILY: @@ -318,6 +329,16 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro { const bool enableMarkup = value.Get(); impl.mController->SetMarkupProcessorEnabled(enableMarkup); + + if(impl.mController->HasAnchors()) + { + // Forward input events to controller + impl.EnableGestureDetection(static_cast(GestureType::TAP)); + } + else + { + impl.DisableGestureDetection(static_cast(GestureType::TAP)); + } break; } case Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL: @@ -804,10 +825,6 @@ void TextLabel::OnInitialize() self.LayoutDirectionChangedSignal().Connect(this, &TextLabel::OnLayoutDirectionChanged); - // Forward input events to controller - EnableGestureDetection(static_cast(GestureType::TAP)); - GetTapGestureDetector().SetMaximumTapsRequired(1); - Layout::Engine& engine = mController->GetLayoutEngine(); engine.SetCursorWidth(0u); // Do not layout space for the cursor. @@ -858,9 +875,6 @@ void TextLabel::OnTap(const TapGesture& gesture) padding = Self().GetProperty(Toolkit::Control::Property::PADDING); const Vector2& localPoint = gesture.GetLocalPoint(); mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top); - - // parents can also listen for tap gesture events - Dali::DevelActor::SetNeedGesturePropagation(Self(), true); } void TextLabel::AnchorClicked(const std::string& href) diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 304276c..7e0410d 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -136,6 +136,11 @@ bool Controller::IsMarkupProcessorEnabled() const return mImpl->mMarkupProcessorEnabled; } +bool Controller::HasAnchors() const +{ + return (mImpl->mMarkupProcessorEnabled && mImpl->mModel->mLogicalModel->mAnchors.Count() && mImpl->IsShowingRealText()); +} + void Controller::SetAutoScrollEnabled(bool enable) { DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable) ? "true" : "false", (mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX) ? "true" : "false", this); diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 73f132b..63a77a4 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -231,6 +231,13 @@ public: // Configure the text controller. bool IsMarkupProcessorEnabled() const; /** + * @brief Retrieves whether the current text contains anchors. + * + * @return @e true if the current text contains anchors. @e false. + */ + bool HasAnchors() const; + + /** * @brief Enables/disables the auto text scrolling * * By default is disabled.