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:
Nigel Tao 2015-08-05 16:08:57 +10:00
parent 50f2c0f60e
commit fa181effb8
1 changed files with 11 additions and 0 deletions

View File

@ -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}}
}