Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移植 SettingsControls #771

Merged
merged 31 commits into from
Dec 12, 2023
Merged

移植 SettingsControls #771

merged 31 commits into from
Dec 12, 2023

Conversation

Blinue
Copy link
Owner

@Blinue Blinue commented Dec 4, 2023

Close #769

这个 PR 移植了 Windows Community Toolkit 中的 SettingsCard 和 SettingsExpander 控件以及它们的依赖项IsEqualStateTrigger、IsNullStateTrigger 和 ControlSizeTrigger,删除了旧版 SettingsCard。还有一些 UI 优化。

并非原样移植,移植过程中进行了一些优化、重构和修复,以满足我们自己的需求。

  1. IsEqualStateTrigger 事实上无法移植为 C++,问题在于 C++ 无法实现 C# 中的 object.Equals。IPropertyValue 虽然提供了获取类型的接口,但不支持结构体和枚举类型,IPropertyValue 也不提供获取底层字节的接口。由于 IsEqualStateTrigger 只在 SettingsCard 中用于比较 ContentAlignment,因此移植的版本只支持 ContentAlignment。
  2. IsNullStateTrigger 原为 IsNullOrEmptyStateTrigger,不过没有需要判断集合是否为空的情况,因此进行了简化。
  3. SettingsCard 添加 IsWrapEnabled 属性,为 true 时会根据控件宽度自动切换布局。
  4. SettingsExpander.Items 的容器从 ItemsRepeater 改为 ListView,因为 ItemsRepeater 托管在 XAML Islands 中时有渲染 bug ItemsRepeater renders only the first item when no ScrollViewer in the visual tree under a popup microsoft/microsoft-ui-xaml#2349
  5. SettingsExpander 添加 CanReorderItems 属性,为 true 时可拖拽子项,这用于实现缩放配置的 UI。

我计划接下来优化 SettingsCard 的布局,使得可以智能切换水平和竖直排列,这将在另一个 PR 中完成。

@Blinue Blinue added the area: UI label Dec 4, 2023
@Blinue Blinue marked this pull request as draft December 4, 2023 13:21
Copy link
Owner Author

@Blinue Blinue left a comment

Choose a reason for hiding this comment

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

修复缩放配置页面崩溃

这个bug表现非常诡异:附加调试器的时候没有问题,直接运行就会崩溃。能定位到很大程度是运气。

@Blinue Blinue added the enhancement New feature or request label Dec 12, 2023
@Blinue Blinue marked this pull request as ready for review December 12, 2023 10:03
@Blinue Blinue merged commit 490a4ea into render-system Dec 12, 2023
2 checks passed
@Blinue Blinue deleted the settings-controls branch December 12, 2023 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UI enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant