mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
feat(tracker/gioui): add scrollbars to menus
This commit is contained in:
parent
64270eaf68
commit
d6abb14b08
@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## Unreleased
|
||||
### Added
|
||||
- Scroll bars to menus, shown when a menu is too long to fit.
|
||||
- Save the GUI state periodically to a recovery file and load it on
|
||||
startup of the app, if present. The recovery files are located in the
|
||||
app config directory (e.g. AppData/Roaming/Sointu on Windows).
|
||||
|
@ -21,6 +21,7 @@ type Menu struct {
|
||||
clicks []int
|
||||
hover int
|
||||
list layout.List
|
||||
scrollBar ScrollBar
|
||||
}
|
||||
|
||||
type MenuStyle struct {
|
||||
@ -80,6 +81,9 @@ func (m *MenuStyle) Layout(gtx C, items ...MenuItem) D {
|
||||
}
|
||||
}
|
||||
m.Menu.list.Axis = layout.Vertical
|
||||
m.Menu.scrollBar.Axis = layout.Vertical
|
||||
return layout.Stack{Alignment: layout.SE}.Layout(gtx,
|
||||
layout.Expanded(func(gtx C) D {
|
||||
return m.Menu.list.Layout(gtx, len(items), func(gtx C, i int) D {
|
||||
defer op.Offset(image.Point{}).Push(gtx.Ops).Pop()
|
||||
var macro op.MacroOp
|
||||
@ -130,6 +134,11 @@ func (m *MenuStyle) Layout(gtx C, items ...MenuItem) D {
|
||||
}
|
||||
return dims
|
||||
})
|
||||
}),
|
||||
layout.Expanded(func(gtx C) D {
|
||||
return m.Menu.scrollBar.Layout(gtx, unit.Dp(10), len(items), &m.Menu.list.Position)
|
||||
}),
|
||||
)
|
||||
}
|
||||
popup := Popup(&m.Menu.Visible)
|
||||
popup.NE = unit.Dp(0)
|
||||
|
Loading…
Reference in New Issue
Block a user