Refactor layout pipeline, add KEY5 regression, and fix tooltip hide
This commit is contained in:
+6
-66
@@ -981,72 +981,12 @@ void Window::scheduleResizeFromModal(int w, int h)
|
||||
|
||||
void Window::adaptiveLayout(std::unique_ptr<Control>& c, const int finalH, const int finalW)
|
||||
{
|
||||
int origParentW = this->localwidth;
|
||||
int origParentH = this->localheight;
|
||||
if (c->getLayoutMode() == StellarX::LayoutMode::AnchorToEdges)
|
||||
{
|
||||
if ((StellarX::Anchor::Left == c->getAnchor_1() && StellarX::Anchor::Right == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::Right == c->getAnchor_1() && StellarX::Anchor::Left == c->getAnchor_2()))
|
||||
{
|
||||
int origRightDist = origParentW - (c->getLocalX() + c->getLocalWidth());
|
||||
int newWidth = finalW - c->getLocalX() - origRightDist;
|
||||
c->setWidth(newWidth);
|
||||
// 左侧距离固定,ctrl->x 保持为 localx 相对窗口左侧(父容器为窗口,偏移0)
|
||||
c->setX(c->getLocalX());
|
||||
}
|
||||
else if ((StellarX::Anchor::Left == c->getAnchor_1() && StellarX::Anchor::NoAnchor == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::NoAnchor == c->getAnchor_1() && StellarX::Anchor::Left == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::Left == c->getAnchor_1() && StellarX::Anchor::Left == c->getAnchor_2()))
|
||||
{
|
||||
// 仅左锚定:宽度固定不变
|
||||
c->setX(c->getLocalX());
|
||||
c->setWidth(c->getLocalWidth());
|
||||
}
|
||||
else if ((StellarX::Anchor::Right == c->getAnchor_1() && StellarX::Anchor::NoAnchor == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::NoAnchor == c->getAnchor_1() && StellarX::Anchor::Right == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::Right == c->getAnchor_1() && StellarX::Anchor::Right == c->getAnchor_2()))
|
||||
{
|
||||
int origRightDist = origParentW - (c->getLocalX() + c->getLocalWidth());
|
||||
c->setWidth(c->getLocalWidth()); // 宽度不变
|
||||
c->setX(finalW - origRightDist - c->getWidth());
|
||||
}
|
||||
else if (StellarX::Anchor::NoAnchor == c->getAnchor_1() && StellarX::Anchor::NoAnchor == c->getAnchor_2())
|
||||
{
|
||||
c->setX(c->getLocalX());
|
||||
c->setWidth(c->getLocalWidth());
|
||||
}
|
||||
|
||||
if ((StellarX::Anchor::Top == c->getAnchor_1() && StellarX::Anchor::Bottom == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::Bottom == c->getAnchor_1() && StellarX::Anchor::Top == c->getAnchor_2()))
|
||||
{
|
||||
// 上下锚定:高度随窗口变化
|
||||
int origBottomDist = origParentH - (c->getLocalY() + c->getLocalHeight());
|
||||
int newHeight = finalH - c->getLocalY() - origBottomDist;
|
||||
c->setHeight(newHeight);
|
||||
c->setY(c->getLocalY());
|
||||
}
|
||||
else if ((StellarX::Anchor::Top == c->getAnchor_1() && StellarX::Anchor::NoAnchor == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::NoAnchor == c->getAnchor_1() && StellarX::Anchor::Top == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::Top == c->getAnchor_1() && StellarX::Anchor::Top == c->getAnchor_2()))
|
||||
{
|
||||
c->setY(c->getLocalY());
|
||||
c->setHeight(c->getLocalHeight());
|
||||
}
|
||||
else if ((StellarX::Anchor::Bottom == c->getAnchor_1() && StellarX::Anchor::NoAnchor == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::NoAnchor == c->getAnchor_1() && StellarX::Anchor::Bottom == c->getAnchor_2())
|
||||
|| (StellarX::Anchor::Bottom == c->getAnchor_1() && StellarX::Anchor::Bottom == c->getAnchor_2()))
|
||||
{
|
||||
int origBottomDist = origParentH - (c->getLocalY() + c->getLocalHeight());
|
||||
c->setHeight(c->getLocalHeight());
|
||||
c->setY(finalH - origBottomDist - c->getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
// 垂直无锚点:默认为顶部定位,高度固定
|
||||
c->setY(c->getLocalY());
|
||||
c->setHeight(c->getLocalHeight());
|
||||
}
|
||||
}
|
||||
// 顶层窗口布局收口:
|
||||
// 先用统一解算器求出控件新的运行态矩形,再通知控件“外部环境已变化”。
|
||||
// onWindowResize() 负责快照失效/标脏,不再承担布局公式。
|
||||
const StellarX::ResolvedLayoutRect rect =
|
||||
c->resolveLayoutRect(this->localwidth, this->localheight, 0, 0, finalW, finalH);
|
||||
c->applyResolvedLayoutRect(rect);
|
||||
c->onWindowResize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user