Refactor layout pipeline, add KEY5 regression, and fix tooltip hide
This commit is contained in:
@@ -37,10 +37,12 @@ class Window;
|
||||
|
||||
class Control
|
||||
{
|
||||
friend class Window;
|
||||
friend class Canvas;
|
||||
protected:
|
||||
std::string id; // 控件ID
|
||||
int localx, x, localy, y; // 左上角坐标
|
||||
int localWidth, width, localHeight, height; // 控件尺寸
|
||||
int localx, x, localy, y; // local* 为设计态父局部坐标,x/y 为运行态世界坐标
|
||||
int localWidth, width, localHeight, height; // local* 为设计态尺寸,width/height 为运行态尺寸
|
||||
Control* parent = nullptr; // 父控件
|
||||
Window* hostWindow = nullptr; // 宿主窗口(顶层由 Window 注入,子控件可沿 parent 回溯)
|
||||
bool dirty = true; // 是否重绘
|
||||
@@ -49,8 +51,15 @@ protected:
|
||||
|
||||
/* == 布局模式 == */
|
||||
StellarX::LayoutMode layoutMode = StellarX::LayoutMode::Fixed; // 布局模式
|
||||
StellarX::Anchor anchor_1 = StellarX::Anchor::Top; // 锚点
|
||||
StellarX::Anchor anchor_2 = StellarX::Anchor::Right; // 锚点
|
||||
StellarX::Anchor anchor_1 = StellarX::Anchor::Top; // 旧版兼容锚点 1
|
||||
StellarX::Anchor anchor_2 = StellarX::Anchor::Right; // 旧版兼容锚点 2
|
||||
// 新布局模型:内部统一使用“水平轴 + 垂直轴”的规格描述,不再直接依赖旧锚点求解。
|
||||
StellarX::LayoutSpec layoutSpec{
|
||||
{ false, true, StellarX::AxisSizePolicy::FixedSize, StellarX::AxisAlignPolicy::End },
|
||||
{ true, false, StellarX::AxisSizePolicy::FixedSize, StellarX::AxisAlignPolicy::Start }
|
||||
};
|
||||
// 控件能力边界:用于限制某些控件在特定轴上是否允许 Stretch。
|
||||
StellarX::LayoutCapability layoutCapability{};
|
||||
|
||||
/* == 背景快照 == */
|
||||
std::unique_ptr<IMAGE> saveBkImage;
|
||||
@@ -115,10 +124,10 @@ public:
|
||||
int getLocalRight() const { return localx + localWidth; }
|
||||
int getLocalBottom() const { return localy + localHeight; }
|
||||
|
||||
virtual void setX(int x) { this->x = x; dirty = true; }
|
||||
virtual void setY(int y) { this->y = y; dirty = true; }
|
||||
virtual void setWidth(int width) { this->width = width; dirty = true; }
|
||||
virtual void setHeight(int height) { this->height = height; dirty = true; }
|
||||
virtual void setX(int x);
|
||||
virtual void setY(int y);
|
||||
virtual void setWidth(int width);
|
||||
virtual void setHeight(int height);
|
||||
public:
|
||||
|
||||
virtual void draw() = 0;
|
||||
@@ -153,7 +162,20 @@ public:
|
||||
StellarX::Anchor getAnchor_1() const;
|
||||
StellarX::Anchor getAnchor_2() const;
|
||||
StellarX::LayoutMode getLayoutMode() const;
|
||||
// 获取内部统一布局规格;供 Window / Canvas 等统一解算入口使用。
|
||||
const StellarX::LayoutSpec& getLayoutSpec() const;
|
||||
// 获取控件能力边界;用于判断某个轴是否允许 Stretch。
|
||||
const StellarX::LayoutCapability& getLayoutCapability() const;
|
||||
// 显式将当前运行态矩形提交为新的设计基线。普通 resize / 重排过程中不得自动调用。
|
||||
void commitCurrentGeometryAsDesignRect();
|
||||
protected:
|
||||
// 第 1 层:根据父设计尺寸、父当前尺寸和本控件设计矩形,解算出当前运行态局部矩形。
|
||||
StellarX::ResolvedLayoutRect resolveLayoutRect(int parentDesignW, int parentDesignH,
|
||||
int parentWorldX, int parentWorldY, int parentCurrentW, int parentCurrentH) const;
|
||||
// 内部受控路径:把统一解算结果应用到运行态矩形。不要把公开 setter 当成纯赋值接口来复用。
|
||||
virtual void applyResolvedLayoutRect(const StellarX::ResolvedLayoutRect& rect);
|
||||
// 最底层运行态赋值入口:仅修改运行态矩形,不回写 local*。
|
||||
void applyRuntimeRectDirect(int worldX, int worldY, int width, int height);
|
||||
void saveStyle();
|
||||
void restoreStyle();
|
||||
void resetEventVisualChanged() { eventVisualChanged = false; }
|
||||
|
||||
Reference in New Issue
Block a user