func (self HorizontalLayout) Layout(bounds geom.Rect, widgets ...Widget) { n := len(widgets) bounds.W -= float64(n-1) * self.Spacing bounds.W /= float64(n) for _, w := range widgets { w.SetBounds(bounds) bounds.X += bounds.W + self.Spacing } }
func redraw(widget Widget, bounds geom.Rect) { if view, ok := widget.(*View); ok { view.redraw(bounds) return } if parent := widget.Parent(); parent != nil { r := parent.Bounds() bounds.X += r.X bounds.Y += r.Y redraw(parent, bounds) return } }
func (self *Frame) SetBounds(bounds geom.Rect) { self.Control.SetBounds(bounds) bounds.X = 0 bounds.Y = 0 self.Layout().Layout(bounds, self.Children()...) }
func RedrawRect(widget Widget, rect geom.Rect) { bounds := widget.Bounds() rect.X += bounds.X rect.Y += bounds.Y redraw(widget, rect) }