all: make unit.Converter concrete and rename to Metric

An interface for scaling dp and sp is overkill, at least for all
current uses. Make it a concrete struct type, and rename it to the
shorter and more precise Metric.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-17 11:47:14 +02:00
parent 1603a6f3ee
commit 596e321610
15 changed files with 86 additions and 85 deletions
+6 -5
View File
@@ -19,6 +19,7 @@ import (
syscall "golang.org/x/sys/windows"
"gioui.org/app/internal/windows"
"gioui.org/unit"
"gioui.org/f32"
"gioui.org/io/key"
@@ -377,7 +378,7 @@ func (w *window) draw(sync bool) {
X: w.width,
Y: w.height,
},
Config: &cfg,
Metric: cfg,
},
Sync: sync,
})
@@ -586,12 +587,12 @@ func convertKeyCode(code uintptr) (string, bool) {
return r, true
}
func configForDC() config {
func configForDC() unit.Metric {
dpi := windows.GetSystemDPI()
const inchPrDp = 1.0 / 96.0
ppdp := float32(dpi) * inchPrDp
return config{
pxPerDp: ppdp,
pxPerSp: ppdp,
return unit.Metric{
PxPerDp: ppdp,
PxPerSp: ppdp,
}
}