Feature/image gallery - #2
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
本 PR 为 AtomUI.Labs 新增实验控件 ImageGallery(
AtomUI.Labs.Controls.ImageGallery):一个面向图片集合浏览的沉浸式主图查看器,由主图视口(Viewport)、浮动工具栏(Toolbar)与虚拟化缩略图走廊(Filmstrip)共同组成,而不是把图片排成行列的缩略图网格。遵循 Labs 多包规范:独立项目、独立 NuGet 包、独立测试项目,AXAML 命名空间
https://atomui.net/labs(推荐前缀atom.labs)。AtomUI.Core与Avalonia,不依赖 AtomUI Desktop Controls 与 GalleryBasenet10.0/net8.0双 TFM,NativeAOT / trimming 友好动机
图片集合浏览在桌面应用中是高频场景,但通用列表/网格控件无法提供「主图查看 + 缩放平移 + 相邻导航 + 大集合缩略条」的一体化体验。ImageGallery 以
SelectingItemsControl为根,把选择模型、加载调度、内存预算与资源所有权收敛为一个可托管、可验证的封闭模板控件,同时通过强类型合同和属性级 Appearance 保持必要的开放度。功能特性
主图视口(Viewport)
Fit/ActualSize/Custom,原子缩放范围(ZoomRange="0.05,32"),切换图片自动回到 Fit 并清零旋转与平移Always/ControlModifier/Disabled)、Pinch 连续缩放与双指平移、拖拽平移(含边界与输入状态机)Empty/Loading/Ready/Error状态视觉合同;解码清晰度升级(先快速呈现、再无缝升级清晰度);失败仅隔离在当前项,不污染选择与导航浮动工具栏(Toolbar)
ToolbarContent追加自定义操作区Normal/Compact/Minimal单调响应式降级缩略图走廊(Filmstrip)
Rmax = ceil(2L/P) + 4约束,与集合规模无关集合与选择合同
SelectingItemsControl的SelectedIndex/SelectedItem/SelectionChanged合同,固定单选IImageGalleryItem/ImageGalleryItem(Key/Title/MainImageSource/ThumbnailImageSource),不做反射式属性路径猜测图片源抽象与加载安全
IImageGallerySource统一抽象;内置FromFile/FromAvaloniaResource/FromHttp/FromStream,Create作为自定义解码与释放策略的逃生口ImageGalleryLoadLimits原子安全限制(编码字节 / 像素总数 / 单边尺寸 / 解码内存),危险分配前校验,防止单张超大图拖垮进程资源所有权与外部消费
ImageGalleryImageLease+SharedImageResource引用计数所有权域:缓存、当前资源槽与外部 Lease 生命周期互不破坏,Dispose 线程安全且幂等MainImageMode = ResourceOnly:视口让渡渲染与输入,宿主应用通过TryAcquireCurrentImage取得调用方所有的 Lease,配合CurrentImageResourceChanged事件实现外部渲染面(如自绘 Canvas / 渲染引擎)外观、主题与本地化
ControlTheme与固定模板,内部 Theme / 资源 Key 不公开;属性级 Appearance 开放(Viewport / Toolbar / Button / Filmstrip / ThumbnailItem 五类稀疏覆盖对象、8 个 Appearance 属性)en_US/zh_CN/zh_TW强类型语言资源,运行时切换即时生效