feat(ui): handle HitRectInsets in CSimpleFrame::LoadXML

This commit is contained in:
fallenoak 2025-12-04 20:01:30 -06:00
parent 3dc6b4373e
commit 45838c6897
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 18 additions and 1 deletions

View File

@ -265,7 +265,11 @@ void CSimpleFrame::LoadXML(XMLNode* node, CStatus* status) {
}
if (!SStrCmpI(child->GetName(), "HitRectInsets", 0x7FFFFFFFu)) {
// TODO
float left, right, top, bottom;
if (LoadXML_Insets(child, left, right, top, bottom, status)) {
this->SetHitRectInsets(left, right, top, bottom);
}
}
if (!SStrCmpI(child->GetName(), "Layers", 0x7FFFFFFFu)) {
@ -1419,6 +1423,18 @@ void CSimpleFrame::SetHitRect() {
this->m_hitRect.maxY = this->m_rect.maxY - this->m_hitOffset.maxY * this->m_layoutScale;
}
void CSimpleFrame::SetHitRectInsets(float left, float right, float top, float bottom) {
this->m_hitOffset.minX = left;
this->m_hitOffset.maxX = right;
this->m_hitOffset.maxY = top;
this->m_hitOffset.minY = bottom;
this->m_hitRect.minX = this->m_rect.minX + (left * this->m_layoutScale);
this->m_hitRect.maxX = this->m_rect.maxX - (right * this->m_layoutScale);
this->m_hitRect.maxY = this->m_rect.maxY - (top * this->m_layoutScale);
this->m_hitRect.minY = this->m_rect.minY + (bottom * this->m_layoutScale);
}
void CSimpleFrame::SetParent(CSimpleFrame* parent) {
if (this->m_parent == parent) {
return;

View File

@ -159,6 +159,7 @@ class CSimpleFrame : public CScriptRegion {
bool SetFrameScale(float scale, bool force);
void SetFrameStrata(FRAME_STRATA strata);
void SetHitRect();
void SetHitRectInsets(float left, float right, float top, float bottom);
void SetParent(CSimpleFrame* parent);
void Show();
int32_t TestHitRect(const C2Vector& pt);