feat(tracker): add some shadow to popups

This commit is contained in:
vsariola 2021-02-03 13:25:45 +02:00
parent fc9a6b6517
commit b0dac8454d
3 changed files with 18 additions and 0 deletions

View File

@ -16,6 +16,11 @@ type PopupStyle struct {
Visible *bool
Contents layout.Widget
SurfaceColor color.NRGBA
ShadowColor color.NRGBA
ShadowN unit.Value
ShadowE unit.Value
ShadowW unit.Value
ShadowS unit.Value
SE, SW, NW, NE unit.Value
}
@ -24,6 +29,11 @@ func Popup(visible *bool, contents layout.Widget) PopupStyle {
Visible: visible,
Contents: contents,
SurfaceColor: popupSurfaceColor,
ShadowColor: popupShadowColor,
ShadowN: unit.Dp(2),
ShadowE: unit.Dp(2),
ShadowS: unit.Dp(2),
ShadowW: unit.Dp(2),
SE: unit.Dp(6),
SW: unit.Dp(6),
NW: unit.Dp(6),
@ -58,6 +68,10 @@ func (s PopupStyle) Layout(gtx C) D {
NW: float32(gtx.Px(s.NW)),
NE: float32(gtx.Px(s.NE)),
}
rrect2 := rrect
rrect2.Rect.Min = rrect2.Rect.Min.Sub(f32.Pt(float32(gtx.Px(s.ShadowW)), float32(gtx.Px(s.ShadowN))))
rrect2.Rect.Max = rrect2.Rect.Max.Add(f32.Pt(float32(gtx.Px(s.ShadowE)), float32(gtx.Px(s.ShadowS))))
paint.FillShape(gtx.Ops, s.ShadowColor, rrect2.Op(gtx.Ops))
paint.FillShape(gtx.Ops, s.SurfaceColor, rrect.Op(gtx.Ops))
return D{Size: gtx.Constraints.Min}
}

View File

@ -59,6 +59,9 @@ func (t *Tracker) layoutSongButtons(gtx C) D {
}
fileMenu := Popup(&t.FileMenuVisible, menuContents)
fileMenu.NE = unit.Dp(0)
fileMenu.ShadowN = unit.Dp(0)
fileMenu.NW = unit.Dp(0)
saveBtnStyle := material.IconButton(t.Theme, t.SaveSongFileBtn, widgetForIcon(icons.ContentSave))
saveBtnStyle.Background = transparent

View File

@ -90,3 +90,4 @@ var instrumentSurfaceColor = color.NRGBA{R: 37, G: 37, B: 38, A: 255}
var songSurfaceColor = color.NRGBA{R: 37, G: 37, B: 38, A: 255}
var popupSurfaceColor = color.NRGBA{R: 45, G: 45, B: 46, A: 255}
var popupShadowColor = color.NRGBA{R: 0, G: 0, B: 0, A: 192}