From 4970d25b844ed394c63835c07e27adbc8ba01e77 Mon Sep 17 00:00:00 2001 From: Baranov Evgeny Date: Tue, 24 Jun 2025 13:44:47 +0300 Subject: [PATCH 1/3] inner_kit path support Signed-off-by: Baranov Evgeny --- build/libace.map | 1 + .../pattern/shape/path_model_ng.cpp | 9 +++-- .../pattern/shape/path_model_ng.h | 1 + interfaces/inner_api/ace_kit/BUILD.gn | 1 + .../ace_kit/include/ui/view/components/path.h | 38 +++++++++++++++++++ .../ace_kit/src/view/components/path.cpp | 32 ++++++++++++++++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 interfaces/inner_api/ace_kit/include/ui/view/components/path.h create mode 100644 interfaces/inner_api/ace_kit/src/view/components/path.cpp diff --git a/build/libace.map b/build/libace.map index c9a77f58ce1..c8255fe1725 100644 --- a/build/libace.map +++ b/build/libace.map @@ -474,6 +474,7 @@ OHOS::Ace::Kit::View::*; OHOS::Ace::Kit::Column::*; OHOS::Ace::Kit::CustomNode::*; + OHOS::Ace::Kit::Path::*; OHOS::Ace::Kit::Text::*; OHOS::Ace::Kit::Tabs::*; OHOS::Ace::NG::NavigationStack::*; diff --git a/frameworks/core/components_ng/pattern/shape/path_model_ng.cpp b/frameworks/core/components_ng/pattern/shape/path_model_ng.cpp index 66f711caa09..bfb5bdeb707 100644 --- a/frameworks/core/components_ng/pattern/shape/path_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/shape/path_model_ng.cpp @@ -29,10 +29,13 @@ void PathModelNG::Create() { auto* stack = ViewStackProcessor::GetInstance(); auto nodeId = stack->ClaimNodeId(); + stack->Push(CreateFrameNode(nodeId)); +} + +RefPtr PathModelNG::CreateFrameNode(int32_t nodeId) +{ ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::PATH_ETS_TAG, nodeId); - auto frameNode = - FrameNode::GetOrCreateFrameNode(V2::PATH_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(); }); - stack->Push(frameNode); + return FrameNode::GetOrCreateFrameNode(V2::PATH_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(); }); } void PathModelNG::SetCommands(const std::string& pathCmd) diff --git a/frameworks/core/components_ng/pattern/shape/path_model_ng.h b/frameworks/core/components_ng/pattern/shape/path_model_ng.h index 09c6abcf88f..475bcb7b1ce 100644 --- a/frameworks/core/components_ng/pattern/shape/path_model_ng.h +++ b/frameworks/core/components_ng/pattern/shape/path_model_ng.h @@ -24,6 +24,7 @@ namespace OHOS::Ace::NG { class ACE_EXPORT PathModelNG : public OHOS::Ace::PathModel { public: void Create() override; + static RefPtr CreateFrameNode(int32_t nodeId); void SetCommands(const std::string& pathCmd) override; static void SetCommands(FrameNode* frameNode, const std::string& pathCmd); diff --git a/interfaces/inner_api/ace_kit/BUILD.gn b/interfaces/inner_api/ace_kit/BUILD.gn index 8e6cc5efb50..08180548b99 100644 --- a/interfaces/inner_api/ace_kit/BUILD.gn +++ b/interfaces/inner_api/ace_kit/BUILD.gn @@ -45,6 +45,7 @@ ohos_source_set("ace_kit") { "src/view/components/column.cpp", "src/view/components/custom_node.cpp", "src/view/components/menu_view.cpp", + "src/view/components/path.cpp", "src/view/components/tabs.cpp", "src/view/components/text.cpp", "src/view/draw/content_modifier.cpp", diff --git a/interfaces/inner_api/ace_kit/include/ui/view/components/path.h b/interfaces/inner_api/ace_kit/include/ui/view/components/path.h new file mode 100644 index 00000000000..61f12180117 --- /dev/null +++ b/interfaces/inner_api/ace_kit/include/ui/view/components/path.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_PATH_H +#define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_PATH_H + +#include "ui/base/ace_type.h" +#include "ui/base/macros.h" + +namespace OHOS::Ace::Kit { + +class FrameNode; + +class ACE_FORCE_EXPORT Path : public AceType { + DECLARE_ACE_TYPE(Path, AceType); + +public: + Path() = default; + ~Path() override = default; + + static RefPtr Create(); +}; + +} // namespace OHOS::Ace::Kit + +#endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_PATH_H diff --git a/interfaces/inner_api/ace_kit/src/view/components/path.cpp b/interfaces/inner_api/ace_kit/src/view/components/path.cpp new file mode 100644 index 00000000000..74832503357 --- /dev/null +++ b/interfaces/inner_api/ace_kit/src/view/components/path.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "interfaces/inner_api/ace_kit/include/ui/view/components/path.h" + +#include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h" +#include "ui/view_stack/view_stack_processor.h" +#include "core/components_ng/pattern/shape/path_model_ng.h" + +namespace OHOS::Ace::Kit { + +RefPtr Path::Create() +{ + int32_t nodeId = ViewStackProcessor::ClaimNodeId(); + auto aceNode = NG::PathModelNG::CreateFrameNode(nodeId); + CHECK_NULL_RETURN(aceNode, nullptr); + return AceType::MakeRefPtr(aceNode); +} + +} // namespace OHOS::Ace::Kit -- Gitee From a9bc2df8fd0ec17e99aa6368c082f82a56c15051 Mon Sep 17 00:00:00 2001 From: Baranov Evgeny Date: Wed, 25 Jun 2025 10:29:10 +0300 Subject: [PATCH 2/3] innerkit path unittest Signed-off-by: Baranov Evgeny --- test/unittest/interfaces/ace_kit/BUILD.gn | 1 + .../unittest/interfaces/ace_kit/path_test.cpp | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/unittest/interfaces/ace_kit/path_test.cpp diff --git a/test/unittest/interfaces/ace_kit/BUILD.gn b/test/unittest/interfaces/ace_kit/BUILD.gn index fd180dd31de..e08b52d8fb2 100644 --- a/test/unittest/interfaces/ace_kit/BUILD.gn +++ b/test/unittest/interfaces/ace_kit/BUILD.gn @@ -174,6 +174,7 @@ ohos_unittest("ace_kit_test") { "content_modifier_test.cpp", "dimension_test.cpp", "frame_node_test.cpp", + "path_test.cpp", "property_test.cpp", "resource_parser_test.cpp", "view_stack_processor_test.cpp", diff --git a/test/unittest/interfaces/ace_kit/path_test.cpp b/test/unittest/interfaces/ace_kit/path_test.cpp new file mode 100644 index 00000000000..3720022f6cd --- /dev/null +++ b/test/unittest/interfaces/ace_kit/path_test.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "interfaces/inner_api/ace_kit/include/view/components/path.h" +#include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Ace::Kit { +class PathTest : public testing::Test {}; + +/** + * @tc.name: PathTest001 + * @tc.desc: + * @tc.type: FUNC + */ +HWTEST_F(PathTest, PathTest001, TestSize.Level1) +{ + const std::string tag = "Path"; + auto frameNode = Path::Create(); + EXPECT_NE(frameNode, nullptr); + auto frameNodeImpl = AceType::DynamicCast(frameNode); + ASSERT_TRUE(frameNodeImpl); + EXPECT_EQ(frameNodeImpl->GetTag(), tag); +} + +} // namespace OHOS::Ace::Kit -- Gitee From 07272696da96a17e8360c9f8340c1f49f63bdd9f Mon Sep 17 00:00:00 2001 From: Baranov Evgeny Date: Wed, 25 Jun 2025 12:09:40 +0300 Subject: [PATCH 3/3] move to shape and fix includes Signed-off-by: Baranov Evgeny --- .../ace_kit/include/ui/view/components/{ => shape}/path.h | 6 +++--- interfaces/inner_api/ace_kit/src/view/components/path.cpp | 2 +- test/unittest/interfaces/ace_kit/BUILD.gn | 1 + test/unittest/interfaces/ace_kit/path_test.cpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) rename interfaces/inner_api/ace_kit/include/ui/view/components/{ => shape}/path.h (93%) diff --git a/interfaces/inner_api/ace_kit/include/ui/view/components/path.h b/interfaces/inner_api/ace_kit/include/ui/view/components/shape/path.h similarity index 93% rename from interfaces/inner_api/ace_kit/include/ui/view/components/path.h rename to interfaces/inner_api/ace_kit/include/ui/view/components/shape/path.h index 61f12180117..afcd3de6ced 100644 --- a/interfaces/inner_api/ace_kit/include/ui/view/components/path.h +++ b/interfaces/inner_api/ace_kit/include/ui/view/components/shape/path.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_PATH_H -#define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_PATH_H +#ifndef FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_SHAPE_PATH_H +#define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_SHAPE_PATH_H #include "ui/base/ace_type.h" #include "ui/base/macros.h" @@ -35,4 +35,4 @@ public: } // namespace OHOS::Ace::Kit -#endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_PATH_H +#endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_COMPONENTS_SHAPE_PATH_H diff --git a/interfaces/inner_api/ace_kit/src/view/components/path.cpp b/interfaces/inner_api/ace_kit/src/view/components/path.cpp index 74832503357..73064c67061 100644 --- a/interfaces/inner_api/ace_kit/src/view/components/path.cpp +++ b/interfaces/inner_api/ace_kit/src/view/components/path.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "interfaces/inner_api/ace_kit/include/ui/view/components/path.h" +#include "ui/view/components/shape/path.h" #include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h" #include "ui/view_stack/view_stack_processor.h" diff --git a/test/unittest/interfaces/ace_kit/BUILD.gn b/test/unittest/interfaces/ace_kit/BUILD.gn index e08b52d8fb2..4992c4bbeb1 100644 --- a/test/unittest/interfaces/ace_kit/BUILD.gn +++ b/test/unittest/interfaces/ace_kit/BUILD.gn @@ -145,6 +145,7 @@ ohos_unittest("ace_kit_test") { "$ace_root/interfaces/inner_api/ace_kit/src/resource/resource_parser.cpp", "$ace_root/interfaces/inner_api/ace_kit/src/utils/measure_utils.cpp", "$ace_root/interfaces/inner_api/ace_kit/src/view/components/column.cpp", + "$ace_root/interfaces/inner_api/ace_kit/src/view/components/path.cpp", "$ace_root/interfaces/inner_api/ace_kit/src/view/components/menu_view.cpp", "$ace_root/interfaces/inner_api/ace_kit/src/view/components/text.cpp", "$ace_root/interfaces/inner_api/ace_kit/src/view/draw/content_modifier.cpp", diff --git a/test/unittest/interfaces/ace_kit/path_test.cpp b/test/unittest/interfaces/ace_kit/path_test.cpp index 3720022f6cd..35c7b70a22f 100644 --- a/test/unittest/interfaces/ace_kit/path_test.cpp +++ b/test/unittest/interfaces/ace_kit/path_test.cpp @@ -14,7 +14,7 @@ */ #include "gtest/gtest.h" -#include "interfaces/inner_api/ace_kit/include/view/components/path.h" +#include "ui/view/components/shape/path.h" #include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h" using namespace testing; -- Gitee