* Draw the contents of this view in the given canvas `context`. * * Defaults to drawing this view's `subviews`. * * To be overwritten by subclasses that wish to draw custom content. * * NOTE: Do not call directly! Use `displayIfNeeded`. * * @see displayIfNeeded
(context: CanvasRenderingContext2D, viewRefs: ViewRefs)
| 263 | * @see displayIfNeeded |
| 264 | */ |
| 265 | draw(context: CanvasRenderingContext2D, viewRefs: ViewRefs) { |
| 266 | const {subviews, visibleArea} = this; |
| 267 | subviews.forEach(subview => { |
| 268 | if (rectIntersectsRect(visibleArea, subview.visibleArea)) { |
| 269 | subview.displayIfNeeded(context, viewRefs); |
| 270 | } |
| 271 | }); |
| 272 | |
| 273 | const backgroundColor = this._backgroundColor; |
| 274 | if (backgroundColor !== null) { |
| 275 | const desiredSize = this.desiredSize(); |
| 276 | if (visibleArea.size.height > desiredSize.height) { |
| 277 | context.fillStyle = backgroundColor; |
| 278 | context.fillRect( |
| 279 | visibleArea.origin.x, |
| 280 | visibleArea.origin.y + desiredSize.height, |
| 281 | visibleArea.size.width, |
| 282 | visibleArea.size.height - desiredSize.height, |
| 283 | ); |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Handle an `interaction`. |
no test coverage detected