!33896 解决slider设置了contentModifier后slider的宽度和高度变成0问题和Slider自定义builder切换undefined问题

Merge pull request !33896 from yangziyong/sliderBuilderBug
This commit is contained in:
openharmony_ci 2024-05-28 02:57:00 +00:00 committed by Gitee
commit 33f6e1aaf6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 25 additions and 4 deletions

View File

@ -826,6 +826,9 @@ void SliderContentModifier::SetBlockShape(const RefPtr<BasicShape>& shape)
void SliderContentModifier::UpdateContentDirtyRect(const SizeF& frameSize)
{
if (useContentModifier_->Get()) {
return;
}
auto pipeline = PipelineBase::GetCurrentContext();
CHECK_NULL_VOID(pipeline);
auto theme = pipeline->GetTheme<SliderTheme>();

View File

@ -187,7 +187,6 @@ void SliderLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper)
CHECK_NULL_VOID(pattern);
if (pattern->UseContentModifier()) {
BoxLayoutAlgorithm::Layout(layoutWrapper);
host->GetGeometryNode()->Reset();
return;
}
PerformLayout(layoutWrapper);

View File

@ -200,9 +200,6 @@ void SliderPattern::OnWindowSizeChanged(int32_t width, int32_t height, WindowSiz
void SliderPattern::InitClickEvent(const RefPtr<GestureEventHub>& gestureHub)
{
if (UseContentModifier()) {
return;
}
if (clickListener_) {
return;
}
@ -214,6 +211,10 @@ void SliderPattern::InitClickEvent(const RefPtr<GestureEventHub>& gestureHub)
void SliderPattern::InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub)
{
if (UseContentModifier()) {
if (touchEvent_) {
gestureHub->RemoveTouchEvent(touchEvent_);
touchEvent_ = nullptr;
}
return;
}
if (touchEvent_) {
@ -694,6 +695,13 @@ void SliderPattern::InitPanEvent(const RefPtr<GestureEventHub>& gestureHub)
void SliderPattern::InitOnKeyEvent(const RefPtr<FocusHub>& focusHub)
{
if (UseContentModifier()) {
focusHub->SetInnerFocusPaintRectCallback(nullptr);
focusHub->SetOnKeyEventInternal(nullptr);
focusHub->SetOnFocusInternal(nullptr);
focusHub->SetOnBlurInternal(nullptr);
return;
}
auto getInnerPaintRectCallback = [wp = WeakClaim(this)](RoundRect& paintRect) {
auto pattern = wp.Upgrade();
CHECK_NULL_VOID(pattern);
@ -927,6 +935,14 @@ bool SliderPattern::MoveStep(int32_t stepCount)
void SliderPattern::InitMouseEvent(const RefPtr<InputEventHub>& inputEventHub)
{
if (UseContentModifier()) {
if (hoverEvent_) {
inputEventHub->RemoveOnHoverEvent(hoverEvent_);
hoverEvent_ = nullptr;
}
if (mouseEvent_) {
inputEventHub->RemoveOnMouseEvent(mouseEvent_);
mouseEvent_ = nullptr;
}
return;
}
auto hoverEvent = [weak = WeakClaim(this)](bool isHover) {

View File

@ -142,6 +142,9 @@ public:
return;
}
makeFunc_ = std::move(makeFunc);
if (sliderContentModifier_) {
sliderContentModifier_->SetUseContentModifier(true);
}
}
bool UseContentModifier()