mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
@@ -8,26 +8,52 @@ import (
|
||||
"gioui.org/ui/f32"
|
||||
)
|
||||
|
||||
// Config contain the context for updating and
|
||||
// drawing a user interface.
|
||||
type Config struct {
|
||||
// Device pixels per dp.
|
||||
PxPerDp float32
|
||||
// Device pixels per sp.
|
||||
PxPerSp float32
|
||||
Now time.Time
|
||||
// The current time for animation.
|
||||
Now time.Time
|
||||
}
|
||||
|
||||
// Pixels converts a value to unitless device pixels.
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
// Op is implemented by all known drawing and control
|
||||
// operations.
|
||||
type Op interface {
|
||||
ImplementsOp()
|
||||
}
|
||||
|
||||
// OpLayer represents a semantic layer of UI.
|
||||
type OpLayer struct {
|
||||
Op Op
|
||||
}
|
||||
|
||||
// OpRedraw requests a redraw at the given time. Use
|
||||
// the zero value to request an immediate redraw.
|
||||
type OpRedraw struct {
|
||||
At time.Time
|
||||
}
|
||||
|
||||
// Ops is the operation for a list of ops.
|
||||
type Ops []Op
|
||||
|
||||
// OpTransform transforms an op.
|
||||
type OpTransform struct {
|
||||
Transform Transform
|
||||
Op Op
|
||||
|
||||
Reference in New Issue
Block a user