From f5412ee99da67bf67c8d5085760436f4cef63416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E5=A4=B4=E9=B9=85?= Date: Sat, 19 Sep 2026 17:33:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E9=A2=84=E8=A7=88=E5=8D=A1?= =?UTF-8?q?=E7=BC=A9=E5=B0=8F=E5=B9=B6=E5=8F=AF=E7=82=B9=E5=87=BB=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E8=A7=86=E5=9B=BE=EF=BC=9B=E5=AF=BC=E5=87=BA=E5=8F=AA?= =?UTF-8?q?=E5=90=AB=E6=97=B6=E5=BA=8F=E5=9B=BE+=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 圆周/条形预览卡缩小(300->190,高度压缩),标题去掉「(实时联动)」,加切换箭头 - 点击预览卡直接切换条形/圆周视图;预览门槛降低,小窗口也可见 - 导出边界(PNG)只包含「时序图 + 标题」;图例/统计/编辑工具/预览/浮动条移出导出边界 - 重新构建 dist --- lib/ui/app_shell.dart | 14 ++- lib/ui/canvas_overlays.dart | 169 ++++++++++++++++++++++-------------- 2 files changed, 115 insertions(+), 68 deletions(-) diff --git a/lib/ui/app_shell.dart b/lib/ui/app_shell.dart index 262c9f9..a19a201 100644 --- a/lib/ui/app_shell.dart +++ b/lib/ui/app_shell.dart @@ -236,6 +236,7 @@ class _AppShellState extends State { // 画布舞台:可绘制区域,叠加画布视图与浮层。 child: Stack( children: [ + // 导出边界:仅包含「时序图 + 标题」,不含编辑辅助浮层。 Positioned.fill( child: RepaintBoundary( key: _stageKey, @@ -245,19 +246,28 @@ class _AppShellState extends State { Positioned.fill( child: Container(color: t.canvas2, child: CanvasView(controller: c)), ), - // 上层:信息浮层。 + // 仅标题(参与导出)。 Positioned.fill( child: CanvasOverlays( controller: c, - // 侧栏收起时让浮层避开边缘把手。 leftInset: _leftRail ? 22 : 0, rightInset: _rightRail ? 22 : 0, + showPanels: false, ), ), ], ), ), ), + // 编辑辅助浮层(图例 / 统计 / 工具 / 预览 / 浮动条):不参与导出。 + Positioned.fill( + child: CanvasOverlays( + controller: c, + leftInset: _leftRail ? 22 : 0, + rightInset: _rightRail ? 22 : 0, + showTitle: false, + ), + ), // 收起状态:贴边轨道(悬停可展开为悬浮面板)。 if (_leftRail) Positioned(left: 0, top: 0, bottom: 0, child: _rail(t, true)), diff --git a/lib/ui/canvas_overlays.dart b/lib/ui/canvas_overlays.dart index 59f67c0..aa15a2b 100644 --- a/lib/ui/canvas_overlays.dart +++ b/lib/ui/canvas_overlays.dart @@ -27,6 +27,8 @@ class CanvasOverlays extends StatelessWidget { required this.controller, this.leftInset = 0, this.rightInset = 0, + this.showTitle = true, + this.showPanels = true, }); /// 全局应用控制器,提供项目数据与编辑动作。 @@ -38,6 +40,14 @@ class CanvasOverlays extends StatelessWidget { /// 右侧把手占用的宽度(0 表示无把手)。 final double rightInset; + /// 是否显示顶部标题(导出 PNG 时把标题纳入导出边界)。 + final bool showTitle; + + /// 是否显示其余面板(图例 / 统计 / 工具 / 预览 / 浮动工具条)。 + /// + /// 这些属于**编辑辅助元素,不参与导出**。 + final bool showPanels; + /// 控制器快捷访问器。 AppController get c => controller; @@ -61,20 +71,21 @@ class CanvasOverlays extends StatelessWidget { final bool showStats = !circular && w >= 820 && h >= 700; // 编辑工具条:门槛最低,几乎始终显示。 final bool showTools = w >= 700; - // 实时预览卡片:门槛放低,钉住侧栏后仍可见。 - final bool showPreview = w >= 1000 && h >= 680; + // 预览卡片(已缩小):门槛放低,钉住侧栏后仍可见。 + final bool showPreview = w >= 720 && h >= 560; // 浮层整体使用 Stack 叠加,各面板按断点条件选择性插入。 return Stack( children: [ // 顶部标题与副标题,横跨整个画布宽度,不拦截手势。 - Positioned( - left: left, - top: 12, - right: right, - child: IgnorePointer(child: _Title(t: t, circular: circular, project: c.project)), - ), + if (showTitle) + Positioned( + left: left, + top: 12, + right: right, + child: IgnorePointer(child: _Title(t: t, circular: circular, project: c.project)), + ), // 圆周视图左侧信息列:图例 + 选中卡片 + 依赖图例。 - if (showLeftColumn) + if (showPanels && showLeftColumn) Positioned( left: left, top: 70, @@ -94,7 +105,7 @@ class CanvasOverlays extends StatelessWidget { ), ), // 条形视图左下角:节拍统计 + 编辑工具。 - if (!circular && (showStats || showTools)) + if (showPanels && !circular && (showStats || showTools)) Positioned( left: left, bottom: 12, @@ -110,19 +121,17 @@ class CanvasOverlays extends StatelessWidget { ], ), ), - // 右下角实时预览:圆周视图显示条形缩略,反之亦然。 - if (showPreview) + // 右下角预览:圆周视图显示条形缩略,反之亦然;点击可切换视图。 + if (showPanels && showPreview) Positioned( right: right, bottom: 12, - child: IgnorePointer( - child: circular - ? _BarPreviewCard(t: t, project: c.project) - : _CircularPreviewCard(t: t, project: c.project), - ), + child: circular + ? _BarPreviewCard(t: t, c: c) + : _CircularPreviewCard(t: t, c: c), ), // 圆周视图右侧浮动工具栏(添加/编辑/复制/删除/改层/对齐)。 - if (circular) + if (showPanels && circular) Positioned( right: right - 2, top: 120, @@ -737,35 +746,48 @@ class _FloatingToolbar extends StatelessWidget { } } -/// 条形节拍缩略预览卡(在圆周视图右下角显示)。 +/// 条形节拍缩略预览卡(在圆周视图右下角显示);点击切换到条形视图。 class _BarPreviewCard extends StatelessWidget { - const _BarPreviewCard({required this.t, required this.project}); + const _BarPreviewCard({required this.t, required this.c}); /// 主题令牌。 final Tokens t; - /// 当前项目。 - final Project project; + /// 全局应用控制器(用于切换视图)。 + final AppController c; - /// 渲染条形缩略预览。 + /// 渲染紧凑的条形缩略预览,整卡可点击切换视图。 @override Widget build(BuildContext context) { - return _Card( - t: t, - width: 300, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('条形节拍预览(实时联动)', style: TextStyle(color: t.sub, fontSize: 11, fontWeight: FontWeight.w600)), - const SizedBox(height: 10), + final Project project = c.project; + return InkWell( + onTap: () => c.setViewMode(ViewMode.bar), + borderRadius: BorderRadius.circular(10), + child: _Card( + t: t, + width: 190, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon(Icons.bar_chart, size: 13, color: t.accent), + const SizedBox(width: 5), + Text('条形预览', style: TextStyle(color: t.sub, fontSize: 10.5, fontWeight: FontWeight.w600)), + const Spacer(), + Icon(Icons.chevron_right, size: 14, color: t.dim), + ], + ), + const SizedBox(height: 6), SizedBox( width: double.infinity, - height: project.actions.length * 22.0 + 18, + height: project.actions.length * 12.0 + 14, child: CustomPaint( size: Size.infinite, painter: _MiniBarPainter(project, t), ), ), - ], + ], + ), ), ); } @@ -783,37 +805,40 @@ class _MiniBarPainter extends CustomPainter { /// 逐行绘制动作色条、跨圈尾段与底部刻度。 @override void paint(Canvas canvas, Size size) { + final int n = project.actions.length; final double w = size.width - 4; - final double rh = 19; - for (int i = 0; i < project.actions.length; i++) { + // 行高按可用高度自适应,保证小预览里也排得下。 + final double pitch = n == 0 ? 12 : math.min(12, (size.height - 16) / n); + final double rh = math.max(pitch - 3, 4); + for (int i = 0; i < n; i++) { final Action a = project.actions[i]; - final double y = i * (rh + 3); + final double y = i * pitch; final double x1 = 2 + a.startAngle / 360 * w; final double x2 = 2 + math.min(a.endAngle, 360) / 360 * w; final RRect r = RRect.fromRectAndRadius( - Rect.fromLTWH(x1, y, math.max(x2 - x1, 2), rh - 4), - const Radius.circular(3), + Rect.fromLTWH(x1, y, math.max(x2 - x1, 2), rh), + const Radius.circular(2), ); canvas.drawRRect(r, Paint()..color = Color(a.color).withValues(alpha: 0.9)); if (a.wrap) { canvas.drawRRect( - RRect.fromRectAndRadius(Rect.fromLTWH(2, y, (a.endAngle - 360) / 360 * w, rh - 4), const Radius.circular(3)), + RRect.fromRectAndRadius(Rect.fromLTWH(2, y, (a.endAngle - 360) / 360 * w, rh), const Radius.circular(2)), Paint()..color = Color(a.color).withValues(alpha: t.tailOp), ); } } - final double baseY = project.actions.length * (rh + 3) + 4; + final double baseY = n * pitch + 3; canvas.drawLine(Offset(2, baseY), Offset(size.width - 2, baseY), Paint()..color = t.line2..strokeWidth = 1); final TextPainter tp = TextPainter( - text: TextSpan(text: '0.0 ${timeUnitLabel(project.units.timeUnit)}', style: TextStyle(color: t.dim, fontSize: 10)), + text: TextSpan(text: '0.0 ${timeUnitLabel(project.units.timeUnit)}', style: TextStyle(color: t.dim, fontSize: 9)), textDirection: TextDirection.ltr, )..layout(); - tp.paint(canvas, Offset(2, baseY + 4)); + tp.paint(canvas, Offset(2, baseY + 2)); final TextPainter tp2 = TextPainter( - text: TextSpan(text: tfmt(project.cycle.durationMs, project.units), style: TextStyle(color: t.dim, fontSize: 10)), + text: TextSpan(text: tfmt(project.cycle.durationMs, project.units), style: TextStyle(color: t.dim, fontSize: 9)), textDirection: TextDirection.ltr, )..layout(); - tp2.paint(canvas, Offset(size.width - 2 - tp2.width, baseY + 4)); + tp2.paint(canvas, Offset(size.width - 2 - tp2.width, baseY + 2)); } /// 预览始终重绘(数据实时联动)。 @@ -821,36 +846,48 @@ class _MiniBarPainter extends CustomPainter { bool shouldRepaint(covariant _MiniBarPainter old) => true; } -/// 圆周节拍缩略预览卡(在条形视图右下角显示)。 +/// 圆周节拍缩略预览卡(在条形视图右下角显示);点击切换到圆周视图。 class _CircularPreviewCard extends StatelessWidget { - const _CircularPreviewCard({required this.t, required this.project}); + const _CircularPreviewCard({required this.t, required this.c}); /// 主题令牌。 final Tokens t; - /// 当前项目。 - final Project project; + /// 全局应用控制器(用于切换视图)。 + final AppController c; - /// 渲染圆周缩略预览。 + /// 渲染紧凑的圆周缩略预览,整卡可点击切换视图。 @override Widget build(BuildContext context) { - return _Card( - t: t, - width: 300, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('圆周节拍预览(实时联动)', style: TextStyle(color: t.sub, fontSize: 11, fontWeight: FontWeight.w600)), - const SizedBox(height: 8), - SizedBox( - width: double.infinity, - height: 250, - child: CustomPaint( - size: Size.infinite, - painter: _MiniCircularPainter(project, t), + final Project project = c.project; + return InkWell( + onTap: () => c.setViewMode(ViewMode.circular), + borderRadius: BorderRadius.circular(10), + child: _Card( + t: t, + width: 190, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon(Icons.donut_large, size: 13, color: t.accent), + const SizedBox(width: 5), + Text('圆周预览', style: TextStyle(color: t.sub, fontSize: 10.5, fontWeight: FontWeight.w600)), + const Spacer(), + Icon(Icons.chevron_right, size: 14, color: t.dim), + ], ), - ), - Text('12 点钟起始 · 顺时针 · 每层一环', style: TextStyle(color: t.dim, fontSize: 10)), - ], + const SizedBox(height: 6), + SizedBox( + width: double.infinity, + height: 150, + child: CustomPaint( + size: Size.infinite, + painter: _MiniCircularPainter(project, t), + ), + ), + ], + ), ), ); }