Skip to content

Add PAGX auto layout system with constraint layout, flex container, and CLI tooling#3363

Merged
Hparty merged 369 commits intomainfrom
feature/dom_auto_layout
Apr 9, 2026
Merged

Add PAGX auto layout system with constraint layout, flex container, and CLI tooling#3363
Hparty merged 369 commits intomainfrom
feature/dom_auto_layout

Conversation

@domchen
Copy link
Copy Markdown
Collaborator

@domchen domchen commented Apr 8, 2026

为 PAGX 格式引入完整的自动布局系统,包括:

  • 实现 LayoutNode/LayoutElement 基础架构,支持约束布局(constraint layout)和弹性容器布局(flex layout)
  • 统一 Text/TextBox 测量与排版流程,将 TextBlob 生成延迟到渲染阶段
  • 重构 TextBox 继承自 Group,支持容器模式和内容驱动尺寸
  • 新增 pagx CLI 子命令:layout(布局检查)、lint(结构检查与优化建议)、verify(结构对比)、insert(SVG 内容插入)
  • 重写 GlyphRun 坐标系为统一管线(TextLayoutGlyphRun + RSXform),消除 measure/layout 重复代码
  • 大量 PAGX 示例和测试用例更新,覆盖约束优先级、flex 权重、内容测量等场景
  • 重构字体架构:FontConfig 替代 fontProvider,TextShaper 替代 HarfBuzzShaper
  • 改进 PAGX skill 文档,增加 CSS 映射、设计模式和生成指南

domchen added 30 commits April 1, 2026 12:22
…n pipeline and defer TextBlob generation to render phase.
domchen added 22 commits April 9, 2026 13:11
// Data Structures
// ============================================================================

struct LCRect {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里的LC缩写不直观,看不出表示什么含义

@@ -279,6 +296,14 @@ static std::string pointListToString(const std::vector<Point>& points) {
return result;
}

static bool shouldSkipPosition(const Point& position, const Point& defaultPos, float left,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI没遵守函数命名规范
函数参数按照left、top、right、bottom、centerX、centerY排列更符合习惯

@@ -152,6 +178,45 @@ static ColorMatrixFilter* parseColorMatrixFilter(const DOMNode* node, PAGXDocume
// Custom data parsing
//==============================================================================

static void serializeDOMNode(const DOMNode* node, std::string& output) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI可能忘记了约束规则,让它整体检查一遍

case TextAlign::Start:
break;
case TextAlign::Center:
anchorX = -maxLineWidth / 2;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里的设计是只考虑水平方向,暂时不管垂直方向吗?如果文本是沿任意路径排版的,anchor如何计算

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TextAlign的定义是行内对齐。垂直方向排版的时候maxLineWidth就是竖的

@Hparty Hparty merged commit 7d8901d into main Apr 9, 2026
9 checks passed
@Hparty Hparty deleted the feature/dom_auto_layout branch April 9, 2026 12:17
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.

4 participants