Skip to content

优化 JFXSpinner 动画生成逻辑#5804

Merged
Glavo merged 22 commits intoHMCL-dev:mainfrom
Glavo:spinner
Mar 18, 2026
Merged

优化 JFXSpinner 动画生成逻辑#5804
Glavo merged 22 commits intoHMCL-dev:mainfrom
Glavo:spinner

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Mar 18, 2026

  1. 简化代码
  2. 在未启用动画时,使用简单的线性旋转动画

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

此 PR 旨在优化(简化)JFXSpinner 的动画关键帧生成逻辑,并在禁用动画时提供一个更轻量的线性旋转动画作为替代,以更好地适配全局动画开关(AnimationUtils.isAnimationEnabled())。

Changes:

  • 将原先重复构建 KeyFrame[] 的逻辑改为向 List<KeyFrame> 追加关键帧,减少样板代码
  • 当启用动画时,继续使用原先的“伸缩弧线 + 旋转”的关键帧序列
  • 当禁用动画时,改用固定弧长的线性旋转动画(更简单、开销更小)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 旨在优化 JFXSpinnerSkin 的不确定(indeterminate)模式动画生成逻辑,以减少代码复杂度,并在“动画未启用”时切换为更简单的线性旋转效果。

Changes:

  • 移除旧的分段 KeyFrame 生成/颜色切换逻辑,改为通过 addKeyFrames(...) 统一拼装关键帧列表
  • 引入 AnimationUtils.isAnimationEnabled() 分支:启用动画时使用原有复杂关键帧序列;未启用时使用线性旋转 Timeline
  • 调整动画启停逻辑,改为在 updateAnimation() 中直接 play/pause,并移除 control.sceneProperty() 监听

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 针对 JFXSpinnerSkin 的不确定进度(indeterminate)动画创建逻辑做了重构,以减少重复代码,并在全局禁用动画时改用更简单的线性旋转动画,以适配 HMCL 的动画开关策略。

Changes:

  • 将原先按颜色分段构造 KeyFrame[] 的逻辑,重构为通过 addKeyFrames(...) 生成并集中组装 KeyFrame 列表。
  • 引入 AnimationUtils.isAnimationEnabled():动画启用时使用原复杂弧线动画;禁用时使用简单线性旋转。
  • 简化 updateAnimation():直接基于 treeShowingProperty 进行 play/pause 控制,并在非 indeterminate 时清理动画。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setDelay(Duration.ZERO);
timeline.playFromStart();
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 优化了 JFXSpinnerSkin 的动画关键帧生成与播放控制逻辑,并在“关闭动画”设置下改为使用更简单的线性旋转动画,以降低动画复杂度与开销。

Changes:

  • 重构不定进度(indeterminate)动画的关键帧生成逻辑,移除多段颜色切换帧并用列表组装关键帧
  • 将动画启停逻辑集中到 updateProgress(),并基于 TreeShowingProperty 控制播放/暂停
  • 在动画未启用时(AnimationUtils.isAnimationEnabled() == false),使用更简单的线性旋转时间线

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} else if (isTreeShowing) {
createTransition();
} else { // determinate
clearAnimation();
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

本 PR 优化 JFXSpinnerSkin 的动画生成与播放控制逻辑,简化原先的关键帧拼接方式,并在禁用动画时改用更轻量的线性旋转动画,以降低复杂度并适配“关闭动画”的配置。

Changes:

  • 将不确定进度(indeterminate)动画关键帧生成逻辑重构为列表拼装方式,并移除旧的颜色/帧生成分支。
  • 将动画启停逻辑收敛到 updateProgress(),结合 TreeShowingProperty 控制显示时播放、隐藏时暂停。
  • AnimationUtils.isAnimationEnabled() 为 false 时,使用简单线性旋转 Timeline 作为替代动画。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

本 PR 优化了 JFXSpinnerSkin 的动画生成与进度更新逻辑,将原本分散的初始化/动画控制流程合并到单一的 updateProgress() 路径中,并在关闭动画设置时提供更简单的线性旋转方案,以降低复杂度并提升可维护性。

Changes:

  • 将不确定/确定进度的处理统一收敛到新的 updateProgress() 实现中,减少状态变量与重复逻辑。
  • 重构不确定进度动画:用 addKeyFrames 组合关键帧,并在动画禁用时改用简单线性旋转 Timeline。
  • 依赖 TreeShowingProperty 来在节点不可见时暂停动画,避免无意义的播放。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Glavo Glavo merged commit 704eb32 into HMCL-dev:main Mar 18, 2026
6 checks passed
@Glavo Glavo deleted the spinner branch March 18, 2026 07:48
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.

2 participants