Made Space() return the same Control repeatedly instead of making a new one each time to conserve memory. No future guarantees, however, so that is noted in the documentation as well.
This commit is contained in:
parent
194e4971b2
commit
d33008e85e
9
stack.go
9
stack.go
|
@ -178,8 +178,11 @@ func (s *Stack) preferredSize() (width int, height int) {
|
|||
// For a Stack, Space can be used to insert spaces in the beginning or middle of Stacks (Stacks by nature handle spaces at the end themselves). In order for this to work properly, make the Space stretchy.
|
||||
//
|
||||
// For a Grid, Space can be used to have an empty cell. A stretchy Grid cell with a Space can be used to anchor the perimeter of a Grid to the respective Window edges without making one of the other controls stretchy instead (leaving empty space in the Window otherwise). Otherwise, you do not need to do anything special for the Space to work (though remember that an entire row or column of Spaces will appear as having height or width zero, respectively, unless one is marked as stretchy).
|
||||
//
|
||||
// The value returned from Space() may or may not be unique.
|
||||
func Space() Control {
|
||||
// As above, a Stack with no controls draws nothing and reports no errors; its parent will still size it properly if made stretchy.
|
||||
// TODO just have one shared Space implementation control instead of making a new one each time?
|
||||
return newStack(horizontal)
|
||||
return space
|
||||
}
|
||||
|
||||
// As above, a Stack with no controls draws nothing and reports no errors; its parent will still size it properly if made stretchy.
|
||||
var space Control = newStack(horizontal)
|
||||
|
|
Loading…
Reference in New Issue