Fix StatusBar background using push/pop instead of op.Record macro

The op.Record macro was leaving a clip on the stack that prevented
subsequent elements from drawing. Use clip.Rect{}.Push()/clip.Pop()
instead for immediate push/pop.
This commit is contained in:
gmp
2026-05-09 19:13:33 -04:00
parent 4893d69f4e
commit 4a9253616d
2 changed files with 38 additions and 23 deletions
+14 -16
View File
@@ -34,13 +34,15 @@ func run(w *app.Window) error {
shaper := text.NewShaper(text.WithCollection(gofont.Collection()))
renderer := ui.New(ui.Theme{FontSize: 14}, shaper)
// Track window dimensions in pixels (from ConfigEvent) and DP (for logic layer)
// Initial DP size from app.Size() — used before we know the scale factor
initialDPW := ui.Dp(390)
initialDPH := ui.Dp(844)
// Track pixel dimensions from ConfigEvent (for resize handling)
var pixelW, pixelH int
var dpW, dpH ui.Dp
var scale float32 = 1.0 // updated on first FrameEvent
// Create logic instance with initial DP size
logic := editor.NewLogic(dpW, dpH)
logic := editor.NewLogic(initialDPW, initialDPH)
// Shared state protected by mutex
var mu sync.Mutex
@@ -58,25 +60,21 @@ func run(w *app.Window) error {
case app.DestroyEvent:
return e.Err
case app.ConfigEvent:
// Store pixel dimensions from ConfigEvent
// Store pixel dimensions for later conversion
pixelW = e.Config.Size.X
pixelH = e.Config.Size.Y
// Convert to DP using current scale (default 1.0 until first FrameEvent)
dpW = ui.ToDp(ui.Px(pixelW), scale)
dpH = ui.ToDp(ui.Px(pixelH), scale)
// Send config event to logic goroutine (in DP)
// Use initial DP size until we get the scale from FrameEvent
logic.ConfigChan() <- editor.ConfigEvent{
Width: dpW,
Height: dpH,
Width: initialDPW,
Height: initialDPH,
}
case app.FrameEvent:
// Update scale from the frame context
gtx := app.NewContext(&ops, e)
scale = gtx.Metric.PxPerDp
scale := gtx.Metric.PxPerDp
// Reconvert pixel dimensions to DP with actual scale
dpW = ui.ToDp(ui.Px(pixelW), scale)
dpH = ui.ToDp(ui.Px(pixelH), scale)
// Convert pixel dimensions to DP using actual scale
dpW := ui.ToDp(ui.Px(pixelW), scale)
dpH := ui.ToDp(ui.Px(pixelH), scale)
// Send updated config to logic goroutine
logic.ConfigChan() <- editor.ConfigEvent{