mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
ui/app: make Draw.Config a value, not a pointer
We are going to encourage a model where pointers to a central (program global) Configs are passed to widgets at setup time, and not pass Configs at every frame. That way, the global Gonfig can change, but the pointers won't need updating. This change only switches the Draw event's Config pointer to a value to avoid tempting programs to use the event Config instead of updating their own central Configs. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ type Event interface {
|
||||
}
|
||||
|
||||
type Draw struct {
|
||||
Config *ui.Config
|
||||
Config ui.Config
|
||||
Size image.Point
|
||||
// Whether this draw is system generated
|
||||
// and needs a complete frame before
|
||||
|
||||
@@ -275,7 +275,7 @@ func (w *window) draw(sync bool) {
|
||||
X: int(width),
|
||||
Y: int(height),
|
||||
},
|
||||
Config: &ui.Config{
|
||||
Config: ui.Config{
|
||||
PxPerDp: ppdp,
|
||||
PxPerSp: w.fontScale * ppdp,
|
||||
Now: time.Now(),
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int) {
|
||||
X: int(width + .5),
|
||||
Y: int(height + .5),
|
||||
},
|
||||
Config: &ui.Config{
|
||||
Config: ui.Config{
|
||||
PxPerDp: float32(dpi) * inchPrDp,
|
||||
PxPerSp: float32(sdpi) * inchPrDp,
|
||||
Now: time.Now(),
|
||||
|
||||
+1
-1
@@ -341,7 +341,7 @@ func (w *window) draw(sync bool) {
|
||||
X: width,
|
||||
Y: height,
|
||||
},
|
||||
Config: &cfg,
|
||||
Config: cfg,
|
||||
sync: sync,
|
||||
})
|
||||
}
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ func (w *window) draw(sync bool) {
|
||||
X: width,
|
||||
Y: height,
|
||||
},
|
||||
Config: &cfg,
|
||||
Config: cfg,
|
||||
sync: sync,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1050,7 +1050,7 @@ func (w *window) draw(sync bool) {
|
||||
X: width,
|
||||
Y: height,
|
||||
},
|
||||
Config: &cfg,
|
||||
Config: cfg,
|
||||
sync: sync,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -487,14 +487,14 @@ func convertKeyCode(code uintptr) (rune, bool) {
|
||||
return r, true
|
||||
}
|
||||
|
||||
func configForDC(hdc syscall.Handle) *ui.Config {
|
||||
func configForDC(hdc syscall.Handle) ui.Config {
|
||||
dpi := getDeviceCaps(hdc, _LOGPIXELSX)
|
||||
ppdp := float32(dpi) * inchPrDp * monitorScale
|
||||
// Force a minimum density to keep text legible and to handle bogus output geometry.
|
||||
if ppdp < minDensity {
|
||||
ppdp = minDensity
|
||||
}
|
||||
return &ui.Config{
|
||||
return ui.Config{
|
||||
PxPerDp: ppdp,
|
||||
PxPerSp: ppdp,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user