orientation

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
var ErrUnsupported = platform.ErrUnsupported

Functions

func IsLandscape

func IsLandscape(o Orientation) bool

IsLandscape reports whether o is a landscape orientation.

func Lock

func Lock(a *tango.App, m Mask) error

Lock restricts the interface to m, rotating if needed.

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".

func Unlock

func Unlock(a *tango.App) error

Unlock lifts a Lock.

Types

type Mask

Mask is a set of orientations for Lock.

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.

func Get

func Get(a *tango.App) (Orientation, error)

Get returns the current interface orientation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL