Revert to last working state (68437c3) before PNG icon changes

This commit is contained in:
gmp
2026-05-10 06:45:47 -04:00
parent 1b1cf51528
commit fe3e7c3d75
4 changed files with 67 additions and 136 deletions
+25 -15
View File
@@ -38,15 +38,12 @@ func run(w *app.Window) error {
initialDPW := ui.Dp(390)
initialDPH := ui.Dp(844)
// Track previous scale to detect changes
prevScale := float32(1.0)
// Track pixel dimensions from ConfigEvent (for resize handling)
var pixelW, pixelH int
// Create logic instance with initial DP size and scale=1.0
logic := editor.NewLogic(initialDPW, initialDPH)
// Set State reference on Renderer — it reads scale/window size from State directly
renderer.SetState(logic.State())
// Shared state protected by mutex
var mu sync.Mutex
var elems []ui.Element
@@ -63,9 +60,12 @@ func run(w *app.Window) error {
case app.DestroyEvent:
return e.Err
case app.ConfigEvent:
// Convert pixel dimensions to DP using current scale (starts at 1.0)
dpW := ui.ToDp(ui.Px(e.Config.Size.X), 1.0)
dpH := ui.ToDp(ui.Px(e.Config.Size.Y), 1.0)
// Store pixel dimensions from ConfigEvent
pixelW = e.Config.Size.X
pixelH = e.Config.Size.Y
// Convert to DP using current scale (starts at 1.0)
dpW := ui.ToDp(ui.Px(pixelW), 1.0)
dpH := ui.ToDp(ui.Px(pixelH), 1.0)
// Send config event to logic goroutine (in DP)
logic.ConfigChan() <- editor.ConfigEvent{
Width: dpW,
@@ -73,20 +73,30 @@ func run(w *app.Window) error {
}
case app.FrameEvent:
gtx := app.NewContext(&ops, e)
newScale := gtx.Metric.PxPerDp
// If scale changed, send scale event to logic goroutine
if newScale != prevScale {
logic.ConfigChan() <- editor.ScaleEvent{Scale: newScale}
prevScale = newScale
// Get scale from State — this is updated by ScaleEvent
newScale := logic.Scale()
// Convert pixel dimensions to DP using actual scale
dpW := ui.ToDp(ui.Px(pixelW), newScale)
dpH := ui.ToDp(ui.Px(pixelH), newScale)
// Send updated config to logic goroutine
logic.ConfigChan() <- editor.ConfigEvent{
Width: dpW,
Height: dpH,
}
// Acquire mutex, read frame, draw, e.Frame(), release mutex
// Update renderer with current scale from State
renderer.SetScale(newScale)
// Acquire mutex, read frame, draw, release mutex
mu.Lock()
currentElems := elems
mu.Unlock()
renderer.Draw(gtx, currentElems)
e.Frame(&ops)
mu.Unlock()
}
}
}