Expose layout API and refresh regression docs

This commit is contained in:
Codex
2026-05-09 19:15:23 +08:00
parent 738cf035bb
commit 2388f22c99
21 changed files with 2491 additions and 367 deletions
+68
View File
@@ -162,6 +162,14 @@ namespace
<< SX_T(" 原因=当前控件禁止该轴 Stretch", " reason=stretch disabled by capability");
}
}
void ActivateExplicitLayoutSpecMode(StellarX::LayoutMode& mode)
{
// 新公开布局 API 明确属于“按边约束解算”的语义层。
// 一旦调用,说明外部希望控件进入统一锚定布局模型,
// 因此直接切换到 AnchorToEdges,避免出现“策略已设但 layoutMode 仍是 Fixed”的半失效状态。
mode = StellarX::LayoutMode::AnchorToEdges;
}
}
StellarX::ControlText& StellarX::ControlText::operator=(const ControlText& text)
@@ -253,6 +261,56 @@ void Control::setAnchor(StellarX::Anchor anchor_1, StellarX::Anchor anchor_2)
this->layoutSpec.horizontal = BuildLegacyAxisSpec(anchor_1, anchor_2, StellarX::Anchor::Left, StellarX::Anchor::Right);
this->layoutSpec.vertical = BuildLegacyAxisSpec(anchor_1, anchor_2, StellarX::Anchor::Top, StellarX::Anchor::Bottom);
}
void Control::setHorizontalLayoutSpec(const StellarX::AxisLayoutSpec& spec)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.horizontal = spec;
}
void Control::setVerticalLayoutSpec(const StellarX::AxisLayoutSpec& spec)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.vertical = spec;
}
void Control::setHorizontalAnchors(bool left, bool right)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.horizontal.anchorStart = left;
this->layoutSpec.horizontal.anchorEnd = right;
}
void Control::setVerticalAnchors(bool top, bool bottom)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.vertical.anchorStart = top;
this->layoutSpec.vertical.anchorEnd = bottom;
}
void Control::setHorizontalSizePolicy(StellarX::AxisSizePolicy policy)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.horizontal.sizePolicy = policy;
}
void Control::setVerticalSizePolicy(StellarX::AxisSizePolicy policy)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.vertical.sizePolicy = policy;
}
void Control::setHorizontalAlignPolicy(StellarX::AxisAlignPolicy policy)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.horizontal.alignPolicy = policy;
}
void Control::setVerticalAlignPolicy(StellarX::AxisAlignPolicy policy)
{
ActivateExplicitLayoutSpecMode(this->layoutMode);
this->layoutSpec.vertical.alignPolicy = policy;
}
StellarX::Anchor Control::getAnchor_1() const
{
return this->anchor_1;
@@ -265,6 +323,16 @@ StellarX::LayoutMode Control::getLayoutMode() const
{
return this->layoutMode;
}
StellarX::AxisLayoutSpec Control::getHorizontalLayoutSpec() const
{
return layoutSpec.horizontal;
}
StellarX::AxisLayoutSpec Control::getVerticalLayoutSpec() const
{
return layoutSpec.vertical;
}
const StellarX::LayoutSpec& Control::getLayoutSpec() const
{
return layoutSpec;