fix: remove duplicate scale storage, read from State via ScaleProvider interface
- Remove Renderer.scale field and SetScale method - Add ScaleProvider interface to avoid editor/ui import cycle - Add Scale() method to State, rename Scale field to scale - Renderer reads scale through r.scale.Scale() - Fix icons.go blank import preventing embed.FS usage - Update main.go to pass State as ScaleProvider to Renderer
This commit is contained in:
@@ -98,9 +98,7 @@ func (l *Logic) ScreenSize() (ui.Dp, ui.Dp) {
|
||||
|
||||
// Scale returns the current scale factor (pixels per DP).
|
||||
func (l *Logic) Scale() float32 {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
return l.state.Scale
|
||||
return l.state.Scale()
|
||||
}
|
||||
|
||||
// Run runs the logic goroutine loop.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
type State struct {
|
||||
ScreenWidth ui.Dp
|
||||
ScreenHeight ui.Dp
|
||||
Scale float32 // pixels per DP, default 1.0
|
||||
scale float32 // pixels per DP, default 1.0
|
||||
Elems []ui.Element
|
||||
}
|
||||
|
||||
@@ -20,17 +20,22 @@ func NewState(screenWidth, screenHeight ui.Dp) *State {
|
||||
return &State{
|
||||
ScreenWidth: screenWidth,
|
||||
ScreenHeight: screenHeight,
|
||||
Scale: 1.0,
|
||||
scale: 1.0,
|
||||
Elems: EditorLayout(screenWidth, screenHeight),
|
||||
}
|
||||
}
|
||||
|
||||
// SetScale updates the scale factor and recomputes layout.
|
||||
func (s *State) SetScale(scale float32) {
|
||||
s.Scale = scale
|
||||
s.scale = scale
|
||||
s.Elems = EditorLayout(s.ScreenWidth, s.ScreenHeight)
|
||||
}
|
||||
|
||||
// Scale returns the current scale factor (pixels per DP).
|
||||
func (s *State) Scale() float32 {
|
||||
return s.scale
|
||||
}
|
||||
|
||||
// EditorLayout computes regions for the editor page.
|
||||
// It takes screen dimensions in Dp and returns []Element with regions in Dp.
|
||||
// This function works exclusively in Dp — no pixel conversions.
|
||||
|
||||
Reference in New Issue
Block a user