hinge

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package hinge tells a screen about a foldable phone's fold: where it runs, and whether the phone is half open, like a laptop or a tent, so a layout can keep things off the crease. Phones without a fold, and every iPhone and iPad, report none.

nimbus native plugin add hinge

hinge.Aware{Style: ui.Style{Grow: 1}, Content: func(f hinge.Fold) ui.Component {
	if f.HalfOpen && !f.Vertical {
		return tabletop(f) // video above the fold, controls below
	}
	return normal()
}}

splitview uses it to split at a vertical fold.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aware

type Aware struct {
	Content func(Fold) ui.Component // the screen, for the fold as it is now
	Style   ui.Style                // its size and place; usually Grow: 1
}

Aware renders Content with the fold, again whenever it changes. Put it at the root of a screen that fills the window, since the fold's place is the window's.

func (Aware) Render

func (a Aware) Render(c *ui.Ctx) ui.Component

Render watches the fold and renders Content.

type Fold

type Fold struct {
	Present   bool `json:"present"`   // there is one on this screen
	HalfOpen  bool `json:"halfOpen"`  // folded partway, not flat
	Vertical  bool `json:"vertical"`  // it runs top to bottom, splitting left from right
	Separates bool `json:"separates"` // it divides the screen in two: half open, or two screens with a gap
	Occludes  bool `json:"occludes"`  // it hides what's under it, like a hinge between two screens
	// X, Y, W and H are where it is, in points from the window's top left.
	// A fold that hides nothing is a line, so W or H is 0.
	X float32 `json:"x"`
	Y float32 `json:"y"` // its top
	W float32 `json:"w"` // its width: 0 for a vertical crease that hides nothing
	H float32 `json:"h"` // its height: 0 for a horizontal crease that hides nothing
}

Fold is a fold, or none.

Jump to

Keyboard shortcuts

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