MCPcopy Create free account
hub / github.com/cogentcore/core / PushBounds

Method PushBounds

core/render.go:286–319  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

284// Render implementations. It returns whether the new bounds are
285// empty or not; if they are empty, then don't render.
286func (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.

Callers 4

RenderWidgetMethod · 0.95
RenderWidgetMethod · 0.45
RenderWidgetMethod · 0.45
RenderWidgetMethod · 0.45

Calls 9

IsVisibleMethod · 0.95
parentWidgetMethod · 0.95
PushBoundsGeomMethod · 0.80
DefaultsMethod · 0.65
PrintfMethod · 0.45
PathMethod · 0.45
DotsMethod · 0.45

Tested by

no test coverage detected