Beispiel #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
	}
}
Beispiel #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
	}
}
Beispiel #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()...)
}
Beispiel #4
0
func RedrawRect(widget Widget, rect geom.Rect) {
	bounds := widget.Bounds()
	rect.X += bounds.X
	rect.Y += bounds.Y
	redraw(widget, rect)
}