all: initial import

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-03-30 13:18:49 +01:00
commit 0f05231c35
102 changed files with 17926 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: Unlicense OR MIT
package ui
type Value struct {
V float32
U Unit
}
type Unit uint8
const (
UnitPx Unit = iota
UnitDp
UnitSp
)
func Px(v float32) Value {
return Value{V: v, U: UnitPx}
}
func Dp(v float32) Value {
return Value{V: v, U: UnitDp}
}
func Sp(v float32) Value {
return Value{V: v, U: UnitSp}
}
func (c *Config) Pixels(v Value) float32 {
switch v.U {
case UnitPx:
return v.V
case UnitDp:
return c.PxPerDp * v.V
case UnitSp:
return c.PxPerSp * v.V
default:
panic("unknown unit")
}
}