Documentation
¶
Overview ¶
Package hierarchy provides platform-neutral geometry and normalized tree helpers over the frozen device DTOs.
Index ¶
- Constants
- func Area(bounds device.Bounds) int64
- func Center(bounds device.Bounds) device.Point
- func FormatBounds(bounds device.Bounds) string
- func IsVisible(bounds, viewport device.Bounds) bool
- func ParseBounds(value string) (device.Bounds, error)
- func VisibleCenter(bounds, viewport device.Bounds) device.Point
- func VisiblePercentage(bounds, viewport device.Bounds) float64
- type BoundsError
- type Element
Constants ¶
const MinimumVisiblePercentage = 0.10
MinimumVisiblePercentage is the exact hierarchy retention boundary.
Variables ¶
This section is empty.
Functions ¶
func FormatBounds ¶
FormatBounds renders normalized bounds using Android hierarchy syntax.
func ParseBounds ¶
ParseBounds parses [left,top][right,bottom] into the normalized bounds DTO.
func VisibleCenter ¶
VisibleCenter returns the center of the part of an element that is actually on screen. FilterVisible keeps an element at 10% visible, so a row scrolled half past the bottom edge stays matchable while its geometric center sits off the device -- and a tap aimed there lands nowhere. For a fully visible element the intersection is the element, so the point is unchanged.
func VisiblePercentage ¶
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 ¶
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
// OnScreen records what FilterVisible decided about this node, so a
// later step can tell a match the user can see from an ancestor kept
// only to carry a visible descendant. It stays false on an unfiltered
// tree, where nothing has decided yet.
OnScreen bool
}
Element is a normalized hierarchy node with explicit geometry, ancestry, and stable preorder identity. Node.Children is cleared; Children is authoritative.
func FilterVisible ¶
FilterVisible returns a pruned copy. Nodes without bounds are retained, and an otherwise invisible node remains when at least one child remains visible.