Skip to content

Conversation

@BLumia
Copy link
Member

@BLumia BLumia commented Apr 1, 2025

注意:仅更改了 x11 下的行为,当前在 Treeland 下行为仍然是旧行为。

2025-04-01.17.11.24.mov

Summary by Sourcery

Refactor dock hide animation to use transform for smoother visual updates and positioning

Bug Fixes:

  • Fix blur area not updating correctly with dock visual position

Enhancements:

  • Implement a new translation-based animation for dock hide/show that supports different dock positions
  • Improve dock layout by introducing a container item with transform for more flexible positioning

Summary by Sourcery

Refactor dock hide animation to use transform-based positioning for smoother visual updates, with platform-specific behavior for X11 and Wayland

New Features:

  • Add platform-specific animation handling for different window systems (X11 vs Wayland)

Bug Fixes:

  • Fix blur area update mechanism for dock visual positioning

Enhancements:

  • Implement a new translation-based animation for dock hide/show that supports different dock positions
  • Introduce a container item with transform for more flexible dock positioning

@deepin-ci-robot
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@BLumia BLumia requested a review from 18202781743 April 1, 2025 09:05
@sourcery-ai
Copy link

sourcery-ai bot commented Apr 1, 2025

Reviewer's Guide by Sourcery

This pull request refactors the dock hide animation to use a transform-based approach on X11 for smoother visual updates and positioning. It also fixes an issue where the blur area was not updating correctly with the dock's visual position. The changes involve modifying the animation target and logic, introducing a transform element, and adjusting the blur effect application.

Sequence diagram for dock hide/show animation (X11)

sequenceDiagram
    participant Panel
    participant Dock
    participant dockTransform

    Panel->>Dock: hideState changed
    activate Dock
    Dock->>hideShowAnimation: start()
    activate hideShowAnimation
    alt useTransformBasedAnimation is true (X11)
        hideShowAnimation->>dockTransform: property = x or y
        dockTransform-->>Panel: Animation updates position
    else useTransformBasedAnimation is false (Wayland)
        hideShowAnimation->>Dock: property = width or height
        Dock-->>Panel: Animation updates size
    end
    hideShowAnimation-->>Dock: onStopped()
    Dock->>Dock: visible = (x or y) == 0
    deactivate hideShowAnimation
    deactivate Dock
Loading

Updated class diagram for Dock component

classDiagram
    class Dock {
        -PropertyAnimation hideShowAnimation
        -bool useTransformBasedAnimation
        -Item dockContainer
        -Translate dockTransform
        -D.StyledBehindWindowBlur blur
        -GridLayout gridLayout
        -Item dockLeftPart
        -Item dockCenterPart
        -Item dockRightPart
    }

    class Translate {
        -id dockTransform
    }

    Dock --|> dockContainer : contains
    Dock --|> hideShowAnimation : uses
    dockContainer --|> Translate : contains
    dockContainer --|> D.StyledBehindWindowBlur : contains
    dockContainer --|> GridLayout : contains
    GridLayout --|> Item : contains (dockLeftPart, dockCenterPart, dockRightPart)

    note for Dock "Animation now uses transform on X11"
Loading

File-Level Changes

Change Details Files
Implements a transform-based animation for dock hide/show, offering smoother visual transitions and supporting various dock positions.
  • Introduces dockTransform Translate element for applying transformations.
  • Modifies hideShowAnimation to animate the x or y property of dockTransform instead of width or height of the dock, based on dock orientation and platform.
  • Updates the to value of hideShowAnimation to use Panel.dockSize for calculating the target translation.
  • Adjusts the onStopped handler of hideShowAnimation to check the x or y property of dockTransform for visibility determination.
  • Adds a conditional check to enable/disable blur effect based on the platform.
  • Wraps dock contents in a new Item called dockContainer to apply the transform.
panels/dock/package/main.qml
Fixes an issue where the blur area was not updating correctly with the dock's visual position.
  • The blur effect is now applied to the dockContainer instead of the Window to ensure it moves with the transform.
panels/dock/package/main.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

避免通过调整原始窗口高度来进行dock的显示\隐藏动画,以便使dock显示\隐
藏动画更流畅.

Log:
@BLumia BLumia marked this pull request as ready for review April 2, 2025 01:38
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. 代码重构

    • PropertyAnimation中,propertyto的绑定逻辑可以进一步简化,避免重复代码。
    • dockTransform的使用可以简化,直接在Transform对象上设置xy属性,而不是通过dockTransform
  2. 逻辑判断

    • PropertyAnimationonStopped回调中,对于useTransformBasedAnimation的判断逻辑可以简化,直接使用dockTransform的属性来判断dock的可见性。
  3. 性能优化

    • D.StyledBehindWindowBlur组件的blendColor计算可以优化,避免每次都调用dock.blendColorAlpha方法。
  4. 代码可读性

    • dockContainerwidthheight的计算逻辑可以提取为一个函数,以提高代码的可读性。
    • dockCenterPartdockRightPart的布局逻辑可以提取为函数或组件,以减少重复代码。
  5. 注释和文档

    • 对于TODO注释,应该提供更多的上下文信息,说明为什么需要这个功能,以及预期的实现方式。
    • 对于复杂的逻辑判断,应该添加注释说明其目的和逻辑。
  6. 平台兼容性

    • PropertyAnimation中,对于Wayland平台的支持逻辑可以进一步明确,确保代码在所有目标平台上都能正常工作。
  7. 安全性

    • 确保所有用户输入都经过适当的验证和清理,以防止潜在的注入攻击。
  8. 测试

    • 对于代码的修改,应该添加相应的单元测试,以确保修改不会引入新的bug。

总体来说,代码的修改提高了代码的可读性和性能,但需要注意保持代码的一致性和可维护性。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @BLumia - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the animation logic into a separate function for better readability.
  • The conditional logic for to in hideShowAnimation is a bit complex; can it be simplified?
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@BLumia BLumia changed the title wip: use transform for dock hide animation fix: use transform for dock hide animation Apr 2, 2025
@BLumia BLumia requested a review from tsic404 April 2, 2025 01:52
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@BLumia BLumia merged commit 962ed4c into linuxdeepin:master Apr 2, 2025
7 of 10 checks passed
@BLumia BLumia deleted the dock-transform branch April 2, 2025 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants