grid

package
v0.2.1-0...-b772245 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	// Percent size is the percent of the total in the horizontal axis.
	PercentSize int
	// Empty marks the element as an empty block that will not be used.
	Empty bool
	// Widget is the widget to be placed.
	Widget model.Widget
}

Element is a "placeable" element on the grid, depending on the implementation of the renderer will be created in one way or another.

type Grid

type Grid struct {
	// Is the max size of the X axis. This is equal to a 100 percentage.
	MaxWidth int
	// Is the max size of the y axis. This is equal to a 100 percentage.
	MaxHeight int
	// Rows are the rows the grid has (inside the rows are the columns).
	// the rows are vertically placed, also know as the Y axis.
	Rows []*Row
}

Grid is the grid itself, it's composed by rows that inside of the rows are the columns, the elements are the columns.

---------------------------------------------------- [------element------] [--element--] [---element---] ---------------------------------------------------- [element] [element] [------------element----------] ---------------------------------------------------- [-element-] [----element----] [element] ----------------------------------------------------

func NewAdaptiveGrid

func NewAdaptiveGrid(maxWidth int, widgets []model.Widget) (*Grid, error)

NewAdaptiveGrid returns a grid that places the widgets in the received order without checking its position (x, y) only using the size of the widgets. It will adapt the rows dinamically so the widgets that are bigger than the empty space on the row, will be placed in the next row an so own, on after the other creating new rows until all the widgets have been placed.

func NewFixedGrid

func NewFixedGrid(maxWidth int, widgets []model.Widget) (*Grid, error)

NewFixedGrid will place the widgets on the grid using the size and position of the widgets letting empty elements between them if required. This kind of grid needs the widgets to be exactly placed on the grid it doesn't adapt horizontally nor vertically.

type Row

type Row struct {
	// Elements are the elements that will be placed on the row. The
	// elements of a row are horizontally placed. also known as
	// the X axis.
	Elements []*Element
	// PercentSize is the size in percentage of the total vertical axis.
	PercentSize int
}

Row is composed by multiple elements.

Jump to

Keyboard shortcuts

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