mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 23:21:05 +00:00
!37904 修复:Section waterFlow布局左右margin不生效
Merge pull request !37904 from 周沺耳/sections
This commit is contained in:
commit
19213ffc0d
@ -26,6 +26,7 @@
|
||||
#include "core/components_ng/pattern/waterflow/layout/water_flow_layout_utils.h"
|
||||
#include "core/components_ng/pattern/waterflow/water_flow_layout_property.h"
|
||||
#include "core/components_ng/pattern/waterflow/water_flow_pattern.h"
|
||||
#include "core/components_ng/property/measure_property.h"
|
||||
#include "core/components_ng/property/measure_utils.h"
|
||||
#include "core/components_ng/property/templates_parser.h"
|
||||
|
||||
@ -594,15 +595,27 @@ float WaterFlowLayoutSW::MeasureChild(const RefPtr<WaterFlowLayoutProperty>& pro
|
||||
return child->GetGeometryNode()->GetMarginFrameSize().MainSize(info_->axis_);
|
||||
}
|
||||
|
||||
namespace {
|
||||
float MarginStart(Axis axis, const PaddingPropertyF& margin)
|
||||
{
|
||||
return (axis == Axis::VERTICAL ? margin.left : margin.top).value_or(0.0f);
|
||||
}
|
||||
float MarginEnd(Axis axis, const PaddingPropertyF& margin)
|
||||
{
|
||||
return (axis == Axis::VERTICAL ? margin.right : margin.bottom).value_or(0.0f);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void WaterFlowLayoutSW::LayoutSection(
|
||||
size_t idx, const OffsetF& paddingOffset, float selfCrossLen, bool reverse, bool rtl)
|
||||
{
|
||||
float crossPos = rtl ? selfCrossLen + mainGaps_[idx] : 0.0f;
|
||||
const auto& margin = info_->margins_[idx];
|
||||
float crossPos = rtl ? selfCrossLen + mainGaps_[idx] - MarginEnd(axis_, margin) : MarginStart(axis_, margin);
|
||||
for (size_t i = 0; i < info_->lanes_[idx].size(); ++i) {
|
||||
if (rtl) {
|
||||
crossPos -= itemsCrossSize_[idx][i] + crossGaps_[idx];
|
||||
}
|
||||
auto& lane = info_->lanes_[idx][i];
|
||||
const auto& lane = info_->lanes_[idx][i];
|
||||
float mainPos = lane.startPos;
|
||||
for (const auto& item : lane.items_) {
|
||||
auto child = wrapper_->GetOrCreateChildByIndex(nodeIdx(item.idx));
|
||||
|
@ -303,7 +303,7 @@ void WaterFlowSegmentedLayout::MeasureOnOffset()
|
||||
if (!forward) {
|
||||
// measure appearing items when scrolling upwards
|
||||
auto props = DynamicCast<WaterFlowLayoutProperty>(wrapper_->GetLayoutProperty());
|
||||
int32_t bound = std::min(oldStart, info_->endIndex_);
|
||||
const int32_t bound = std::min(oldStart, info_->endIndex_);
|
||||
for (int32_t i = info_->startIndex_; i <= bound; ++i) {
|
||||
MeasureItem(props, i, info_->itemInfos_[i].crossIdx,
|
||||
WaterFlowLayoutUtils::GetUserDefHeight(sections_, info_->GetSegment(i), i));
|
||||
|
@ -135,6 +135,7 @@ const PaddingProperty MARGIN_1 = {
|
||||
.bottom = CalcLength(5.0_vp),
|
||||
.top = CalcLength(1.0_vp),
|
||||
.right = CalcLength(3.0_vp),
|
||||
.left = CalcLength(5.0_vp),
|
||||
};
|
||||
|
||||
const std::vector<WaterFlowSections::Section> SECTION_5 = {
|
||||
@ -162,7 +163,7 @@ const std::vector<float> CROSS_GAP_5 = { 0.0f, 0.0f, 0.0f, 2.0f, 0.0f };
|
||||
const std::vector<float> MAIN_GAP_5 = { 5.0f, 0.0f, 0.0f, 1.0f, 2.0f };
|
||||
// assuming WaterFlow width = 400.0f
|
||||
const std::vector<std::vector<float>> ITEM_CROSS_SIZE_5 = { { 400.0f / 3, 400.0f / 3, 400.0f / 3 },
|
||||
{ 79.4f, 79.4f, 79.4f, 79.4f, 79.4f }, { 400.0f }, { 400.0f }, { 200.0f, 200.0f } };
|
||||
{ 78.4f, 78.4f, 78.4f, 78.4f, 78.4f }, { 400.0f }, { 400.0f }, { 200.0f, 200.0f } };
|
||||
|
||||
const std::vector<WaterFlowSections::Section> ADD_SECTION_6 = {
|
||||
WaterFlowSections::Section { .itemsCount = 10,
|
||||
|
@ -775,8 +775,9 @@ HWTEST_F(WaterFlowSegmentCommonTest, Constraint001, TestSize.Level1)
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, i), 500.f / 3);
|
||||
}
|
||||
for (int i = 5; i < 10; i++) {
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, i), (500.f - 3) / 5);
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, i), (500.f - 8.0f) / 5);
|
||||
}
|
||||
EXPECT_EQ(GetChildX(frameNode_, 5), 5.0f);
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, 10), 500.f);
|
||||
EXPECT_EQ(info_->endIndex_, 10);
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ HWTEST_F(WaterFlowSegmentTest, Constraint001, TestSize.Level1)
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, i), 500.f / 3);
|
||||
}
|
||||
for (int i = 5; i < 10; i++) {
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, i), (500.f - 3) / 5);
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, i), (500.f - 8.0f) / 5);
|
||||
}
|
||||
EXPECT_EQ(GetChildWidth(frameNode_, 10), 500.f);
|
||||
EXPECT_EQ(info->endIndex_, 10);
|
||||
|
Loading…
Reference in New Issue
Block a user