Fix BottomBar X positioning to use visible window width

This commit is contained in:
Greg Pomerantz 2026-05-09 18:01:24 -04:00
parent 3a3a62a50c
commit 4cf8641bbd
2 changed files with 23 additions and 9 deletions

BIN
cmd/pad/pad Executable file

Binary file not shown.

View File

@ -163,20 +163,34 @@ func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar) {
drawY := unit.Dp(float64(drawYPx) / float64(scale)) drawY := unit.Dp(float64(drawYPx) / float64(scale))
fmt.Printf("[DEBUG drawBottomBar] drawY=%d (clamped from %d)\n", gtx.Dp(drawY), gtx.Dp(reg.Y)) fmt.Printf("[DEBUG drawBottomBar] drawY=%d (clamped from %d)\n", gtx.Dp(drawY), gtx.Dp(reg.Y))
// Use the BottomBar region for X positioning, clamped to visible window width.
// The region width (1520 DP = 3040px) exceeds the window width (780px).
regXPx := int(float32(reg.X) * scale)
windowW := gtx.Constraints.Max.X
// Clamp right edge to window width
rightXPx := regXPx + int(float32(reg.W)*scale)
if rightXPx > windowW {
rightXPx = windowW
}
barW := rightXPx - regXPx
// Left: Cursor position // Left: Cursor position
cursorX := reg.X + unit.Dp(8) cursorXPx := regXPx + int(8*scale)
fmt.Printf("[DEBUG drawBottomBar] cursor=(%d, %d) text=%q\n", gtx.Dp(cursorX), gtx.Dp(drawY), bb.CursorPos) cursorXDp := unit.Dp(float64(cursorXPx) / float64(scale))
r.drawText(gtx, r.shp, bb.CursorPos, r.theme.FontSize, cursorX, drawY, color.NRGBA{R: 0, G: 0, B: 0, A: 255}) fmt.Printf("[DEBUG drawBottomBar] cursor=(%d, %d) text=%q\n", cursorXPx, drawYPx, bb.CursorPos)
r.drawText(gtx, r.shp, bb.CursorPos, r.theme.FontSize, cursorXDp, drawY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
// Center: Byte position // Center: Byte position
byteX := reg.X + reg.W/2 - unit.Dp(60) // approximate center byteXPx := regXPx + barW/2 - int(60*scale)
fmt.Printf("[DEBUG drawBottomBar] byte=(%d, %d) text=%q\n", gtx.Dp(byteX), gtx.Dp(drawY), bb.BytePos) byteXDp := unit.Dp(float64(byteXPx) / float64(scale))
r.drawText(gtx, r.shp, bb.BytePos, r.theme.FontSize, byteX, drawY, color.NRGBA{R: 0, G: 0, B: 0, A: 255}) fmt.Printf("[DEBUG drawBottomBar] byte=(%d, %d) text=%q\n", byteXPx, drawYPx, bb.BytePos)
r.drawText(gtx, r.shp, bb.BytePos, r.theme.FontSize, byteXDp, drawY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
// Right: Word wrap button // Right: Word wrap button
wordWrapX := reg.X + reg.W - unit.Dp(80) wordWrapXPx := regXPx + barW - int(80*scale)
fmt.Printf("[DEBUG drawBottomBar] wordwrap=(%d, %d) text=%q\n", gtx.Dp(wordWrapX), gtx.Dp(drawY), "W:"+boolToString(bb.WordWrap)) wordWrapXDp := unit.Dp(float64(wordWrapXPx) / float64(scale))
r.drawText(gtx, r.shp, "W:"+boolToString(bb.WordWrap), r.theme.FontSize, wordWrapX, drawY, color.NRGBA{R: 0, G: 0, B: 0, A: 255}) fmt.Printf("[DEBUG drawBottomBar] wordwrap=(%d, %d) text=%q\n", wordWrapXPx, drawYPx, "W:"+boolToString(bb.WordWrap))
r.drawText(gtx, r.shp, "W:"+boolToString(bb.WordWrap), r.theme.FontSize, wordWrapXDp, drawY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
} }
func (r *Renderer) drawButton(gtx layout.Context, btn Button) { func (r *Renderer) drawButton(gtx layout.Context, btn Button) {