mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 12:52:53 -05:00
refactor(tracker/gioui): Surface is given relative Height, not Gray
This commit is contained in:
parent
3495d91a4a
commit
fa9654d311
@ -9,25 +9,26 @@ import (
|
||||
)
|
||||
|
||||
type Surface struct {
|
||||
Gray int
|
||||
Inset layout.Inset
|
||||
Focus bool
|
||||
Height int
|
||||
Inset layout.Inset
|
||||
Focus bool
|
||||
}
|
||||
|
||||
func (s Surface) Layout(gtx C, widget layout.Widget) D {
|
||||
return layout.Background{}.Layout(gtx,
|
||||
func(gtx C) D {
|
||||
gray := s.Gray
|
||||
if s.Focus {
|
||||
gray += 8
|
||||
}
|
||||
gray8 := uint8(min(max(gray, 0), 255))
|
||||
color := color.NRGBA{R: gray8, G: gray8, B: gray8, A: 255}
|
||||
paint.FillShape(gtx.Ops, color, clip.Rect{Max: gtx.Constraints.Min}.Op())
|
||||
return D{Size: gtx.Constraints.Min}
|
||||
},
|
||||
func(gtx C) D {
|
||||
return s.Inset.Layout(gtx, widget)
|
||||
},
|
||||
)
|
||||
t := TrackerFromContext(gtx)
|
||||
t.surfaceHeight += s.Height
|
||||
bg := func(gtx C) D {
|
||||
gray := s.Height * 8
|
||||
if s.Focus {
|
||||
gray += 8
|
||||
}
|
||||
gray8 := uint8(min(max(gray, 0), 255))
|
||||
color := color.NRGBA{R: gray8, G: gray8, B: gray8, A: 255}
|
||||
paint.FillShape(gtx.Ops, color, clip.Rect{Max: gtx.Constraints.Min}.Op())
|
||||
return D{Size: gtx.Constraints.Min}
|
||||
}
|
||||
fg := func(gtx C) D { return s.Inset.Layout(gtx, widget) }
|
||||
dims := layout.Background{}.Layout(gtx, bg, fg)
|
||||
t.surfaceHeight -= s.Height
|
||||
return dims
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user