Files
MujicaUI/internal/layout.go
T

15 lines
398 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package internal
import "github.com/egoist/mygo/ui"
// Remeasure rebuilds the view when layout gives e another size than the w×h it was built for.
func Remeasure(c *ui.Context, e *ui.Element, w, h float32) *ui.Element {
return e.DrawOver(func(_ *ui.Painter, r ui.Rect) {
if abs(r.W-w) > 0.5 || abs(r.H-h) > 0.5 {
c.Invalidate()
}
})
}
func abs(v float32) float32 { return max(v, -v) }