提交 bb53950e 编写于 作者: W wanngtiantian 提交者: wangtiantian

IssueNo:#I3D6KV

Description:fix UILabel GetTextWidth value error when LineBreakMode is LINE_BREAK_ELLIPSIS
Sig:graphic
Feature or Bugfix:Bugfix
Binary Source:No
上级 0c824f55
......@@ -165,6 +165,18 @@ void Text::ReMeasureTextSize(const Rect& textRect, const Style& style)
}
}
void Text::ReMeasureTextWidthInEllipsisMode(const Rect& textRect, const Style& style, uint16_t ellipsisIndex)
{
if (ellipsisIndex != TEXT_ELLIPSIS_END_INV) {
int16_t lineMaxWidth = expandWidth_ ? textSize_.x : textRect.GetWidth();
uint32_t maxLineBytes = 0;
uint16_t lineCount = GetLine(lineMaxWidth, style.letterSpace_, ellipsisIndex, maxLineBytes);
if ((lineCount > 0) && (textSize_.x < textLine_[lineCount - 1].linePixelWidth)) {
textSize_.x = textLine_[lineCount - 1].linePixelWidth;
}
}
}
void Text::OnDraw(const Rect& invalidatedArea,
const Rect& viewOrigRect,
const Rect& textRect,
......@@ -365,4 +377,4 @@ uint16_t Text::GetLetterIndexByPosition(const Rect& textRect, const Style& style
return static_cast<uint16_t>(i);
}
}
} // namespace OHOS
\ No newline at end of file
} // namespace OHOS
......@@ -224,9 +224,7 @@ uint16_t UILabel::GetTextWidth()
{
InitLabelText();
if (labelText_->IsNeedRefresh()) {
Style style = GetStyleConst();
style.textColor_ = GetTextColor();
labelText_->ReMeasureTextSize(GetContentRect(), style);
ReMeasure();
}
return labelText_->GetTextSize().x;
}
......@@ -235,9 +233,7 @@ uint16_t UILabel::GetTextHeight()
{
InitLabelText();
if (labelText_->IsNeedRefresh()) {
Style style = GetStyleConst();
style.textColor_ = GetTextColor();
labelText_->ReMeasureTextSize(GetContentRect(), style);
ReMeasure();
}
return labelText_->GetTextSize().y;
}
......@@ -290,6 +286,7 @@ void UILabel::ReMeasure()
break;
case LINE_BREAK_ELLIPSIS:
ellipsisIndex_ = labelText_->GetEllipsisIndex(GetContentRect(), style);
labelText_->ReMeasureTextWidthInEllipsisMode(GetContentRect(), style, ellipsisIndex_);
break;
case LINE_BREAK_MARQUEE:
RemeasureForMarquee(textSize.x);
......
......@@ -245,6 +245,8 @@ public:
virtual void ReMeasureTextSize(const Rect& textRect, const Style& style);
void ReMeasureTextWidthInEllipsisMode(const Rect& textRect, const Style& style, uint16_t ellipsisIndex);
void OnDraw(const Rect& invalidatedArea,
const Rect& viewOrigRect,
const Rect& textRect,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册