layout

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package layout provides geometric primitives and interfaces for view layout. See https://gomatcha.io/guide/layout for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis added in v0.2.0

type Axis int

Axis represents a direction along the coordinate plane.

const (
	AxisY Axis = 1 << iota
	AxisX
)

type Context

type Context interface {
	MaxSize() Point
	MinSize() Point
	ChildCount() int
	LayoutChild(idx int, minSize, maxSize Point) Guide
}

Context provides properties and hooks for Layouter.Layout().

type Edge added in v0.2.0

type Edge int

Edge represents a side of a rectangle.

const (
	EdgeTop Edge = 1 << iota
	EdgeBottom
	EdgeLeft
	EdgeRight
)

type Guide

type Guide struct {
	Frame  Rect
	ZIndex int
}

Guide represents the position of a view.

func (Guide) Bottom

func (g Guide) Bottom() float64

Bottom returns the bottom edge of g.

func (Guide) CenterX

func (g Guide) CenterX() float64

CenterX returns the horizontal center of g.

func (Guide) CenterY

func (g Guide) CenterY() float64

CenterY returns the vertical center of g.

func (Guide) Height

func (g Guide) Height() float64

Height returns the height of g.

func (Guide) Left

func (g Guide) Left() float64

Left returns the left edge of g.

func (Guide) MarshalProtobuf

func (g Guide) MarshalProtobuf() *pblayout.Guide

MarshalProtobuf serializes g into a protobuf object.

func (Guide) Right

func (g Guide) Right() float64

Right returns the right edge of g.

func (Guide) Top

func (g Guide) Top() float64

Top returns the top edge of g.

func (Guide) Width

func (g Guide) Width() float64

Width returns the width of g.

type Layouter

type Layouter interface {
	Layout(ctx Context) (Guide, []Guide)
	comm.Notifier
}

Layouter ... TODO(KD):...

type Point

type Point struct {
	X float64
	Y float64
}

Point represents a point on the XY coordinate system.

func Pt

func Pt(x, y float64) Point

Pt creates a point with x and y.

func (*Point) MarshalProtobuf

func (p *Point) MarshalProtobuf() *pblayout.Point

MarshalProtobuf serializes p into a protobuf object.

func (*Point) UnmarshalProtobuf

func (p *Point) UnmarshalProtobuf(pbpoint *pblayout.Point)

UnmarshalProtobuf deserializes p from a protobuf object.

type PointNotifier

type PointNotifier interface {
	comm.Notifier
	Value() Point
}

PointNotifier wraps the comm.Notifier interface with an additional Value() method which returns a Point.

type Rect

type Rect struct {
	Min, Max Point
}

Rect represents a 2D rectangle with the top left corner at Min and the bottom right corner at Max.

func Rt

func Rt(x0, y0, x1, y1 float64) Rect

Rt creates a rectangle with the min at X0, Y0 and the max at X1, Y1.

func (Rect) Add

func (r Rect) Add(p Point) Rect

Add translates rect r by p.

func (*Rect) MarshalProtobuf

func (r *Rect) MarshalProtobuf() *pblayout.Rect

MarshalProtobuf serializes r into a protobuf object.

func (Rect) String

func (r Rect) String() string

String returns a string description of r.

func (*Rect) UnmarshalProtobuf

func (r *Rect) UnmarshalProtobuf(pbrect *pblayout.Rect)

UnmarshalProtobuf deserializes r from a protobuf object.

Directories

Path Synopsis
Package absolute implements a fixed layout system similar to HTML absolute positioning.
Package absolute implements a fixed layout system similar to HTML absolute positioning.
Package constraint implements a constraint-based layout system.
Package constraint implements a constraint-based layout system.
Package full implements a layout system where the view and all direct children are positioned to the maximum size.
Package full implements a layout system where the view and all direct children are positioned to the maximum size.
Package table implements a vertical, single column layout system.
Package table implements a vertical, single column layout system.

Jump to

Keyboard shortcuts

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