mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
ui/app: rename DrawEvent to UpdateEvent and Window.Draw to Window.Update
Window.Draw is not the right name for a method that does more than just drawing. Rename to Update instead, and rename the DrawEvent accordingly for symmetry. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+3
-3
@@ -13,9 +13,9 @@ import (
|
|||||||
"gioui.org/ui"
|
"gioui.org/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DrawEvent is sent when a Window's Draw
|
// UpdateEvent is sent when a Window's Update
|
||||||
// method must be called.
|
// method must be called.
|
||||||
type DrawEvent struct {
|
type UpdateEvent struct {
|
||||||
Config Config
|
Config Config
|
||||||
Size image.Point
|
Size image.Point
|
||||||
Insets Insets
|
Insets Insets
|
||||||
@@ -178,7 +178,7 @@ func newWindowRendezvous() *windowRendezvous {
|
|||||||
return wr
|
return wr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ DrawEvent) ImplementsEvent() {}
|
func (_ UpdateEvent) ImplementsEvent() {}
|
||||||
func (_ StageEvent) ImplementsEvent() {}
|
func (_ StageEvent) ImplementsEvent() {}
|
||||||
func (_ *CommandEvent) ImplementsEvent() {}
|
func (_ *CommandEvent) ImplementsEvent() {}
|
||||||
func (_ DestroyEvent) ImplementsEvent() {}
|
func (_ DestroyEvent) ImplementsEvent() {}
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ func (w *window) draw(sync bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ppdp := float32(w.dpi) * inchPrDp
|
ppdp := float32(w.dpi) * inchPrDp
|
||||||
w.event(DrawEvent{
|
w.event(UpdateEvent{
|
||||||
Size: image.Point{
|
Size: image.Point{
|
||||||
X: int(width),
|
X: int(width),
|
||||||
Y: int(height),
|
Y: int(height),
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int, to
|
|||||||
if sync != 0 {
|
if sync != 0 {
|
||||||
isSync = true
|
isSync = true
|
||||||
}
|
}
|
||||||
w.w.event(DrawEvent{
|
w.w.event(UpdateEvent{
|
||||||
Size: image.Point{
|
Size: image.Point{
|
||||||
X: int(width + .5),
|
X: int(width + .5),
|
||||||
Y: int(height + .5),
|
Y: int(height + .5),
|
||||||
|
|||||||
+1
-1
@@ -345,7 +345,7 @@ func (w *window) draw(sync bool) {
|
|||||||
w.scale = float32(scale)
|
w.scale = float32(scale)
|
||||||
w.mu.Unlock()
|
w.mu.Unlock()
|
||||||
cfg.now = time.Now()
|
cfg.now = time.Now()
|
||||||
w.w.event(DrawEvent{
|
w.w.event(UpdateEvent{
|
||||||
Size: image.Point{
|
Size: image.Point{
|
||||||
X: width,
|
X: width,
|
||||||
Y: height,
|
Y: height,
|
||||||
|
|||||||
+1
-1
@@ -198,7 +198,7 @@ func (w *window) draw(sync bool) {
|
|||||||
cfg := configFor(w.ppdp, w.scale)
|
cfg := configFor(w.ppdp, w.scale)
|
||||||
cfg.now = time.Now()
|
cfg.now = time.Now()
|
||||||
w.setStage(StageRunning)
|
w.setStage(StageRunning)
|
||||||
w.w.event(DrawEvent{
|
w.w.event(UpdateEvent{
|
||||||
Size: image.Point{
|
Size: image.Point{
|
||||||
X: width,
|
X: width,
|
||||||
Y: height,
|
Y: height,
|
||||||
|
|||||||
@@ -1050,7 +1050,7 @@ func (w *window) draw(sync bool) {
|
|||||||
C.gio_wl_callback_add_listener(w.lastFrameCallback, unsafe.Pointer(w.surf))
|
C.gio_wl_callback_add_listener(w.lastFrameCallback, unsafe.Pointer(w.surf))
|
||||||
}
|
}
|
||||||
cfg.now = time.Now()
|
cfg.now = time.Now()
|
||||||
w.w.event(DrawEvent{
|
w.w.event(UpdateEvent{
|
||||||
Size: image.Point{
|
Size: image.Point{
|
||||||
X: width,
|
X: width,
|
||||||
Y: height,
|
Y: height,
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ func (w *window) draw(sync bool) {
|
|||||||
w.height = int(r.bottom - r.top)
|
w.height = int(r.bottom - r.top)
|
||||||
cfg := configForDC(w.hdc)
|
cfg := configForDC(w.hdc)
|
||||||
cfg.now = time.Now()
|
cfg.now = time.Now()
|
||||||
w.w.event(DrawEvent{
|
w.w.event(UpdateEvent{
|
||||||
Size: image.Point{
|
Size: image.Point{
|
||||||
X: w.width,
|
X: w.width,
|
||||||
Y: w.height,
|
Y: w.height,
|
||||||
|
|||||||
+4
-4
@@ -59,7 +59,7 @@ type driverEvent struct {
|
|||||||
// of a Window.
|
// of a Window.
|
||||||
var _ interface {
|
var _ interface {
|
||||||
// setAnimating sets the animation flag. When the window is animating,
|
// setAnimating sets the animation flag. When the window is animating,
|
||||||
// DrawEvents are delivered as fast as the display can handle them.
|
// UpdateEvents are delivered as fast as the display can handle them.
|
||||||
setAnimating(anim bool)
|
setAnimating(anim bool)
|
||||||
// showTextInput updates the virtual keyboard state.
|
// showTextInput updates the virtual keyboard state.
|
||||||
showTextInput(show bool)
|
showTextInput(show bool)
|
||||||
@@ -104,7 +104,7 @@ func (w *Window) Queue() *Queue {
|
|||||||
return &w.queue
|
return &w.queue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Draw(frame *ui.Ops) {
|
func (w *Window) Update(frame *ui.Ops) {
|
||||||
w.frames <- frame
|
w.frames <- frame
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ func (w *Window) draw(size image.Point, frame *ui.Ops) {
|
|||||||
w.updateAnimation()
|
w.updateAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalidate the current window such that a DrawEvent will be generated
|
// Invalidate the current window such that a UpdateEvent will be generated
|
||||||
// immediately. If the window is not active, the redraw will trigger
|
// immediately. If the window is not active, the redraw will trigger
|
||||||
// when the window becomes active.
|
// when the window becomes active.
|
||||||
func (w *Window) Invalidate() {
|
func (w *Window) Invalidate() {
|
||||||
@@ -237,7 +237,7 @@ func (w *Window) run(opts *WindowOptions) {
|
|||||||
w.updateAnimation()
|
w.updateAnimation()
|
||||||
w.out <- e
|
w.out <- e
|
||||||
w.waitAck()
|
w.waitAck()
|
||||||
case DrawEvent:
|
case UpdateEvent:
|
||||||
if e2.Size == (image.Point{}) {
|
if e2.Size == (image.Point{}) {
|
||||||
panic(errors.New("internal error: zero-sized Draw"))
|
panic(errors.New("internal error: zero-sized Draw"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user