event/size: make methods take values, not pointers.
This makes the following program valid: ---- package main import ( "fmt" "golang.org/x/mobile/event/size" ) func foo() size.Event { return size.Event{} } func main() { fmt.Println(foo().Bounds()) } ---- Previously, you would get: ./main.go:12: cannot call pointer method on foo() ./main.go:12: cannot take the address of foo() Change-Id: I2801d18a04d56d1c7496cb008531d078490ccf86 Reviewed-on: https://go-review.googlesource.com/18356 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
cc29d844e9
commit
a103499a63
|
@ -38,7 +38,7 @@ type Event struct {
|
|||
|
||||
// Size returns the window's size in pixels, at the time this size event was
|
||||
// sent.
|
||||
func (e *Event) Size() image.Point {
|
||||
func (e Event) Size() image.Point {
|
||||
return image.Point{e.WidthPx, e.HeightPx}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ func (e *Event) Size() image.Point {
|
|||
//
|
||||
// The top-left pixel is always (0, 0). The bottom-right pixel is given by the
|
||||
// width and height.
|
||||
func (e *Event) Bounds() image.Rectangle {
|
||||
func (e Event) Bounds() image.Rectangle {
|
||||
return image.Rectangle{Max: image.Point{e.WidthPx, e.HeightPx}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue