app: rename UpdateEvent to FrameEvent and add Frame field

While "DrawEvent" was too specific (op.Ops contains non-draw events),
"Update" is too vague: it's a common word, and could be misunderstood
to mean update parts of a window, not replace it.

"FrameEvent" is more specific, and is the usual way to refer to immediate
mode drawing.

While we're here, unexport Window.Update and add a Frame function to
FrameEvent, to emphasize that updating the window frame is only
appropriate during the handling of a FrameEvent.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-10 12:15:04 +02:00
parent e49df512f6
commit a937a76534
9 changed files with 29 additions and 25 deletions
+11 -8
View File
@@ -10,20 +10,23 @@ import (
"strings"
"time"
"gioui.org/op"
"gioui.org/unit"
)
// An UpdateEvent is generated when a Window's Update
// method must be called.
type UpdateEvent struct {
// A FrameEvent asks for a new frame in the form of a list of
// operations.
type FrameEvent struct {
Config Config
// Size is the dimensions of the window.
Size image.Point
// Insets is the insets to apply.
Insets Insets
// Whether this draw is system generated
// and needs a complete frame before
// proceeding.
// Frame replaces the window's frame with the new
// frame.
Frame func(frame *op.Ops)
// Whether this draw is system generated and needs a complete
// frame before proceeding.
sync bool
}
@@ -74,7 +77,7 @@ type windowAndOptions struct {
const (
// StagePaused is the Stage for inactive Windows.
// Inactive Windows don't receive UpdateEvents.
// Inactive Windows don't receive FrameEvents.
StagePaused Stage = iota
// StateRunning is for active Windows.
StageRunning
@@ -200,7 +203,7 @@ func newWindowRendezvous() *windowRendezvous {
return wr
}
func (_ UpdateEvent) ImplementsEvent() {}
func (_ FrameEvent) ImplementsEvent() {}
func (_ StageEvent) ImplementsEvent() {}
func (_ *CommandEvent) ImplementsEvent() {}
func (_ DestroyEvent) ImplementsEvent() {}