未验证 提交 4874a26c 编写于 作者: O openharmony_ci 提交者: Gitee

!928 JS文本控件支持设定行高

Merge pull request !928 from Zhouyj/setLineHeight
......@@ -299,7 +299,7 @@ void Text::Draw(BufferInfo& gfxDstBuffer,
uint16_t lineCount = GetLine(lineMaxWidth, style.letterSpace_, ellipsisIndex, maxLineBytes);
int16_t lineHeight = style.lineHeight_;
int16_t curLineHeight;
if (lineHeight == 0) {
if (lineHeight <= 0) {
lineHeight = UIFont::GetInstance()->GetHeight(fontId_, fontSize_);
lineHeight += style.lineSpace_;
}
......
......@@ -60,6 +60,9 @@ void UITestLabel::TearDown()
labelDirectionBtn2_ = nullptr;
labelSizeBtn1_ = nullptr;
labelSizeBtn2_ = nullptr;
labelLineHeightBtn1_ = nullptr;
labelLineHeightBtn2_ = nullptr;
labelLineHeightBtn3_ = nullptr;
}
const UIView* UITestLabel::GetTestView()
......@@ -179,6 +182,14 @@ void UITestLabel::UIKitUILabeTestDisplay002()
label3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
labelDirectionBtn1_ = SetUpButton("左往右 ", 24, 240, uiViewGroup); // 24: x-coordinate; 240: y-coordinate
labelDirectionBtn2_ = SetUpButton("右往左 ", 116, 240, uiViewGroup); // 116: x-coordinate; 240: y-coordinate
UILabel* label4 = new UILabel();
uiViewGroup->Add(label4);
label4->SetPosition(24, 299, 288, 48); // 24: x-coordinate, 299: y-coordinate, 288: width; 48: height
label4->SetText("行高");
label4->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
labelLineHeightBtn1_ = SetUpButton("行高20 ", 24, 336, uiViewGroup); // 24: x-coordinate; 336: y-coordinate
labelLineHeightBtn2_ = SetUpButton("行高35 ", 116, 336, uiViewGroup); // 116: x-coordinate; 336: y-coordinate
labelLineHeightBtn3_ = SetUpButton("行高50 ", 208, 336, uiViewGroup); // 208: x-coordinate; 336: y-coordinate
positionY_ += 384; // 384: increase x-coordinate
positionX_ -= 312; // 312: increase y-coordinate
}
......@@ -270,6 +281,12 @@ void UITestLabel::ExpandClick(UIView& view, const ClickEvent& event) const
} else if (&view == labelSizeBtn2_) {
uiLabel->SetText("Test of 图形子系统,Test of 图形子系统 ");
uiLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
} else if (&view == labelLineHeightBtn1_) {
uiLabel->SetStyle(STYLE_LINE_HEIGHT, 20); // 20: lineHeight
} else if (&view == labelLineHeightBtn2_) {
uiLabel->SetStyle(STYLE_LINE_HEIGHT, 35); // 35: lineHeight
} else if (&view == labelLineHeightBtn3_) {
uiLabel->SetStyle(STYLE_LINE_HEIGHT, 50); // 50: lineHeight
}
}
} // namespace OHOS
......@@ -65,6 +65,9 @@ private:
UILabelButton* labelDirectionBtn2_ = nullptr;
UILabelButton* labelSizeBtn1_ = nullptr;
UILabelButton* labelSizeBtn2_ = nullptr;
UILabelButton* labelLineHeightBtn1_ = nullptr;
UILabelButton* labelLineHeightBtn2_ = nullptr;
UILabelButton* labelLineHeightBtn3_ = nullptr;
void InnerTestTitle(const char* title);
UILabelButton* SetUpButton(const char* title, int16_t x, int16_t y, UIViewGroup* uiViewGroup,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册