Documentation
¶
Overview ¶
Package orientation reads and locks the interface orientation.
o, _ := orientation.Get(a) // orientation.Portrait, ...
orientation.Lock(a, orientation.Landscape)
orientation.Unlock(a)
orientation.OnChange(a, func(o orientation.Orientation) { ... })
Locking only chooses among the orientations the app declares (UISupportedInterfaceOrientations on iOS; Android allows all). On iPad, apps that support multitasking (split view) cannot lock; iOS ignores the request there.
Functions return ErrUnsupported on desktop and tango.ErrNotRunning after the app quit.
Index ¶
Constants ¶
const ( Unknown = platform.OrientationUnknown Portrait = platform.OrientationPortrait PortraitUpsideDown = platform.OrientationPortraitUpsideDown LandscapeLeft = platform.OrientationLandscapeLeft LandscapeRight = platform.OrientationLandscapeRight )
const ( MaskPortrait = platform.MaskPortrait MaskPortraitUpsideDown = platform.MaskPortraitUpsideDown MaskLandscapeLeft = platform.MaskLandscapeLeft MaskLandscapeRight = platform.MaskLandscapeRight Landscape = platform.MaskLandscape // either landscape PortraitOnly = platform.MaskPortrait All = platform.MaskAll )
Variables ¶
var ErrUnsupported = platform.ErrUnsupported
Functions ¶
func IsLandscape ¶
func IsLandscape(o Orientation) bool
IsLandscape reports whether o is a landscape orientation.
func OnChange ¶
func OnChange(a *tango.App, fn func(Orientation))
OnChange calls fn on the main thread with the new orientation whenever it changes. It does nothing on desktop.
func String ¶
func String(o Orientation) string
String names o: "portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight" or "unknown".
Types ¶
type Orientation ¶
type Orientation = platform.Orientation
Orientation is named by where the device's top edge points: LandscapeLeft is the device turned 90° counter-clockwise from portrait.