atomize-element-interface #3
@ -203,7 +203,7 @@ func (window *Window) redrawChildEntirely () {
|
|||||||
|
|
||||||
func (window *Window) resizeChildToFit () {
|
func (window *Window) resizeChildToFit () {
|
||||||
window.skipChildDrawCallback = true
|
window.skipChildDrawCallback = true
|
||||||
if child, ok := window.child.(tomo.Expanding); ok {
|
if child, ok := window.child.(tomo.Flexible); ok {
|
||||||
minimumHeight := child.MinimumHeightFor(window.metrics.width)
|
minimumHeight := child.MinimumHeightFor(window.metrics.width)
|
||||||
_, minimumWidth := child.MinimumSize()
|
_, minimumWidth := child.MinimumSize()
|
||||||
|
|
||||||
|
@ -183,9 +183,9 @@ type MouseTarget interface {
|
|||||||
HandleScroll (x, y int, deltaX, deltaY float64)
|
HandleScroll (x, y int, deltaX, deltaY float64)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expanding represents an element who's preferred minimum height can change in
|
// Flexible represents an element who's preferred minimum height can change in
|
||||||
// response to its width.
|
// response to its width.
|
||||||
type Expanding interface {
|
type Flexible interface {
|
||||||
Element
|
Element
|
||||||
|
|
||||||
// HeightForWidth returns what the element's minimum height would be if
|
// HeightForWidth returns what the element's minimum height would be if
|
||||||
@ -200,6 +200,6 @@ type Expanding interface {
|
|||||||
// minimum size that the element may be resized to.
|
// minimum size that the element may be resized to.
|
||||||
//
|
//
|
||||||
// It is important to note that if a parent container checks for
|
// It is important to note that if a parent container checks for
|
||||||
// expanding chilren, it itself will likely need to be expanding.
|
// flexible chilren, it itself will likely need to be flexible.
|
||||||
MinimumHeightFor (width int) (height int)
|
MinimumHeightFor (width int) (height int)
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,10 @@ func (layout Vertical) Arrange (entries []tomo.LayoutEntry, width, height int) {
|
|||||||
freeSpace := height
|
freeSpace := height
|
||||||
expandingElements := 0
|
expandingElements := 0
|
||||||
|
|
||||||
|
// TODO: find the width first, then store the minumum height of
|
||||||
|
// everything in a list, then arrange everything.
|
||||||
|
// minimumHeights := make([]int, len(entries))
|
||||||
|
|
||||||
// count the number of expanding elements and the amount of free space
|
// count the number of expanding elements and the amount of free space
|
||||||
// for them to collectively occupy
|
// for them to collectively occupy
|
||||||
for index, entry := range entries {
|
for index, entry := range entries {
|
||||||
|
Reference in New Issue
Block a user