Widget local rendering PushBounds pushes our bounding box bounds onto the bounds stack if they are non-empty. This automatically limits our drawing to our own bounding box. This must be called as the first step in Render implementations. It returns whether the new bounds are empty or not; if they
()
| 284 | // Render implementations. It returns whether the new bounds are |
| 285 | // empty or not; if they are empty, then don't render. |
| 286 | func (wb *WidgetBase) PushBounds() bool { |
| 287 | if wb == nil || wb.This == nil { |
| 288 | return false |
| 289 | } |
| 290 | wb.needsRender = false // done! |
| 291 | if !wb.IsVisible() { // checks deleted etc |
| 292 | return false |
| 293 | } |
| 294 | if wb.Geom.TotalBBox.Empty() { |
| 295 | if DebugSettings.RenderTrace { |
| 296 | fmt.Printf("Render empty bbox: %v at %v\n", wb.Path(), wb.Geom.TotalBBox) |
| 297 | } |
| 298 | return false |
| 299 | } |
| 300 | wb.Styles.ComputeActualBackground(wb.parentActualBackground()) |
| 301 | pc := &wb.Scene.PaintContext |
| 302 | if pc.State == nil || pc.Image == nil { |
| 303 | return false |
| 304 | } |
| 305 | if len(pc.BoundsStack) == 0 && wb.Parent != nil { |
| 306 | wb.firstRender = true |
| 307 | // push our parent's bounds if we are the first to render |
| 308 | pw := wb.parentWidget() |
| 309 | pc.PushBoundsGeom(pw.Geom.TotalBBox, pw.Styles.Border.Radius.Dots()) |
| 310 | } else { |
| 311 | wb.firstRender = false |
| 312 | } |
| 313 | pc.PushBoundsGeom(wb.Geom.TotalBBox, wb.Styles.Border.Radius.Dots()) |
| 314 | pc.Defaults() // start with default values |
| 315 | if DebugSettings.RenderTrace { |
| 316 | fmt.Printf("Render: %v at %v\n", wb.Path(), wb.Geom.TotalBBox) |
| 317 | } |
| 318 | return true |
| 319 | } |
| 320 | |
| 321 | // PopBounds pops our bounding box bounds. This is the last step |
| 322 | // in Render implementations after rendering children. |
no test coverage detected