mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
!48439 适配LineHeight的动画效果
Merge pull request !48439 from xiangyuan6/master
This commit is contained in:
commit
8dbc8afc67
@ -324,6 +324,16 @@ void MultipleParagraphLayoutAlgorithm::SetPropertyToModifier(const RefPtr<TextLa
|
||||
} else {
|
||||
modifier->SetBaselineOffset(textStyle.GetBaselineOffset(), textStyle, true);
|
||||
}
|
||||
auto lineHeight = layoutProperty->GetLineHeight();
|
||||
if (lineHeight.has_value()) {
|
||||
if (lineHeight->Unit() == DimensionUnit::PERCENT) {
|
||||
modifier->SetLineHeight(lineHeight.value(), textStyle, true);
|
||||
} else {
|
||||
modifier->SetLineHeight(lineHeight.value(), textStyle);
|
||||
}
|
||||
} else {
|
||||
modifier->SetLineHeight(textStyle.GetLineHeight(), textStyle, true);
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<Paragraph> MultipleParagraphLayoutAlgorithm::GetSingleParagraph() const
|
||||
|
@ -131,6 +131,7 @@ void TextContentModifier::SetDefaultAnimatablePropertyValue(const TextStyle& tex
|
||||
SetDefaultTextShadow(textStyle);
|
||||
SetDefaultTextDecoration(textStyle);
|
||||
SetDefaultBaselineOffset(textStyle);
|
||||
SetDefaultLineHeight(textStyle);
|
||||
}
|
||||
|
||||
void TextContentModifier::SetDefaultFontSize(const TextStyle& textStyle)
|
||||
@ -236,6 +237,19 @@ void TextContentModifier::SetDefaultBaselineOffset(const TextStyle& textStyle)
|
||||
AttachProperty(baselineOffsetFloat_);
|
||||
}
|
||||
|
||||
void TextContentModifier::SetDefaultLineHeight(const TextStyle& textStyle)
|
||||
{
|
||||
float lineHeight = textStyle.GetLineHeight().Value();
|
||||
auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck();
|
||||
if (pipelineContext) {
|
||||
lineHeight = textStyle.GetLineHeight().ConvertToPxDistribute(
|
||||
textStyle.GetMinFontScale(), textStyle.GetMaxFontScale(), textStyle.IsAllowScale());
|
||||
}
|
||||
|
||||
lineHeightFloat_ = MakeRefPtr<AnimatablePropertyFloat>(lineHeight);
|
||||
AttachProperty(lineHeightFloat_);
|
||||
}
|
||||
|
||||
void TextContentModifier::SetClip(bool clip)
|
||||
{
|
||||
if (clip_) {
|
||||
@ -602,6 +616,14 @@ void TextContentModifier::ModifyBaselineOffsetInTextStyle(TextStyle& textStyle)
|
||||
}
|
||||
}
|
||||
|
||||
void TextContentModifier::ModifyLineHeightInTextStyle(TextStyle& textStyle)
|
||||
{
|
||||
if (lineHeight_.has_value() && lineHeightFloat_) {
|
||||
lastLineHeight_ = lineHeightFloat_->Get();
|
||||
textStyle.SetLineHeight(Dimension(lineHeightFloat_->Get(), DimensionUnit::PX));
|
||||
}
|
||||
}
|
||||
|
||||
void TextContentModifier::ModifyTextStyle(TextStyle& textStyle)
|
||||
{
|
||||
ModifyFontSizeInTextStyle(textStyle);
|
||||
@ -612,6 +634,7 @@ void TextContentModifier::ModifyTextStyle(TextStyle& textStyle)
|
||||
ModifyTextShadowsInTextStyle(textStyle);
|
||||
ModifyDecorationInTextStyle(textStyle);
|
||||
ModifyBaselineOffsetInTextStyle(textStyle);
|
||||
ModifyLineHeightInTextStyle(textStyle);
|
||||
}
|
||||
|
||||
void TextContentModifier::UpdateFontSizeMeasureFlag(PropertyChangeFlag& flag)
|
||||
@ -697,6 +720,15 @@ void TextContentModifier::UpdateBaselineOffsetMeasureFlag(PropertyChangeFlag& fl
|
||||
}
|
||||
}
|
||||
|
||||
void TextContentModifier::UpdateLineHeightMeasureFlag(PropertyChangeFlag& flag)
|
||||
{
|
||||
if (lineHeight_.has_value() && lineHeightFloat_ &&
|
||||
!NearEqual(lastLineHeight_, lineHeightFloat_->Get())) {
|
||||
flag |= PROPERTY_UPDATE_MEASURE;
|
||||
lastLineHeight_ = lineHeightFloat_->Get();
|
||||
}
|
||||
}
|
||||
|
||||
bool TextContentModifier::NeedMeasureUpdate(PropertyChangeFlag& flag)
|
||||
{
|
||||
flag = 0;
|
||||
@ -707,6 +739,7 @@ bool TextContentModifier::NeedMeasureUpdate(PropertyChangeFlag& flag)
|
||||
UpdateTextShadowMeasureFlag(flag);
|
||||
UpdateTextDecorationMeasureFlag(flag);
|
||||
UpdateBaselineOffsetMeasureFlag(flag);
|
||||
UpdateLineHeightMeasureFlag(flag);
|
||||
flag &= (PROPERTY_UPDATE_MEASURE | PROPERTY_UPDATE_MEASURE_SELF | PROPERTY_UPDATE_MEASURE_SELF_AND_PARENT);
|
||||
if (flag) {
|
||||
onlyTextColorAnimation_ = false;
|
||||
@ -855,6 +888,20 @@ void TextContentModifier::SetBaselineOffset(const Dimension& value, const TextSt
|
||||
baselineOffsetFloat_->Set(baselineOffsetValue);
|
||||
}
|
||||
|
||||
void TextContentModifier::SetLineHeight(const Dimension& value, const TextStyle& textStyle, bool isReset)
|
||||
{
|
||||
float lineHeightValue = 0.0f;
|
||||
if (!isReset) {
|
||||
lineHeightValue = value.ConvertToPxDistribute(
|
||||
textStyle.GetMinFontScale(), textStyle.GetMaxFontScale(), textStyle.IsAllowScale());
|
||||
lineHeight_ = Dimension(lineHeightValue);
|
||||
} else {
|
||||
lineHeight_ = std::nullopt;
|
||||
}
|
||||
CHECK_NULL_VOID(lineHeightFloat_);
|
||||
lineHeightFloat_->Set(lineHeightValue);
|
||||
}
|
||||
|
||||
void TextContentModifier::SetContentOffset(OffsetF& value)
|
||||
{
|
||||
CHECK_NULL_VOID(contentOffset_);
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
void SetTextDecoration(const TextDecoration& value, bool isReset = false);
|
||||
void SetTextDecorationColor(const Color& value, bool isReset = false);
|
||||
void SetBaselineOffset(const Dimension& value, const TextStyle& textStyle, bool isReset = false);
|
||||
void SetLineHeight(const Dimension& value, const TextStyle& textStyle, bool isReset = false);
|
||||
void SetContentOffset(OffsetF& value);
|
||||
void SetContentSize(SizeF& value);
|
||||
|
||||
@ -110,6 +111,7 @@ private:
|
||||
void AddDefaultShadow();
|
||||
void SetDefaultTextDecoration(const TextStyle& textStyle);
|
||||
void SetDefaultBaselineOffset(const TextStyle& textStyle);
|
||||
void SetDefaultLineHeight(const TextStyle& textStyle);
|
||||
float GetTextRacePercent();
|
||||
TextDirection GetTextRaceDirection() const;
|
||||
TextDirection GetTextRaceDirectionByContent() const;
|
||||
@ -123,6 +125,7 @@ private:
|
||||
void ModifyTextShadowsInTextStyle(TextStyle& textStyle);
|
||||
void ModifyDecorationInTextStyle(TextStyle& textStyle);
|
||||
void ModifyBaselineOffsetInTextStyle(TextStyle& textStyle);
|
||||
void ModifyLineHeightInTextStyle(TextStyle& textStyle);
|
||||
|
||||
void UpdateFontSizeMeasureFlag(PropertyChangeFlag& flag);
|
||||
void UpdateAdaptMinFontSizeMeasureFlag(PropertyChangeFlag& flag);
|
||||
@ -132,6 +135,7 @@ private:
|
||||
void UpdateTextShadowMeasureFlag(PropertyChangeFlag& flag);
|
||||
void UpdateTextDecorationMeasureFlag(PropertyChangeFlag& flag);
|
||||
void UpdateBaselineOffsetMeasureFlag(PropertyChangeFlag& flag);
|
||||
void UpdateLineHeightMeasureFlag(PropertyChangeFlag& flag);
|
||||
|
||||
void ChangeParagraphColor(const RefPtr<Paragraph>& paragraph);
|
||||
void DrawObscuration(DrawingContext& drawingContext);
|
||||
@ -189,6 +193,10 @@ private:
|
||||
RefPtr<AnimatablePropertyFloat> baselineOffsetFloat_;
|
||||
float lastBaselineOffsetFloat_ = 0.0f;
|
||||
|
||||
std::optional<Dimension> lineHeight_;
|
||||
RefPtr<AnimatablePropertyFloat> lineHeightFloat_;
|
||||
float lastLineHeight_ = 0.0f;
|
||||
|
||||
WeakPtr<Pattern> pattern_;
|
||||
|
||||
RefPtr<AnimatablePropertyFloat> racePercentFloat_;
|
||||
|
Loading…
Reference in New Issue
Block a user