#include "UiBox.hpp" namespace jdi { void UiBoxTable::Clear() { m_boxes.clear(); m_occluders.clear(); m_layer = 0; m_clip = gd::RectF(); } void UiBoxTable::OnTextRect(const gd::RectF& rect) { // 文本用固定层级 4:它总是"最里层"的元素(复选框里的字、行里的信号名…)。 Add(rect, 4); } void UiBoxTable::Add(const gd::RectF& rect, int depth) { if (!(rect.Width > 0.0f) || !(rect.Height > 0.0f)) { return; // 空矩形(未布局 / 该元素当前不显示)不登记。 } if (m_clip.Width > 0.0f && m_clip.Height > 0.0f) { // 与所属组件的区域无交集 ⇒ 已经完全滚出地盘,不必登记(也避免越界登记到邻居的地盘上)。 if (rect.X + rect.Width <= m_clip.X || rect.X >= m_clip.X + m_clip.Width || rect.Y + rect.Height <= m_clip.Y || rect.Y >= m_clip.Y + m_clip.Height) { return; } } UiBox box; box.rect = rect; box.clip = m_clip; box.depth = (depth < 0) ? 0 : depth; box.layer = m_layer; m_boxes.push_back(box); } void UiBoxTable::AddAll(const std::vector& rects, int depth) { for (const gd::RectF& rect : rects) { Add(rect, depth); } } void UiBoxTable::AddOccluder(const gd::RectF& rect) { if (!(rect.Width > 0.0f) || !(rect.Height > 0.0f)) { return; } Occluder occluder; occluder.rect = rect; occluder.layer = m_layer; m_occluders.push_back(occluder); } } // namespace jdi