Skip to main content

drawChildren 绘制所有子元素

drawChildren

类型: MethodDeclaration

所属类: WindowElement

定义位置: ui.ts

描述

绘制所有子元素

返回值

类型: void

源代码

位置: 第 5866 行

protected drawChildren(): void {
if (this.overflow === 'visible') {
return super.drawChildren()
}
switch (this.layout) {
case 'normal':
return super.drawChildren()
case 'horizontal-grid': {
const unitWidth = this.gridWidth + this.gridGapX
const unitHeight = this.gridHeight + this.gridGapY
if (unitWidth * unitHeight === 0) {
return super.drawChildren()
}
const children = this.children
const scrollTop = this.scrollY - this.paddingY
const scrollBottom = scrollTop + this.height
const startRow = Math.floor(scrollTop / unitHeight)
const endRow = Math.ceil(scrollBottom / unitHeight)
const start = Math.max(startRow * this.columns, 0)
const end = Math.min(endRow * this.columns, children.length)
for (let i = start; i < end; i++) {
children[i].draw()
}
break
}
case 'vertical-grid': {
const unitWidth = this.gridWidth + this.gridGapX
const unitHeight = this.gridHeight + this.gridGapY
if (unitWidth * unitHeight === 0) {
return super.drawChildren()
}
const children = this.children
const scrollLeft = this.scrollX - this.paddingX
const scrollRight = scrollLeft + this.width
const startCol = Math.floor(scrollLeft / unitWidth)
const endCol = Math.ceil(scrollRight / unitWidth)
const start = Math.max(startCol * this.rows, 0)
const end = Math.min(endCol * this.rows, children.length)
for (let i = start; i < end; i++) {
children[i].draw()
}
break
}
}
}

文档生成时间:2025/7/7 12:07:07