layout: take a size, not constraints in Context.Reset

Taking a constraint in Reset smells too much of a layout operation,
whereas a size is simpler and only serves to set the context constraints
to something sensible.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-02 15:31:52 +02:00
parent b0e7b165b6
commit e031308172
2 changed files with 11 additions and 15 deletions
+4 -3
View File
@@ -102,9 +102,10 @@ func (s *Context) Layout(cs Constraints, w Widget) Dimensions {
return s.Dimensions
}
// Reset the context.
func (c *Context) Reset(cfg Config, cs Constraints) {
c.Constraints = cs
// Reset the context. The constraints' minimum and maximum values are
// set to the size.
func (c *Context) Reset(cfg Config, size image.Point) {
c.Constraints = RigidConstraints(size)
c.Dimensions = Dimensions{}
c.Config = cfg
if c.Ops == nil {