Refactor layout pipeline, add KEY5 regression, and fix tooltip hide
This commit is contained in:
+42
-24
@@ -62,6 +62,9 @@ inline void TabControl::initTabBar()
|
||||
inline void TabControl::initTabPage()
|
||||
{
|
||||
if (controls.empty())return;
|
||||
// TabControl 内部页签页仍然保留专用布局:
|
||||
// 这里负责把“当前选项卡容器矩形”拆分成页签栏和页面区,
|
||||
// 不把这部分细节下放到通用布局解算器里。
|
||||
//子控件坐标原点
|
||||
int nX = 0;
|
||||
int nY = 0;
|
||||
@@ -148,6 +151,15 @@ inline void TabControl::initTabPage()
|
||||
}
|
||||
}
|
||||
|
||||
void TabControl::refreshRuntimeLayout()
|
||||
{
|
||||
// 这是 TabControl 的内部专用布局入口:
|
||||
// 外层先通过统一解算得到 TabControl 自身矩形,
|
||||
// 再由这里继续安置页签按钮和页面区。
|
||||
initTabBar();
|
||||
initTabPage();
|
||||
}
|
||||
|
||||
TabControl::TabControl() :Canvas()
|
||||
{
|
||||
this->id = "TabControl";
|
||||
@@ -165,28 +177,38 @@ TabControl::~TabControl()
|
||||
|
||||
void TabControl::setX(int x)
|
||||
{
|
||||
this->x = x;
|
||||
initTabBar();
|
||||
initTabPage();
|
||||
dirty = true;
|
||||
for (auto& c : controls)
|
||||
{
|
||||
c.first->onWindowResize();
|
||||
c.second->onWindowResize();
|
||||
}
|
||||
applyRuntimeRectDirect(x, y, width, height);
|
||||
refreshRuntimeLayout();
|
||||
onWindowResize();
|
||||
}
|
||||
|
||||
void TabControl::setY(int y)
|
||||
{
|
||||
this->y = y;
|
||||
initTabBar();
|
||||
initTabPage();
|
||||
dirty = true;
|
||||
for (auto& c : controls)
|
||||
{
|
||||
c.first->onWindowResize();
|
||||
c.second->onWindowResize();
|
||||
}
|
||||
applyRuntimeRectDirect(x, y, width, height);
|
||||
refreshRuntimeLayout();
|
||||
onWindowResize();
|
||||
}
|
||||
|
||||
void TabControl::setWidth(int width)
|
||||
{
|
||||
applyRuntimeRectDirect(x, y, width, height);
|
||||
refreshRuntimeLayout();
|
||||
onWindowResize();
|
||||
}
|
||||
|
||||
void TabControl::setHeight(int height)
|
||||
{
|
||||
applyRuntimeRectDirect(x, y, width, height);
|
||||
refreshRuntimeLayout();
|
||||
onWindowResize();
|
||||
}
|
||||
|
||||
void TabControl::applyResolvedLayoutRect(const StellarX::ResolvedLayoutRect& rect)
|
||||
{
|
||||
// TabControl 作为外层控件接入统一解算;
|
||||
// 但页签栏和页面区仍由自身专用逻辑继续排布。
|
||||
applyRuntimeRectDirect(rect.worldX, rect.worldY, rect.width, rect.height);
|
||||
refreshRuntimeLayout();
|
||||
}
|
||||
|
||||
void TabControl::draw()
|
||||
@@ -348,18 +370,14 @@ void TabControl::setIsVisible(bool visible)
|
||||
|
||||
void TabControl::onWindowResize()
|
||||
{
|
||||
// 调用基类的窗口变化处理,丢弃快照并标记脏
|
||||
// 本轮不再在 onWindowResize 中重做页签布局,
|
||||
// 这里只负责失效快照、标脏,并把 resize 语义向页签按钮和页面传递。
|
||||
Control::onWindowResize();
|
||||
// 根据当前 TabControl 的新尺寸重新计算页签栏和页面区域
|
||||
initTabBar();
|
||||
initTabPage();
|
||||
// 转发窗口尺寸变化给所有页签按钮和页面
|
||||
for (auto& c : controls)
|
||||
{
|
||||
c.first->onWindowResize();
|
||||
c.second->onWindowResize();
|
||||
}
|
||||
// 尺寸变化后需要重绘自身
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user