hierarchy

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package hierarchy provides platform-neutral geometry and normalized tree helpers over the frozen device DTOs.

Index

Constants

View Source
const MinimumVisiblePercentage = 0.10

MinimumVisiblePercentage is the exact hierarchy retention boundary.

Variables

This section is empty.

Functions

func Area

func Area(bounds device.Bounds) int64

Area returns the non-negative rectangular area.

func Center

func Center(bounds device.Bounds) device.Point

Center returns the exact geometric center, including half-pixel positions.

func FormatBounds

func FormatBounds(bounds device.Bounds) string

FormatBounds renders normalized bounds using Android hierarchy syntax.

func IsVisible

func IsVisible(bounds, viewport device.Bounds) bool

IsVisible applies the exact 10% hierarchy-retention threshold.

func ParseBounds

func ParseBounds(value string) (device.Bounds, error)

ParseBounds parses [left,top][right,bottom] into the normalized bounds DTO.

func VisiblePercentage

func VisiblePercentage(bounds, viewport device.Bounds) float64

VisiblePercentage returns the portion of an element visible in the viewport. An element covering every viewport edge is fully visible even when the element itself extends beyond those edges.

Types

type BoundsError

type BoundsError struct {
	Value  string
	Reason string
}

BoundsError reports a malformed or inverted Android-style bounds value.

func (*BoundsError) Error

func (e *BoundsError) Error() string

type Element

type Element struct {
	Node      device.TreeNode
	Bounds    device.Bounds
	HasBounds bool
	Parent    *Element
	Children  []*Element
	Order     int
}

Element is a normalized hierarchy node with explicit geometry, ancestry, and stable preorder identity. Node.Children is cleared; Children is authoritative.

func FilterVisible

func FilterVisible(root *Element, viewport device.Bounds) *Element

FilterVisible returns a pruned copy. Nodes without bounds are retained, and an otherwise invisible node remains when at least one child remains visible.

func New

func New(root device.TreeNode) (*Element, error)

New converts a frozen TreeNode DTO into a normalized hierarchy.

func Walk

func Walk(root *Element) []*Element

Walk returns elements in stable preorder.

Jump to

Keyboard shortcuts

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