all: rename package ui to unit

Package ui is now only about units except for the Config.Now method.
Remove Now and rename Config to Converter. Add layout.Config to
replace the old ui.Config.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-09-30 16:42:12 +02:00
parent 1d3360699e
commit 3784ece6dd
20 changed files with 95 additions and 101 deletions
+7 -7
View File
@@ -10,7 +10,7 @@ import (
"strings"
"time"
"gioui.org/ui"
"gioui.org/unit"
)
// An UpdateEvent is generated when a Window's Update
@@ -39,7 +39,7 @@ type DestroyEvent struct {
// system decoration such as translucent
// system bars and software keyboards.
type Insets struct {
Top, Bottom, Left, Right ui.Value
Top, Bottom, Left, Right unit.Value
}
// A StageEvent is generated whenever the stage of a
@@ -146,7 +146,7 @@ func Main() {
main()
}
// Config implements the ui.Config interface.
// Config implements the layout.Config interface.
type Config struct {
// Device pixels per dp.
pxPerDp float32
@@ -159,14 +159,14 @@ func (c *Config) Now() time.Time {
return c.now
}
func (c *Config) Px(v ui.Value) int {
func (c *Config) Px(v unit.Value) int {
var r float32
switch v.U {
case ui.UnitPx:
case unit.UnitPx:
r = v.V
case ui.UnitDp:
case unit.UnitDp:
r = c.pxPerDp * v.V
case ui.UnitSp:
case unit.UnitSp:
r = c.pxPerSp * v.V
default:
panic("unknown unit")