event/config: add a Bounds method.
This is analogous to the image.Image's Bounds method. Change-Id: I2be927f21008107b535cb79e231149cb8d4e8e36 Reviewed-on: https://go-review.googlesource.com/13152 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
50f2c0f60e
commit
fa181effb8
|
@ -9,6 +9,8 @@
|
|||
package config // import "golang.org/x/mobile/event/config"
|
||||
|
||||
import (
|
||||
"image"
|
||||
|
||||
"golang.org/x/mobile/geom"
|
||||
)
|
||||
|
||||
|
@ -29,3 +31,12 @@ type Event struct {
|
|||
// PixelsPerPt values. In general, work in geom.Pt.
|
||||
PixelsPerPt float32
|
||||
}
|
||||
|
||||
// Bounds returns the window's bounds in pixels, at the time this configuration
|
||||
// event was sent.
|
||||
//
|
||||
// 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 {
|
||||
return image.Rectangle{Max: image.Point{e.WidthPx, e.HeightPx}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue