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:
+14
-16
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user