Example #1
0
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
	}
}
Example #2
0
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
	}
}
Example #3
0
func (self *Frame) SetBounds(bounds geom.Rect) {
	self.Control.SetBounds(bounds)
	bounds.X = 0
	bounds.Y = 0
	self.Layout().Layout(bounds, self.Children()...)
}
Example #4
0
func RedrawRect(widget Widget, rect geom.Rect) {
	bounds := widget.Bounds()
	rect.X += bounds.X
	rect.Y += bounds.Y
	redraw(widget, rect)
}