feat(UI): 布局边界改为四角粗/四边细包角 + 全元素覆盖 + 几何同源(RowRect O(1))
## 1. 边界观感:四角粗、四边细 用户反馈"边框就是实心矩形、粗细不一,效果不佳"。旧实现是四条等宽实心矩形 (层级 0 用 2px、其余 1px),同一元素的角与边粗细不一致,父子矩形共边时还会叠成更粗的一条。 新规则: - 四条边固定 1 设备像素(四条独立实心矩形;不用 DrawRectangle,笔宽奇偶会偏半像素); - 四个角额外加粗:层级 0 = 4px、其余 3px,沿水平/垂直各延伸 cornerLen(≤14px 且 ≤ 短边一半); - 层级 > 0 整体内缩 1px,父子矩形共边不再叠粗; - 绝不填充(几十层嵌套填充会把内容糊住); - 整像素对齐 + PixelOffsetModeNone + 关抗锯齿。 四角粗不只是观感:多条边重合时靠角的形状分辨层次(父=青蓝大包角、子=同位置品红小包角)。 ## 2. 协议:组件"收集 box",宿主统一绘制 UiComponent::CollectDebugBoxes(UiDebugBoxList&) 默认只登记 Area() UiWidget::CollectDebugBoxes(boxes, depth) 递归整棵控件树 Application::PaintLayoutBounds 收集后按 depth 升序一次性描边 刻意保持 box 为**值类型**而不是让它继承控件基类:PlotView 的 4 层位图缓存、 SignalPanel 的 192 槽行位图缓存都要求"绘制由组件自己负责",几何进继承体系会与 缓存键/失效体系打架。box 不参与绘制,因此能让绘制/命中/调试共用同一份几何。 ## 3. 覆盖补齐(此前大量元素被裹在外层单位里) - Toolbar:区域 / 每个按钮 / **按钮内容(文字或齿轮图标,新增 UiButtonWidget::ContentRect())** - TabBar:区域 / 标签条 / 新建按钮 / 每个 ✕ - SignalPanel:4 分区 + 筛选输入框/清空✕/全部显示 + 滚动轨道与滑块 + 样式区 5 行及其 12 色块/自定义/3 模式/3 调整/线宽与透明度轨道和数值 + 目标行/名称/GX 徽标 + **每个可见行**的折起三角/复选框/色块/名称/GX 徽标/✕ (组行另有组名/计数)+ 内联编辑框 - PlotView:区域 / 每个网格 / GX 徽标 / 装饰层矩形 / 图例托底+色块+文本 / **5 类浮动面板全部 20+ 字段**(标题/✕/折起三角/徽标/编辑行/按钮/内容区/滚动轨道与滑块 /透明度轨道与数值/两个开关/各行复选框与数值与滑轨与复位与名称与✕/分组栏/表头/固定点行) - PopupMenu:浮层 / 每个条目 / 可滚动可视区 / 轨道 / 滑块 / 二级子菜单与条目 - ColorPickerPopup:面板 / 标题 / 预览 / 色号 / 色域 / 色相条 / 3 条滑轨与数值 / 输入框 标签增加**尺寸门槛**(< 56×16 逻辑像素不画):复选框/色块/✕ 紧邻,逐个小框贴字会糊成一片。 ## 4. 设置按钮配色 + 齿轮图标 - ToolbarAction::SETTINGS 改为 primary = true,与「导入文件」同为强调色主按钮。 - 齿轮几何重做:齿占最外一圈(0.66R→1.0R)、外环中心线 0.54R/笔宽 0.24R、轴孔 0.17R。 旧版让齿从环中心线伸出,齿被环的描边吃掉 ⇒ 看起来只剩一个"甜甜圈"。 ## 5. 几何同源与性能 - RowRect(row) 原本每次调用都从头累加行高(O(row)),而画一行要调它 **5 次** (✕/徽标/名称/组计数/折起三角各一次)⇒ 200 行只见 30 行时每帧上万次加法, 命中测试(每次鼠标移动)同样走这条路。 新增 m_rowTop 前缀和(由 UpdateAnimGeometry() 统一重建)⇒ **O(1)**; 长度与行集合不一致时自动退回逐行累加(正确性优先)。 - ContentOffsetBeforeRow 同样改用前缀和。 - PanelBounds() 收敛 6 处重复的 (m_clientBounds.Width > 1.0f) ? m_clientBounds : m_area。 ## 6. 验证 - make release / make debug 零 error 零 warning;TargetCheck.exe 910,336 B(889 KiB < 900 KiB)。 - .preflight/lbcheck:21 / 21 PASS(含 bounds-off-restores-pixels:关闭后逐像素回到开启前)。 - Tools/rendercheck:「工具栏带以下」区域哈希 8/8 与上一轮**逐一相同** (证明本轮改动只落在工具栏带内);FUNC 断言 7/7 PASS。 - Tools/uicheck:69 passed / 0 failed。 ## 7. 文档 Documents/UI_Refactor_Plan.md / UI_Refactor_Progress.md / UI_Refactor_Report.md 追加第七阶段; Documents/agent_mem.md 同步变更日志与「2026-10-28 第九轮」硬规则与踩坑记录。
This commit is contained in:
1 parent
ab19a6e72e
commit
24706c906a
26 files changed
+1003
-163
No files matched your search
@@ -25,6 +25,8 @@
|
||||
namespace jdi
|
||||
{
|
||||
|
||||
class UiDebugBoxList;
|
||||
|
||||
/**
|
||||
* @brief 后台派生曲线计算完成后由 `PlotView` 投递给宿主的自定义消息。
|
||||
*
|
||||
@@ -205,15 +207,14 @@ namespace jdi
|
||||
void Paint(gd::Graphics& g) override;
|
||||
|
||||
/**
|
||||
* @brief 绘制绘图区区域与**每个网格波形区**的布局边界(调试用)。
|
||||
* @brief 收集绘图区区域、**每个网格**、GX 徽标、图例条目与浮动面板的布局边界(调试用)。
|
||||
*
|
||||
* 只上报“布局结构”(区域 + 网格),不上报曲线/胶囊/提示这类随数据变化的瞬态几何:
|
||||
* 后者每帧不同,画出来只是噪声。
|
||||
* 只上报“布局结构”,**不上报**曲线折线、取值胶囊、悬停提示这类随数据/鼠标逐帧变化的
|
||||
* 瞬态几何 —— 它们每帧都不同,叠上去只是噪声。
|
||||
*
|
||||
* @param [IN,OUT] g 绘图上下文。
|
||||
* @param [IN] scale DPI 缩放系数。
|
||||
* @param [IN,OUT] boxes 收集器。
|
||||
*/
|
||||
void PaintDebugBounds(gd::Graphics& g, float scale) override;
|
||||
void CollectDebugBoxes(UiDebugBoxList& boxes) override;
|
||||
|
||||
/**
|
||||
* @brief 处理鼠标移动(含拖拽)。
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "PlotViewInternal.hpp"
|
||||
|
||||
#include "UiDebugBounds.hpp"
|
||||
#include "UiLayout.hpp"
|
||||
|
||||
namespace jdi
|
||||
{
|
||||
@@ -562,14 +563,92 @@ namespace jdi
|
||||
UiText(g, message, m_fonts->ui, m_area, m_theme->textMuted, TextAlign::CENTER);
|
||||
}
|
||||
|
||||
void PlotView::PaintDebugBounds(gd::Graphics& g, float scale)
|
||||
void PlotView::CollectDebugBoxes(UiDebugBoxList& boxes)
|
||||
{
|
||||
UiComponent::PaintDebugBounds(g, scale);
|
||||
for (const LaneVisual& lane : m_lanes)
|
||||
UiComponent::CollectDebugBoxes(boxes);
|
||||
|
||||
// 层级 1:每个网格的波形区;层级 2:该网格的 GX 编号徽标与装饰层矩形。
|
||||
for (std::size_t index = 0; index < m_lanes.size(); ++index)
|
||||
{
|
||||
// 层级 1:网格波形区。不画曲线/取值胶囊/提示这类随数据变化的瞬态几何
|
||||
//(它们每帧都不同,叠上去只是噪声)。
|
||||
UiDebugPaintBounds(g, lane.rect, 1, scale);
|
||||
const LaneVisual& lane = m_lanes[index];
|
||||
boxes.Add(lane.rect, 1, L"lane " + std::to_wstring(index + 1));
|
||||
|
||||
// GX 编号徽标:矩形由 `LaneBadgeRect` 统一给出(绘制与命中都用它)。
|
||||
boxes.Add(LaneBadgeRect(static_cast<int>(index)), 2, L"G");
|
||||
|
||||
// 装饰层矩形(图例托底 / “无信号” / “更多”):绘制时已登记在 `m_decorRects`。
|
||||
for (const gd::RectF& decor : m_decorRects)
|
||||
{
|
||||
if (decor.Y >= lane.rect.Y && decor.Y < lane.rect.Y + lane.rect.Height)
|
||||
{
|
||||
boxes.Add(decor, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 层级 2/3:图例条目(托底 + 色块 + 文本),绘制时已登记在 `m_legendHits`。
|
||||
for (const LegendHit& hit : m_legendHits)
|
||||
{
|
||||
boxes.Add(hit.rect, 2, L"legend");
|
||||
boxes.Add(hit.swatch, 3);
|
||||
boxes.Add(hit.text, 3);
|
||||
}
|
||||
|
||||
// 层级 2/3/4:5 类实验性功能浮动面板的内部控件。
|
||||
// 这些矩形由 `EdgePanelLayoutFor` 统一算出(绘制与命中共用),一个循环即可全部上报。
|
||||
for (std::size_t index = 0; index < m_lanes.size(); ++index)
|
||||
{
|
||||
const int laneIndex = static_cast<int>(index);
|
||||
for (int kindValue = static_cast<int>(EdgePanelKind::COUNT);
|
||||
kindValue <= static_cast<int>(EdgePanelKind::MARK); ++kindValue)
|
||||
{
|
||||
const EdgePanelLayout layout =
|
||||
EdgePanelLayoutFor(laneIndex, static_cast<EdgePanelKind>(kindValue));
|
||||
if (!UiRectHasArea(layout.panel))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
boxes.Add(layout.panel, 2, L"panel");
|
||||
boxes.Add(layout.title, 3, L"title");
|
||||
boxes.Add(layout.close, 3, L"x");
|
||||
boxes.Add(layout.disclosure, 3);
|
||||
boxes.Add(layout.badge, 3, L"G");
|
||||
boxes.Add(layout.edit, 3);
|
||||
boxes.Add(layout.button, 3);
|
||||
boxes.Add(layout.content, 3, L"content");
|
||||
boxes.Add(layout.scrollTrack, 3, L"scroll");
|
||||
boxes.Add(layout.scrollThumb, 4);
|
||||
boxes.Add(layout.opacityTrack, 3, L"track");
|
||||
boxes.Add(layout.opacityValue, 3, L"value");
|
||||
boxes.Add(layout.showDelta, 3);
|
||||
boxes.Add(layout.showEnum, 3);
|
||||
|
||||
boxes.AddAll(layout.rowChecks, 4);
|
||||
boxes.AddAll(layout.rowPoints, 4);
|
||||
boxes.AddAll(layout.rowIterations, 4);
|
||||
boxes.AddAll(layout.rowStats, 4);
|
||||
boxes.AddAll(layout.rowLevelTracks, 4);
|
||||
boxes.AddAll(layout.rowLevelValues, 4);
|
||||
boxes.AddAll(layout.rowIterTracks, 4);
|
||||
boxes.AddAll(layout.rowIterValues, 4);
|
||||
boxes.AddAll(layout.rowLevelResets, 4);
|
||||
boxes.AddAll(layout.rowIterResets, 4);
|
||||
boxes.AddAll(layout.rowNameRects, 4);
|
||||
boxes.AddAll(layout.rowNameCloses, 4);
|
||||
|
||||
for (const EdgePanelLayout::MarkerGroup& group : layout.markerGroups)
|
||||
{
|
||||
boxes.Add(group.header, 3, L"group");
|
||||
boxes.Add(group.tableHeader, 3);
|
||||
boxes.Add(group.triangle, 4);
|
||||
boxes.Add(group.close, 4, L"x");
|
||||
}
|
||||
for (const EdgePanelLayout::MarkerRow& row : layout.markerRows)
|
||||
{
|
||||
boxes.Add(row.rect, 4, L"marker");
|
||||
boxes.Add(row.close, 4, L"x");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user