app,io/system: extract system events to separate package

Package app is the only package that depends on native libraries and
Cgo. Minimize its API, thereby minimizing Gio clients' dependency on
it. In the future, a headless, testing or remote "Window" should be
very easy to replace app.Window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-14 14:55:42 +02:00
parent 641656b307
commit 36d1cd90f2
10 changed files with 251 additions and 214 deletions
+3 -12
View File
@@ -4,9 +4,9 @@ package layout
import (
"image"
"time"
"gioui.org/io/event"
"gioui.org/io/system"
"gioui.org/op"
"gioui.org/unit"
)
@@ -53,20 +53,11 @@ type Context struct {
// operation.
Dimensions Dimensions
Config
system.Config
event.Queue
*op.Ops
}
// Config define the essential properties of
// the environment.
type Config interface {
// Now returns the current animation time.
Now() time.Time
unit.Converter
}
const (
Start Alignment = iota
End
@@ -104,7 +95,7 @@ func (s *Context) Layout(cs Constraints, w Widget) Dimensions {
// Reset the context. The constraints' minimum and maximum values are
// set to the size.
func (c *Context) Reset(cfg Config, size image.Point) {
func (c *Context) Reset(cfg system.Config, size image.Point) {
c.Constraints = RigidConstraints(size)
c.Dimensions = Dimensions{}
c.Config = cfg