From 94503875e37bf40da97f1f81079dda3f7ff1e7bc Mon Sep 17 00:00:00 2001 From: lanyill Date: Wed, 22 Feb 2023 22:57:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DLine=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E8=AE=BE=E7=BD=AE=E5=AE=BD=E9=AB=98=E6=97=B6=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lanyill --- .../pattern/shape/line_layout_algorithm.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp index 8866aae54fc..fcae7ecd32d 100644 --- a/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp @@ -31,17 +31,23 @@ std::optional LineLayoutAlgorithm::MeasureContent( CHECK_NULL_RETURN(host, std::nullopt); auto paintProperty = host->GetPaintProperty(); CHECK_NULL_RETURN(paintProperty, std::nullopt); - + auto strokewidth = paintProperty->GetStrokeWidth()->ConvertToPx(); PointF startPoint = PointF(paintProperty->GetStartPointValue().first.ConvertToPx(), paintProperty->GetStartPointValue().second.ConvertToPx()); PointF endPoint = PointF( paintProperty->GetEndPointValue().first.ConvertToPx(), paintProperty->GetEndPointValue().second.ConvertToPx()); - auto width = startPoint.GetX() > endPoint.GetX() ? (startPoint.GetX() - endPoint.GetX()) : (endPoint.GetX() - startPoint.GetX()); auto height = startPoint.GetY() > endPoint.GetY() ? (startPoint.GetY() - endPoint.GetY()) : (endPoint.GetY() - startPoint.GetY()); + if (strokewidth > width) { + width = strokewidth; + } + + if (strokewidth > height) { + height = strokewidth; + } return SizeF(width, height); } } // namespace OHOS::Ace::NG -- Gitee From 739a364fda51198d851d06333a4e3e82d661a676 Mon Sep 17 00:00:00 2001 From: lanyill Date: Thu, 23 Feb 2023 09:53:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DLine=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E8=AE=BE=E7=BD=AE=E5=AE=BD=E9=AB=98=E6=97=B6=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lanyill --- .../pattern/shape/line_layout_algorithm.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp index fcae7ecd32d..93f97c4ea3e 100644 --- a/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/shape/line_layout_algorithm.cpp @@ -19,6 +19,10 @@ #include "core/components_ng/pattern/shape/line_paint_property.h" namespace OHOS::Ace::NG { +namespace { +const Dimension DEFAULT_STROKE_WIDTH(1, DimensionUnit::PX); +} // namespace + std::optional LineLayoutAlgorithm::MeasureContent( const LayoutConstraintF& contentConstraint, LayoutWrapper* layoutWrapper) { @@ -31,7 +35,11 @@ std::optional LineLayoutAlgorithm::MeasureContent( CHECK_NULL_RETURN(host, std::nullopt); auto paintProperty = host->GetPaintProperty(); CHECK_NULL_RETURN(paintProperty, std::nullopt); - auto strokewidth = paintProperty->GetStrokeWidth()->ConvertToPx(); + auto strokewidth = static_cast(paintProperty->GetStrokeWidthValue(DEFAULT_STROKE_WIDTH).ConvertToPx()); + if (paintProperty->HasStrokeWidth()) { + strokewidth = paintProperty->GetStrokeWidthValue().ConvertToPx(); + } + PointF startPoint = PointF(paintProperty->GetStartPointValue().first.ConvertToPx(), paintProperty->GetStartPointValue().second.ConvertToPx()); PointF endPoint = PointF( @@ -40,11 +48,9 @@ std::optional LineLayoutAlgorithm::MeasureContent( : (endPoint.GetX() - startPoint.GetX()); auto height = startPoint.GetY() > endPoint.GetY() ? (startPoint.GetY() - endPoint.GetY()) : (endPoint.GetY() - startPoint.GetY()); - if (strokewidth > width) { width = strokewidth; } - if (strokewidth > height) { height = strokewidth; } -- Gitee