Fix ScaleEvent: track prevScale and only send when scale actually changes
This commit is contained in:
parent
b581abb691
commit
fbf6cfac95
|
|
@ -40,6 +40,8 @@ func run(w *app.Window) error {
|
|||
|
||||
// Track pixel dimensions from ConfigEvent (for resize handling)
|
||||
var pixelW, pixelH int
|
||||
// Track previous scale to detect changes
|
||||
prevScale := float32(1.0)
|
||||
|
||||
// Create logic instance with initial DP size and scale=1.0
|
||||
logic := editor.NewLogic(initialDPW, initialDPH)
|
||||
|
|
@ -76,8 +78,9 @@ func run(w *app.Window) error {
|
|||
newScale := gtx.Metric.PxPerDp
|
||||
|
||||
// If scale changed, send scale event to logic goroutine
|
||||
if newScale != 1.0 {
|
||||
if newScale != prevScale {
|
||||
logic.ScaleChan() <- editor.ScaleEvent{Scale: newScale}
|
||||
prevScale = newScale
|
||||
}
|
||||
|
||||
// Convert pixel dimensions to DP using actual scale
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user