Clean up debug output and fix clip push/pop pattern
This commit is contained in:
parent
4a9253616d
commit
f433a992b7
|
|
@ -1,7 +1,6 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
|
|
@ -111,17 +110,15 @@ func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar, _ WindowConst
|
||||||
th := material.NewTheme()
|
th := material.NewTheme()
|
||||||
th.Shaper = r.shp
|
th.Shaper = r.shp
|
||||||
|
|
||||||
fmt.Printf("[DEBUG drawStatusBar] reg=(%d, %d, %d, %d)\n", reg.X, reg.Y, reg.W, reg.H)
|
|
||||||
|
|
||||||
// Draw light gray background
|
// Draw light gray background
|
||||||
bgColor := color.NRGBA{R: 230, G: 230, B: 230, A: 255}
|
bgColor := color.NRGBA{R: 230, G: 230, B: 230, A: 255}
|
||||||
clip.Rect{
|
bgClip := clip.Rect{
|
||||||
Min: image.Point{X: int(r.toPx(reg.X)), Y: int(r.toPx(reg.Y))},
|
Min: image.Point{X: int(r.toPx(reg.X)), Y: int(r.toPx(reg.Y))},
|
||||||
Max: image.Point{X: int(r.toPx(reg.X + reg.W)), Y: int(r.toPx(reg.Y + reg.H))},
|
Max: image.Point{X: int(r.toPx(reg.X + reg.W)), Y: int(r.toPx(reg.Y + reg.H))},
|
||||||
}.Push(gtx.Ops)
|
}.Push(gtx.Ops)
|
||||||
paint.ColorOp{Color: bgColor}.Add(gtx.Ops)
|
paint.ColorOp{Color: bgColor}.Add(gtx.Ops)
|
||||||
paint.PaintOp{}.Add(gtx.Ops)
|
paint.PaintOp{}.Add(gtx.Ops)
|
||||||
clip.Pop()
|
bgClip.Pop()
|
||||||
|
|
||||||
// Clip to status bar region for text (convert Dp to pixels)
|
// Clip to status bar region for text (convert Dp to pixels)
|
||||||
c := clip.Rect{
|
c := clip.Rect{
|
||||||
|
|
@ -186,28 +183,15 @@ func (r *Renderer) drawStatusBar(gtx layout.Context, sb StatusBar, _ WindowConst
|
||||||
func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar, constraints WindowConstraints) {
|
func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar, constraints WindowConstraints) {
|
||||||
reg := bb.Region()
|
reg := bb.Region()
|
||||||
|
|
||||||
fmt.Printf("[DEBUG drawBottomBar] reg=(%d, %d, %d, %d)\n", reg.X, reg.Y, reg.W, reg.H)
|
|
||||||
fmt.Printf("[DEBUG drawBottomBar] constraints=(%d, %d, %d, %d)\n",
|
|
||||||
constraints.Min.X, constraints.Min.Y,
|
|
||||||
constraints.Max.X, constraints.Max.Y)
|
|
||||||
fmt.Printf("[DEBUG drawBottomBar] scale=%f\n", r.scale)
|
|
||||||
|
|
||||||
// Draw light gray background
|
// Draw light gray background
|
||||||
bgColor := color.NRGBA{R: 230, G: 230, B: 230, A: 255}
|
bgColor := color.NRGBA{R: 230, G: 230, B: 230, A: 255}
|
||||||
m := op.Record(gtx.Ops)
|
bgClip := clip.Rect{
|
||||||
bgMinX := int(r.toPx(reg.X))
|
Min: image.Point{X: int(r.toPx(reg.X)), Y: int(r.toPx(reg.Y))},
|
||||||
bgMinY := int(r.toPx(reg.Y))
|
Max: image.Point{X: int(r.toPx(reg.X + reg.W)), Y: int(r.toPx(reg.Y + reg.H))},
|
||||||
bgMaxX := int(r.toPx(reg.X + reg.W))
|
}.Push(gtx.Ops)
|
||||||
bgMaxY := int(r.toPx(reg.Y + reg.H))
|
|
||||||
fmt.Printf("[DEBUG drawBottomBar] bg_rect=(%d, %d, %d, %d)\n", bgMinX, bgMinY, bgMaxX, bgMaxY)
|
|
||||||
clip.Rect{
|
|
||||||
Min: image.Point{X: bgMinX, Y: bgMinY},
|
|
||||||
Max: image.Point{X: bgMaxX, Y: bgMaxY},
|
|
||||||
}.Op().Push(gtx.Ops)
|
|
||||||
paint.ColorOp{Color: bgColor}.Add(gtx.Ops)
|
paint.ColorOp{Color: bgColor}.Add(gtx.Ops)
|
||||||
paint.PaintOp{}.Add(gtx.Ops)
|
paint.PaintOp{}.Add(gtx.Ops)
|
||||||
call := m.Stop()
|
bgClip.Pop()
|
||||||
call.Add(gtx.Ops)
|
|
||||||
|
|
||||||
// Use captured constraints for positioning — they are in pixels and
|
// Use captured constraints for positioning — they are in pixels and
|
||||||
// represent the actual window bounds. Never use gtx.Constraints here
|
// represent the actual window bounds. Never use gtx.Constraints here
|
||||||
|
|
@ -230,8 +214,6 @@ func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar, constraints W
|
||||||
bottomBarHeightPx := r.toPx(Dp(24))
|
bottomBarHeightPx := r.toPx(Dp(24))
|
||||||
marginPx := r.toPx(Dp(10))
|
marginPx := r.toPx(Dp(10))
|
||||||
drawYPx := Px(windowH) - bottomBarHeightPx - marginPx
|
drawYPx := Px(windowH) - bottomBarHeightPx - marginPx
|
||||||
fmt.Printf("[DEBUG drawBottomBar] drawY_px=%d (windowH=%d - barH=%d - margin=%d)\n",
|
|
||||||
drawYPx, windowH, bottomBarHeightPx, marginPx)
|
|
||||||
|
|
||||||
// Convert draw position back to Dp for text rendering
|
// Convert draw position back to Dp for text rendering
|
||||||
drawY := r.toDp(drawYPx)
|
drawY := r.toDp(drawYPx)
|
||||||
|
|
@ -239,19 +221,16 @@ func (r *Renderer) drawBottomBar(gtx layout.Context, bb BottomBar, constraints W
|
||||||
// Left: Cursor position
|
// Left: Cursor position
|
||||||
cursorXPx := regXPx + r.toPx(Dp(8))
|
cursorXPx := regXPx + r.toPx(Dp(8))
|
||||||
cursorXDp := r.toDp(cursorXPx)
|
cursorXDp := r.toDp(cursorXPx)
|
||||||
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})
|
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
|
||||||
byteXPx := regXPx + barW/2 - r.toPx(Dp(60))
|
byteXPx := regXPx + barW/2 - r.toPx(Dp(60))
|
||||||
byteXDp := r.toDp(byteXPx)
|
byteXDp := r.toDp(byteXPx)
|
||||||
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})
|
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
|
||||||
wordWrapXPx := regXPx + barW - r.toPx(Dp(80))
|
wordWrapXPx := regXPx + barW - r.toPx(Dp(80))
|
||||||
wordWrapXDp := r.toDp(wordWrapXPx)
|
wordWrapXDp := r.toDp(wordWrapXPx)
|
||||||
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})
|
r.drawText(gtx, r.shp, "W:"+boolToString(bb.WordWrap), r.theme.FontSize, wordWrapXDp, drawY, color.NRGBA{R: 0, G: 0, B: 0, A: 255})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user