提交 18b0521f 编写于 作者: L liqiang

fix flexlayout layout error while child is uilabel

Change-Id: I648c56c17cbf4a90ac1b6f5a15335573200b05dd
Signed-off-by: Nliqiang <liqiang121@huawei.com>
上级 4de9343f
......@@ -109,6 +109,7 @@ void FlexLayout::CalValidLength(uint16_t& totalValidLength, uint16_t& allChildNu
/* calculate valid length of all children views */
while (child != nullptr) {
if (child->IsVisible()) {
child->ReMeasure();
if ((direction_ == LAYOUT_HOR) || (direction_ == LAYOUT_HOR_R)) {
left = child->GetStyle(STYLE_MARGIN_LEFT);
right = child->GetStyle(STYLE_MARGIN_RIGHT);
......@@ -134,6 +135,7 @@ void FlexLayout::CalRowCount()
rowCount_ = 1;
while (child != nullptr) {
if (child->IsVisible()) {
child->ReMeasure();
left = child->GetStyle(STYLE_MARGIN_LEFT);
right = child->GetStyle(STYLE_MARGIN_RIGHT);
pos += left;
......@@ -285,7 +287,6 @@ void FlexLayout::LayoutHorizontal()
while (child != nullptr) {
if (child->IsVisible()) {
child->ReMeasure();
int16_t left = child->GetStyle(STYLE_MARGIN_LEFT);
int16_t right = child->GetStyle(STYLE_MARGIN_RIGHT);
posX += left;
......@@ -324,6 +325,7 @@ void FlexLayout::CalColumnCount()
columnCount_ = 1;
while (child != nullptr) {
if (child->IsVisible()) {
child->ReMeasure();
top = child->GetStyle(STYLE_MARGIN_TOP);
bottom = child->GetStyle(STYLE_MARGIN_BOTTOM);
pos += top;
......@@ -473,7 +475,6 @@ void FlexLayout::LayoutVertical()
while (child != nullptr) {
if (child->IsVisible()) {
child->ReMeasure();
int16_t top = child->GetStyle(STYLE_MARGIN_TOP);
int16_t bottom = child->GetStyle(STYLE_MARGIN_BOTTOM);
posY += top;
......
......@@ -40,6 +40,7 @@ void UITestAdvancedLayout::SetUp()
verfRBtn_ = new UILabelButton();
wrapBtn_ = new UILabelButton();
addElefBtn_ = new UILabelButton();
addTextElefBtn_ = new UILabelButton();
majorStartBtn_ = new UILabelButton();
majorEndBtn_ = new UILabelButton();
majorCenterBtn_ = new UILabelButton();
......@@ -126,6 +127,7 @@ void UITestAdvancedLayout::UIKit_Layout_Test_FlexLayout_001()
SetUpButton(flexController_, verfRBtn_, "ver_r");
SetUpButton(flexController_, wrapBtn_, "wrap");
SetUpButton(flexController_, addElefBtn_, "add");
SetUpButton(flexController_, addTextElefBtn_, "addLabel");
SetUpButton(flexController_, majorStartBtn_, "M_start");
SetUpButton(flexController_, majorEndBtn_, "M_end");
SetUpButton(flexController_, majorCenterBtn_, "M_center");
......@@ -258,6 +260,8 @@ bool UITestAdvancedLayout::OnClick(UIView& view, const ClickEvent& event)
fTarget_->SetFlexWrap(true);
} else if (&view == addElefBtn_) {
AddElement(fTarget_);
} else if (&view == addTextElefBtn_) {
AddTextElement(fTarget_);
} else if (&view == majorStartBtn_) {
fTarget_->SetMajorAxisAlign(ALIGN_START);
} else if (&view == majorEndBtn_) {
......@@ -273,9 +277,9 @@ bool UITestAdvancedLayout::OnClick(UIView& view, const ClickEvent& event)
} else if (&view == secStartBtn_) {
fTarget_->SetSecondaryAxisAlign(ALIGN_START);
} else if (&view == secEndBtn_) {
fTarget_->SetSecondaryAxisAlign(ALIGN_CENTER);
fTarget_->SetSecondaryAxisAlign(ALIGN_END);
} else if (&view == secCenterBtn_) {
fTarget_->SetMajorAxisAlign(ALIGN_END);
fTarget_->SetSecondaryAxisAlign(ALIGN_CENTER);
} else {
OnClickButton(view);
}
......
......@@ -57,6 +57,7 @@ private:
UILabelButton* verfRBtn_ = nullptr;
UILabelButton* wrapBtn_ = nullptr;
UILabelButton* addElefBtn_ = nullptr;
UILabelButton* addTextElefBtn_ = nullptr;
UILabelButton* majorStartBtn_ = nullptr;
UILabelButton* majorEndBtn_ = nullptr;
UILabelButton* majorCenterBtn_ = nullptr;
......@@ -102,6 +103,7 @@ private:
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
}
void AddElement(Layout* layout)
{
UIView* view = new UIView();
......@@ -115,6 +117,16 @@ private:
}
layout->Add(view);
}
void AddTextElement(Layout* layout)
{
UILabel* label = new UILabel();
label->Resize(80, 30);
label->SetLineBreakMode(0);
label->SetText("Hello, OHOS!");
layout->Add(label);
}
void Clear(Layout* layout) const
{
if (layout == nullptr) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册