| 1269 | this.onChange(); |
| 1270 | } |
| 1271 | render() |
| 1272 | { |
| 1273 | super.render(); |
| 1274 | if (this.checked) |
| 1275 | { |
| 1276 | const p = this.cornerRadius / min(this.size.x, this.size.y) * 2; |
| 1277 | const length = lerp(1, 2**.5/2, p) / 2; |
| 1278 | let s = this.size.scale(length); |
| 1279 | uiSystem.drawLine(this.pos.add(s.multiply(vec2(-1))), this.pos.add(s.multiply(vec2(1))), this.lineWidth, this.lineColor); |
| 1280 | uiSystem.drawLine(this.pos.add(s.multiply(vec2(-1,1))), this.pos.add(s.multiply(vec2(1,-1))), this.lineWidth, this.lineColor); |
| 1281 | } |
| 1282 | |
| 1283 | // draw the text next to the checkbox |
| 1284 | const textSize = this.getTextSize(); |
| 1285 | const pos = this.pos.add(vec2(this.size.x,0)); |
| 1286 | uiSystem.drawText(this.text, pos, textSize, |
| 1287 | this.textColor, this.textLineWidth, this.textLineColor, 'left', this.font, this.fontStyle, false, this.textShadow); |
| 1288 | } |
| 1289 | } |
| 1290 | |
| 1291 | /////////////////////////////////////////////////////////////////////////////// |