!38484 make component consume children adjustment

Merge pull request !38484 from xiexiyun/consume_adjust_child
This commit is contained in:
openharmony_ci 2024-07-26 05:57:16 +00:00 committed by Gitee
commit e31584e575
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 35 additions and 30 deletions

View File

@ -255,24 +255,9 @@ void LayoutWrapper::ExpandSafeArea()
auto frame = geometryNode->GetFrameRect() + parentGlobalOffset + keyboardAdjust + parentAdjust.GetOffset(); auto frame = geometryNode->GetFrameRect() + parentGlobalOffset + keyboardAdjust + parentAdjust.GetOffset();
auto originGlobal = frame; auto originGlobal = frame;
auto safeArea = pipeline->GetSafeAreaManager()->GetCombinedSafeArea(*opts); ExpandHelper(opts, frame);
if ((opts->edges & SAFE_AREA_EDGE_START) && safeArea.left_.IsOverlapped(frame.Left())) {
frame.SetWidth(frame.Width() + frame.Left() - safeArea.left_.start);
frame.SetLeft(safeArea.left_.start);
}
if ((opts->edges & SAFE_AREA_EDGE_TOP) && safeArea.top_.IsOverlapped(frame.Top())) {
frame.SetHeight(frame.Height() + frame.Top() - safeArea.top_.start);
frame.SetTop(safeArea.top_.start);
}
if ((opts->edges & SAFE_AREA_EDGE_END) && safeArea.right_.IsOverlapped(frame.Right())) { AdjustFixedSizeNode(frame);
frame.SetWidth(frame.Width() + (safeArea.right_.end - frame.Right()));
}
if ((opts->edges & SAFE_AREA_EDGE_BOTTOM) && safeArea.bottom_.IsOverlapped(frame.Bottom())) {
frame.SetHeight(frame.Height() + (safeArea.bottom_.end - frame.Bottom()));
}
AdjustNotExpandNode(frame);
auto parent = host->GetAncestorNodeOfFrame(); auto parent = host->GetAncestorNodeOfFrame();
auto parentScrollable = (parent && parent->GetPattern<ScrollablePattern>()); auto parentScrollable = (parent && parent->GetPattern<ScrollablePattern>());
// restore to local offset // restore to local offset
@ -291,7 +276,30 @@ void LayoutWrapper::ExpandSafeArea()
renderContext->UpdatePaintRect(frame + geometryNode->GetPixelGridRoundRect() - geometryNode->GetFrameRect()); renderContext->UpdatePaintRect(frame + geometryNode->GetPixelGridRoundRect() - geometryNode->GetFrameRect());
} }
void LayoutWrapper::AdjustNotExpandNode(RectF& frame) void LayoutWrapper::ExpandHelper(const std::unique_ptr<SafeAreaExpandOpts>& opts, RectF& frame)
{
CHECK_NULL_VOID(opts);
auto pipeline = PipelineContext::GetCurrentContext();
CHECK_NULL_VOID(pipeline);
auto safeArea = pipeline->GetSafeAreaManager()->GetCombinedSafeArea(*opts);
if ((opts->edges & SAFE_AREA_EDGE_START) && safeArea.left_.IsOverlapped(frame.Left())) {
frame.SetWidth(frame.Width() + frame.Left() - safeArea.left_.start);
frame.SetLeft(safeArea.left_.start);
}
if ((opts->edges & SAFE_AREA_EDGE_TOP) && safeArea.top_.IsOverlapped(frame.Top())) {
frame.SetHeight(frame.Height() + frame.Top() - safeArea.top_.start);
frame.SetTop(safeArea.top_.start);
}
if ((opts->edges & SAFE_AREA_EDGE_END) && safeArea.right_.IsOverlapped(frame.Right())) {
frame.SetWidth(frame.Width() + (safeArea.right_.end - frame.Right()));
}
if ((opts->edges & SAFE_AREA_EDGE_BOTTOM) && safeArea.bottom_.IsOverlapped(frame.Bottom())) {
frame.SetHeight(frame.Height() + (safeArea.bottom_.end - frame.Bottom()));
}
}
void LayoutWrapper::AdjustFixedSizeNode(RectF& frame)
{ {
// reset if User has fixed size // reset if User has fixed size
auto layoutProperty = GetLayoutProperty(); auto layoutProperty = GetLayoutProperty();
@ -449,6 +457,12 @@ void LayoutWrapper::GetAccumulatedSafeAreaExpandHelper(RectF& adjustingRect, Exp
void LayoutWrapper::AdjustChildren(const OffsetF& offset, bool parentScrollable) void LayoutWrapper::AdjustChildren(const OffsetF& offset, bool parentScrollable)
{ {
auto host = GetHostNode();
CHECK_NULL_VOID(host);
auto pattern = host->GetPattern();
if (pattern && pattern->ConsumeChildrenAdjustment(offset)) {
return;
}
for (const auto& childUI : GetHostNode()->GetChildren()) { for (const auto& childUI : GetHostNode()->GetChildren()) {
AdjustChild(childUI, offset, parentScrollable); AdjustChild(childUI, offset, parentScrollable);
} }

View File

@ -227,7 +227,8 @@ public:
// expand the SafeArea of expansive nodes, which are previously recorded during Layout traversal // expand the SafeArea of expansive nodes, which are previously recorded during Layout traversal
void ExpandSafeArea(); void ExpandSafeArea();
void AdjustNotExpandNode(); void AdjustNotExpandNode();
void AdjustNotExpandNode(RectF& frame); void AdjustFixedSizeNode(RectF& frame);
void ExpandHelper(const std::unique_ptr<SafeAreaExpandOpts>& opts, RectF& frame);
ExpandEdges GetAccumulatedSafeAreaExpand(bool includingSelf = false); ExpandEdges GetAccumulatedSafeAreaExpand(bool includingSelf = false);
void ResetSafeAreaPadding(); void ResetSafeAreaPadding();

View File

@ -52,11 +52,6 @@ public:
return false; return false;
} }
bool StopExpandMark() override
{
return true;
}
bool IsNeedPercent() const override bool IsNeedPercent() const override
{ {
return true; return true;

View File

@ -85,7 +85,7 @@ public:
return true; return true;
} }
virtual bool StopExpandMark() virtual bool ConsumeChildrenAdjustment(const OffsetF& /* offset */)
{ {
return false; return false;
} }

View File

@ -708,11 +708,6 @@ protected:
void Register2DragDropManager(); void Register2DragDropManager();
bool StopExpandMark() override
{
return true;
}
private: private:
virtual void OnScrollEndCallback() {}; virtual void OnScrollEndCallback() {};