!44076 【收编】button--修复用户将shadow设置为异常值,还存在阴影的问题

Merge pull request !44076 from zhangwenbin00001/button_0919
This commit is contained in:
openharmony_ci 2024-09-24 07:17:46 +00:00 committed by Gitee
commit 14b0b8b805
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 5 additions and 13 deletions

View File

@ -387,6 +387,7 @@ void ButtonPattern::OnModifyDone()
renderContext_ = host->GetRenderContext();
layoutProperty_ = GetLayoutProperty<ButtonLayoutProperty>();
buttonTheme_ = pipeline_->GetTheme<ButtonTheme>();
shadow_ = Shadow::CreateShadow(static_cast<ShadowStyle>(buttonTheme_->GetShadowNormal()));
HandleBorderAndShadow();
HandleFocusStatusStyle();
if (pipeline_->GetIsFocusActive()) {
@ -580,11 +581,10 @@ void ButtonPattern::HandleBorderAndShadow()
if (shadowStyle != ShadowStyle::None) {
auto&& graphics = renderContext_->GetOrCreateGraphics();
CHECK_NULL_VOID(graphics);
if ((!graphics->HasBackShadow() ||
IsDynamicSwitchButtonStyle(graphics->GetBackShadowValue())) && isApplyShadow_) {
Shadow shadow = Shadow::CreateShadow(
if ((!graphics->HasBackShadow() || graphics->GetBackShadowValue() == shadow_) && isApplyShadow_) {
shadow_ = Shadow::CreateShadow(
buttonStyle == ButtonStyleMode::TEXT ? ShadowStyle::None : shadowStyle);
renderContext_->UpdateBackShadow(shadow);
renderContext_->UpdateBackShadow(shadow_);
}
}

View File

@ -410,15 +410,6 @@ public:
return false;
}
bool IsDynamicSwitchButtonStyle(const Shadow& shadow)
{
ShadowStyle shadowStyle = static_cast<ShadowStyle>(buttonTheme_->GetShadowNormal());
if (shadow == Shadow::CreateShadow(ShadowStyle::None) || shadow == Shadow::CreateShadow(shadowStyle)) {
return true;
}
return false;
}
protected:
bool IsNeedInitClickEventRecorder() const override
{
@ -449,6 +440,7 @@ private:
RefPtr<ButtonLayoutProperty>& layoutProperty, RefPtr<TextLayoutProperty>& textLayoutProperty);
static bool NeedAgingUpdateText(RefPtr<ButtonLayoutProperty>& layoutProperty);
bool IsNeedToHandleHoverOpacity();
Shadow shadow_;
Color backgroundColor_;
Color focusBorderColor_;
Color themeBgColor_;