all: move Now from system.Config to system.FrameEvent

Then, make layout.Context.Now a field, copied from FrameEvent.Now.

API change:

	gofmt -r 'gtx.Now() -> gtx.Now'

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-09 23:18:04 +02:00
parent 81a84d874b
commit 6380baacb6
14 changed files with 25 additions and 34 deletions
+5 -8
View File
@@ -24,6 +24,9 @@ type Context struct {
// By convention, a nil Queue is a signal to widgets to draw themselves
// in a disabled state.
Queue event.Queue
// Now is the animation time.
Now time.Time
*op.Ops
}
@@ -31,6 +34,7 @@ type Context struct {
//
// Context{
// Ops: ops,
// Now: e.Now,
// Queue: e.Queue,
// Config: e.Config,
// Constraints: Exact(e.Size),
@@ -41,20 +45,13 @@ func NewContext(ops *op.Ops, e system.FrameEvent) Context {
ops.Reset()
return Context{
Ops: ops,
Now: e.Now,
Queue: e.Queue,
Config: e.Config,
Constraints: Exact(e.Size),
}
}
// Now returns the configuration time or the zero time.
func (c Context) Now() time.Time {
if c.Config == nil {
return time.Time{}
}
return c.Config.Now()
}
// Px maps the value to pixels. If no configuration is set,
// Px returns the rounded value of v.
func (c Context) Px(v unit.Value) int {