Fix button timing and event decoding and avoid redundant menu refreshes

This commit is contained in:
maze committed 2026-10-29 19:07:17 +01:00
1 parent 62b32c15cf
commit 494fa41420
8 files changed
+276 -44

No files matched your search

+5 -1
View File
@@ -55,7 +55,7 @@ func (w *Menu) Refresh(ctx app.Context) bool {
)
if w.changed.CompareAndSwap(true, false) || w.buffer == nil || (w.curr != w.next && w.next != nil) {
if w.buffer == nil {
if w.buffer == nil || w.buffer.Bounds().Size() != size {
w.buffer = app.BufferFor(ctx.Display().ColorModel(), size)
w.Root.SetPageSize(size.Y / 16)
}
@@ -64,6 +64,8 @@ func (w *Menu) Refresh(ctx app.Context) bool {
w.curr, w.next = w.next, nil
}
w.curr.SetPageSize(size.Y / 16)
// Clear the buffer.
app.ImageClear(w.buffer)
@@ -102,6 +104,8 @@ func (w *Menu) Refresh(ctx app.Context) bool {
y := size.Y / len(menu.Items) * menu.Position
draw.Box(w.buffer, image.Rect(size.X-3, y, size.X, y+size.Y/len(menu.Items)), color.Gray{Y: 0x7f})
}
} else {
return false
}
app.ImageCopyBounds(ctx.Display(), w.buffer, bounds.Add(w.position.Load()))