grid

package
v1.7.0-dev-20191011 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Unknown represents the unknown result of a task.
	Unknown = Result(iota)

	// Succeeded represents a task that has succeeded.
	Succeeded

	// Failed represents a task that has failed.
	Failed
)
View Source
const (
	// Current represents a task that has a result for the latest data.
	Current = Status(iota)

	// Stale represents a task that has a result for data that is not current.
	Stale

	// InProgress represents a task that is currently being run.
	// The task's result will be for data that is not current.
	InProgress

	// Changed represents a task with a result for the latest data that is different from its stale data
	Changed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CellData

type CellData struct {
	// The list of tasks that belong to this cell.
	Tasks TaskList

	// Optional Key used for transition animations when changing data.
	Key Key
}

CellData holds the list of tasks to display for that cell.

type CellIndex

type CellIndex struct {
	Column Key
	Row    Key
}

CellIndex locates a single cell in the grid.

type Data

type Data struct {
	Columns map[Key]*HeaderData
	Rows    map[Key]*HeaderData
	Cells   map[CellIndex]*CellData
}

Data holds all the presentable data for the grid.

type Grid

type Grid struct {

	// Style holds display style parameters.
	Style Style

	// OnCellClicked is called when a cell is clicked.
	OnCellClicked func(CellIndex, *CellData)

	// OnColumnClicked is called when a column header is clicked.
	OnColumnClicked func(Key, *HeaderData)

	// OnRowClicked is called when a row header is clicked.
	OnRowClicked func(Key, *HeaderData)
	// contains filtered or unexported fields
}

Grid is a two-dimensional grid that uses an HTML canvas for display. Call New() to create a default initialized Grid.

func New

func New() *Grid

New returns a new Grid widget.

func (*Grid) Element

func (g *Grid) Element() *dom.Element

Element returns the DOM element that holds the grid.

func (*Grid) SetData

func (g *Grid) SetData(data Data, rowSort, columnSort func(a, b string) bool)

SetData assigns the data to the grid.

type HeaderData

type HeaderData struct {
	// Label used for displaying the header.
	Name string

	// The list of tasks that belong to this cell.
	Tasks TaskList
}

HeaderData holds information about a single row or column header.

type Icons

type Icons struct {
	Succeeded rune
	Failed    rune
	Unknown   rune
}

Icons holds the characters to use to draw the icons using the icons font.

type Key

type Key interface{}

Key is a unique identifier for headers and cells.

type Result

type Result int

Result is an enumerator of task results.

type Status

type Status int

Status is an enumerator of task statuses.

type Style

type Style struct {
	GridPadding                     float64   // Padding in pixels from the top-left of the canvas.
	CellSize                        float64   // Width and height in pixels of each cell.
	CellShadowColor                 dom.Color // The color of the shadow of a raised cell / header.
	HeaderFont                      dom.Font  // The header font.
	HeaderFontColor                 dom.Color // The header font color.
	GridLineColor                   dom.Color // The line color for the grid.
	GridLineWidth                   float64   // The line width for the grid.
	BackgroundColor                 dom.Color // The regular background color of cells and headers.
	CurrentSucceededBackgroundColor dom.Color // The background color used for tasks that have succeeded and are current.
	CurrentSucceededForegroundColor dom.Color // The foreground color used for tasks that have succeeded and are current.
	StaleSucceededBackgroundColor   dom.Color // The background color used for tasks that have succeeded and are stale.
	StaleSucceededForegroundColor   dom.Color // The foreground color used for tasks that have succeeded and are stale.
	CurrentFailedBackgroundColor    dom.Color // The background color used for tasks that have failed and are current.
	CurrentFailedForegroundColor    dom.Color // The foreground color used for tasks that have failed and are current.
	StaleFailedBackgroundColor      dom.Color // The background color used for tasks that have failed and are stale.
	StaleFailedForegroundColor      dom.Color // The foreground color used for tasks that have failed and are stale.
	InProgressForegroundColor       dom.Color // The foreground color used for tasks that last failed and are currently in progress.
	RegressedForegroundColor        dom.Color // The foreground color used for tasks that last succeeded and now are failing.
	FixedForegroundColor            dom.Color // The foreground color used for tasks that last failed and now are succeeding.
	UnknownBackgroundColor          dom.Color // The background color used for tasks that are in an unknown state.
	UnknownForegroundColor          dom.Color // The foreground color used for tasks that are in an unknown state.
	StaleUnknownForegroundColor     dom.Color // The foreground color used for tasks that are in an unknown state and are stale.
	SelectedBackgroundColor         dom.Color // The background color used for cells and headers when selected.
	IconsFont                       dom.Font  // The font to use for icon drawing.
	Icons                           Icons     // The character table used for icon drawing.
}

Style holds parameters to style the grid.

type Task

type Task struct {
	// Last completed task result.
	Result Result

	// The current task status.
	Status Status

	// User data.
	Data interface{}
}

Task holds information about a single task in a cell.

type TaskList

type TaskList []Task

TaskList is a list of tasks.

func (*TaskList) Count

func (l *TaskList) Count(pred func(Task) bool) int

Count returns the number of tasks that pass the predicate.

Jump to

Keyboard shortcuts

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