layouts

package
v0.0.0-...-c5bdd4e Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchor

type Anchor uint8
const (
	AnchorMin Anchor = 1 << iota
	AnchorMax
)

type Flow

type Flow struct {
	uik.Foundation

	Add    chan *uik.Block
	Remove chan *uik.Block
	// contains filtered or unexported fields
}

func NewFlow

func NewFlow() (f *Flow)

func (*Flow) HandleEvents

func (f *Flow) HandleEvents()

dispense events to children, as appropriate

func (*Flow) Initialize

func (f *Flow) Initialize()

type GridComponent

type GridComponent struct {
	// The coordinates for the top-left of the block's placement
	GridX, GridY int
	// How many extra columns and rows the block occupies
	ExtraX, ExtraY int
	// AnchorX and AnchorY get the bit flags from AnchorMin and AnchorMax. The
	// zero value means they will float in the center.
	AnchorTop, AnchorBottom bool
	AnchorLeft, AnchorRight bool
	// The zero-values for MinSize, PreferredSize and MaxSize tell the grid to ignore them
	MinSize, PreferredSize, MaxSize geom.Coord
}

type GridConfig

type GridConfig struct {
	Components map[string]GridComponent
}

func ParseGridConfig

func ParseGridConfig(fmt string) (cfg GridConfig, err error)

func ReadGridConfig

func ReadGridConfig(r io.Reader) (cfg GridConfig, err error)

type GridEngine

type GridEngine struct {
	// contains filtered or unexported fields
}

func NewGridEngine

func NewGridEngine(config GridConfig) (g *GridEngine)

func (*GridEngine) Add

func (g *GridEngine) Add(b *uik.Block, bd GridComponent)

func (*GridEngine) AddName

func (g *GridEngine) AddName(name string, b *uik.Block)

func (*GridEngine) ConfigUnsafe

func (g *GridEngine) ConfigUnsafe(cfg interface{})

func (*GridEngine) GetHint

func (g *GridEngine) GetHint() (hint uik.SizeHint)

func (*GridEngine) GetLayout

func (g *GridEngine) GetLayout(size geom.Coord) (layout Layout)

func (*GridEngine) Remove

func (g *GridEngine) Remove(b *uik.Block)

func (*GridEngine) SetConfig

func (g *GridEngine) SetConfig(cfg GridConfig)

func (*GridEngine) SetHint

func (g *GridEngine) SetHint(block *uik.Block, hint uik.SizeHint)

func (*GridEngine) SetLayouter

func (g *GridEngine) SetLayouter(layouter *Layouter)

type Layout

type Layout map[*uik.Block]geom.Rect

type LayoutEngine

type LayoutEngine interface {
	// The layouter using this engine. The engine should use this
	// layouter's .AddBlock(), .RemoveBlock(), .Invalidate()
	// methods, etc.
	SetLayouter(layouter *Layouter)
	// Set the hint associated with this block.
	SetHint(block *uik.Block, hint uik.SizeHint)
	// Return the hint that the Layouter will report.
	GetHint() uik.SizeHint
	// Get the bounds for each of the blocks in this layout.
	GetLayout(size geom.Coord) Layout
	// Items sent on the config channel will appear as a parameter
	// to this function. It is suffixed by "Unsafe" to deter
	// sites other than the Layouter from calling it, since it
	// would not be safe for them.
	ConfigUnsafe(cfg interface{})
}

Implement this interface with your own layout code. All methods listed in this interface will be called from the same goroutine in the Layouter, so no mutual thread-safety is needed. However, if your implementing type has more methods (perhaps to add a new block, or to set configuration data), those methods will need to implement some sort of thread-safety when manipulating the data accessed by the LayoutEngine methods.

type Layouter

type Layouter struct {
	uik.Foundation
	// contains filtered or unexported fields
}

func HBox

func HBox(config GridConfig, blocks ...*uik.Block) (l *Layouter)

func NewGrid

func NewGrid(cfg GridConfig) (l *Layouter)

func NewLayouter

func NewLayouter(engine LayoutEngine) (l *Layouter)

func NewPadBox

func NewPadBox(config PadConfig, block *uik.Block) (pb *Layouter)

func VBox

func VBox(config GridConfig, blocks ...*uik.Block) (l *Layouter)

func (*Layouter) Config

func (l *Layouter) Config(cfg interface{})

func (*Layouter) HandleEvents

func (l *Layouter) HandleEvents()

dispense events to children, as appropriate

func (*Layouter) Initialize

func (l *Layouter) Initialize()

type PadConfig

type PadConfig struct {
	Left, Top, Right, Bottom float64
}

type PadLayout

type PadLayout struct {
	// contains filtered or unexported fields
}

func NewPadLayout

func NewPadLayout(config PadConfig, block *uik.Block) (p *PadLayout)

func (*PadLayout) ConfigUnsafe

func (p *PadLayout) ConfigUnsafe(cfg interface{})

Do not call this method except from within the containing Layout's goroutine.

func (*PadLayout) GetHint

func (p *PadLayout) GetHint() (hint uik.SizeHint)

func (*PadLayout) GetLayout

func (p *PadLayout) GetLayout(size geom.Coord) (l Layout)

func (*PadLayout) SetBlock

func (p *PadLayout) SetBlock(block *uik.Block)

func (*PadLayout) SetConfig

func (p *PadLayout) SetConfig(cfg PadConfig)

func (*PadLayout) SetHint

func (p *PadLayout) SetHint(block *uik.Block, hint uik.SizeHint)

func (*PadLayout) SetLayouter

func (p *PadLayout) SetLayouter(layouter *Layouter)

Jump to

Keyboard shortcuts

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