From 7a8baa8fc4f88808a1855d0eeb187039a0a62151 Mon Sep 17 00:00:00 2001 From: liukaii Date: Tue, 17 Oct 2023 20:29:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E5=B1=82=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=94=9F=E6=95=88=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liukaii --- .../pattern/hyperlink/hyperlink_model_ng.cpp | 5 ++--- .../components_ng/pattern/image/image_model_ng.cpp | 11 +++++++++++ .../components_ng/pattern/image/image_pattern.cpp | 10 ---------- .../pattern/rich_editor/rich_editor_model_ng.cpp | 5 ++--- .../core/components_ng/pattern/text/text_model_ng.cpp | 5 +++++ .../core/components_ng/pattern/text/text_pattern.cpp | 3 --- .../pattern/text_field/text_field_model_ng.cpp | 3 ++- frameworks/core/pipeline/pipeline_base.h | 11 +++++++++++ 8 files changed, 33 insertions(+), 20 deletions(-) diff --git a/frameworks/core/components_ng/pattern/hyperlink/hyperlink_model_ng.cpp b/frameworks/core/components_ng/pattern/hyperlink/hyperlink_model_ng.cpp index 08bd29ca546..1ca0a8cd37f 100644 --- a/frameworks/core/components_ng/pattern/hyperlink/hyperlink_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/hyperlink/hyperlink_model_ng.cpp @@ -33,9 +33,8 @@ void HyperlinkModelNG::Create(const std::string& address, const std::string& con auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - SetDraggable(theme->GetDraggable()); + auto draggable = pipeline->GetDraggable(); + SetDraggable(draggable); } void HyperlinkModelNG::SetColor(const Color& value) diff --git a/frameworks/core/components_ng/pattern/image/image_model_ng.cpp b/frameworks/core/components_ng/pattern/image/image_model_ng.cpp index 0dd85211734..97c80c4b193 100644 --- a/frameworks/core/components_ng/pattern/image/image_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/image/image_model_ng.cpp @@ -51,6 +51,17 @@ void ImageModelNG::Create( auto frameNode = FrameNode::GetOrCreateFrameNode( V2::IMAGE_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(); }); stack->Push(frameNode); + + // set draggable for framenode + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto draggable = pipeline->GetDraggable(); + if (draggable && !frameNode->IsDraggable()) { + auto gestureHub = frameNode->GetOrCreateGestureEventHub(); + CHECK_NULL_VOID(gestureHub); + gestureHub->InitDragDropEvent(); + } + frameNode->SetDraggable(draggable); ACE_UPDATE_LAYOUT_PROPERTY( ImageLayoutProperty, ImageSourceInfo, CreateSourceInfo(src, pixMap, bundleName, moduleName)); } diff --git a/frameworks/core/components_ng/pattern/image/image_pattern.cpp b/frameworks/core/components_ng/pattern/image/image_pattern.cpp index 877562e8184..01ba0ee0030 100644 --- a/frameworks/core/components_ng/pattern/image/image_pattern.cpp +++ b/frameworks/core/components_ng/pattern/image/image_pattern.cpp @@ -484,16 +484,6 @@ void ImagePattern::OnAttachToFrameNode() CHECK_NULL_VOID(pipeline); pipeline->AddNodesToNotifyMemoryLevel(host->GetId()); pipeline->AddWindowStateChangedCallback(host->GetId()); - // set draggable for framenode - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - auto draggable = theme->GetDraggable(); - if (draggable && !host->IsDraggable()) { - auto gestureHub = host->GetOrCreateGestureEventHub(); - CHECK_NULL_VOID(gestureHub); - gestureHub->InitDragDropEvent(); - } - host->SetDraggable(draggable); } void ImagePattern::OnDetachFromFrameNode(FrameNode* frameNode) diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_ng.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_ng.cpp index 7d31f831589..6d06539ff74 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_ng.cpp @@ -42,9 +42,8 @@ void RichEditorModelNG::Create() auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - SetDraggable(theme->GetDraggable()); + auto draggable = pipeline->GetDraggable(); + SetDraggable(draggable); } void RichEditorModelNG::SetDraggable(bool draggable) diff --git a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp index 10ab760b007..c8508ca6805 100644 --- a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp @@ -34,6 +34,11 @@ void TextModelNG::Create(const std::string& content) FrameNode::GetOrCreateFrameNode(V2::TEXT_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(); }); stack->Push(frameNode); + // set draggable for framenode + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto draggable = pipeline->GetDraggable(); + frameNode->SetDraggable(draggable); ACE_UPDATE_LAYOUT_PROPERTY(TextLayoutProperty, Content, content); } diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index 8f7e0a01833..736853f6171 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -61,9 +61,6 @@ void TextPattern::OnAttachToFrameNode() } InitSurfaceChangedCallback(); InitSurfacePositionChangedCallback(); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - host->SetDraggable(theme->GetDraggable()); auto textLayoutProperty = GetLayoutProperty(); textLayoutProperty->UpdateTextAlign(TextAlign::START); textLayoutProperty->UpdateAlignment(Alignment::CENTER_LEFT); diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp index b798345a269..f3938ca6836 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp @@ -81,7 +81,8 @@ void TextFieldModelNG::CreateNode( AddDragFrameNodeToManager(); PaddingProperty paddings; ProcessDefaultPadding(paddings); - SetDraggable(textFieldTheme->GetDraggable()); + auto draggable = pipeline->GetDraggable(); + SetDraggable(draggable); ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Padding, paddings); } diff --git a/frameworks/core/pipeline/pipeline_base.h b/frameworks/core/pipeline/pipeline_base.h index 0bfcaac941e..650976927fc 100644 --- a/frameworks/core/pipeline/pipeline_base.h +++ b/frameworks/core/pipeline/pipeline_base.h @@ -503,6 +503,17 @@ public: return {}; } + template + bool GetDraggable() + { + if (IsJsCard()) { + return false; + } + auto theme = GetTheme(); + CHECK_NULL_RETURN(theme, false); + return theme->GetDraggable(); + } + const RefPtr& GetTextFieldManager() { return textFieldManager_; -- Gitee