widget

package module
v0.0.0-...-4c72047 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: MIT Imports: 16 Imported by: 0

README

go.widget

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FontPaths = []string{}
View Source
var FrameDefault = &Box{map[State]*BoxState{Normal: FrameDefaultNormalBoxState}}
View Source
var FrameDefaultBackground = Background{c.White}
View Source
var FrameDefaultBorder = Border{Sides{map[Side]int{All: 1}}, map[Side]c.Color{All: c.RGBA{255, 0, 0, 255}}}
View Source
var FrameDefaultMargin = Margin{Sides{map[Side]int{All: 25}}}
View Source
var FrameDefaultPadding = Padding{Sides{map[Side]int{All: 5}}}

Functions

This section is empty.

Types

type Background

type Background struct {
	Color c.Color
}

func NewBackground

func NewBackground(color c.Color) *Background

func (*Background) Draw

func (this *Background) Draw(img draw.Image)

type Border

type Border struct {
	Sides
	// contains filtered or unexported fields
}

func (*Border) Color

func (this *Border) Color(side Side) c.Color

func (*Border) SetColor

func (this *Border) SetColor(side Side, color c.Color)

type Box

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

func (*Box) Draw

func (this *Box) Draw(img draw.Image, state State)

func (*Box) State

func (this *Box) State(state State) *BoxState

type BoxState

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

func (*BoxState) BorderColor

func (this *BoxState) BorderColor(side Side) c.Color

func (*BoxState) BorderWidth

func (this *BoxState) BorderWidth(side Side) int

func (*BoxState) Margin

func (this *BoxState) Margin(side Side) int

func (*BoxState) Padding

func (this *BoxState) Padding(side Side) int

type Frame

type Frame struct {
	*Size
	*Box
	// contains filtered or unexported fields
}

func NewFrame

func NewFrame(parent Widget) *Frame

func (*Frame) BorderRect

func (this *Frame) BorderRect() image.Rectangle

func (*Frame) ContentRect

func (this *Frame) ContentRect() image.Rectangle

func (*Frame) Draw

func (this *Frame) Draw(img draw.Image)

func (Frame) Layout

func (this Frame) Layout() Layout

func (*Frame) MouseEnteredEvent

func (this *Frame) MouseEnteredEvent(where image.Point) bool

func (*Frame) MouseExitedEvent

func (this *Frame) MouseExitedEvent() bool

func (*Frame) MouseMoveEvent

func (this *Frame) MouseMoveEvent(where image.Point, from image.Point) bool

func (*Frame) Offset

func (this *Frame) Offset() image.Point

func (Frame) Parent

func (this Frame) Parent() Widget

func (*Frame) SetBackground

func (this *Frame) SetBackground(state State, background *Background)

func (*Frame) SetBorderColor

func (this *Frame) SetBorderColor(state State, side Side, color c.Color)

func (*Frame) SetBorderWidth

func (this *Frame) SetBorderWidth(state State, side Side, width int)

func (*Frame) SetMargin

func (this *Frame) SetMargin(state State, side Side, width int)

func (*Frame) SetPadding

func (this *Frame) SetPadding(state State, side Side, width int)

func (*Frame) State

func (this *Frame) State() State

func (*Frame) Update

func (this *Frame) Update()

type HorizontalLayout

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

type Label

type Label struct {
	*Frame
	// contains filtered or unexported fields
}

func NewLabel

func NewLabel(text string, imagePath string, parent Widget) (*Label, error)

func NewLabelWithFunc

func NewLabelWithFunc(textFunc func() string, imagePath string, parent Widget) (*Label, error)

func (*Label) Draw

func (this *Label) Draw(img draw.Image)

type Layout

type Layout interface {
	Parent() Widget
	AddChild(Widget)
	Children() []Widget
	ChildOffset(Widget) image.Point
	Update()
	Draw(draw.Image)
}

type MainWindow

type MainWindow struct {
	*Frame
	// contains filtered or unexported fields
}

func NewMainWindow

func NewMainWindow(width int, height int) *MainWindow

func (*MainWindow) Draw

func (this *MainWindow) Draw(unused draw.Image)

func (*MainWindow) Update

func (this *MainWindow) Update()

type Margin

type Margin struct {
	Sides
}

type Padding

type Padding struct {
	Sides
}

type Side

type Side int
const (
	Top Side = iota
	Bottom
	Left
	Right
	All
)

type Sides

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

func (*Sides) SetWidth

func (this *Sides) SetWidth(side Side, width int)

func (*Sides) Width

func (this *Sides) Width(side Side) int

type Size

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

func NewSize

func NewSize() *Size

func (*Size) Height

func (this *Size) Height() int

func (*Size) HorizontalStretch

func (this *Size) HorizontalStretch() int

func (*Size) MaxHeight

func (this *Size) MaxHeight() int

func (*Size) MaxWidth

func (this *Size) MaxWidth() int

func (*Size) MinHeight

func (this *Size) MinHeight() int

func (*Size) MinWidth

func (this *Size) MinWidth() int

func (*Size) SetHeight

func (this *Size) SetHeight(height int)

This function is called frequently by layouts and will likely change whatever value you use. In general, users should call Set{Max,Min}Height for the size to persist

func (*Size) SetHorizontalStretch

func (this *Size) SetHorizontalStretch(stretch int)

func (*Size) SetMaxHeight

func (this *Size) SetMaxHeight(max int)

func (*Size) SetMaxWidth

func (this *Size) SetMaxWidth(max int)

func (*Size) SetMinHeight

func (this *Size) SetMinHeight(min int)

func (*Size) SetMinWidth

func (this *Size) SetMinWidth(min int)

func (*Size) SetVerticalStretch

func (this *Size) SetVerticalStretch(stretch int)

func (*Size) SetWidth

func (this *Size) SetWidth(width int)

This function is called frequently by layouts and will likely change whatever value you use. In general, users should call Set{Max,Min}Width for the size to persist

func (*Size) VerticalStretch

func (this *Size) VerticalStretch() int

func (*Size) Width

func (this *Size) Width() int

type SizeI

type SizeI interface {
	SetWidth(int)
	Width() int
	SetMaxWidth(int)
	MaxWidth() int
	SetMinWidth(int)
	MinWidth() int
	SetHorizontalStretch(int)
	HorizontalStretch() int
	SetHeight(int)
	Height() int
	SetMaxHeight(int)
	MaxHeight() int
	SetMinHeight(int)
	MinHeight() int
	SetVerticalStretch(int)
	VerticalStretch() int
}

This interface is inherited by Widget

type State

type State int
const (
	Normal State = 1 << iota
	Hover
	Active
	Disabled
	Focused
)

type Vertical

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

func NewVertical

func NewVertical(parent Widget) *Vertical

func (*Vertical) AddChild

func (this *Vertical) AddChild(child Widget)

func (*Vertical) ChildOffset

func (this *Vertical) ChildOffset(child Widget) image.Point

func (*Vertical) Children

func (this *Vertical) Children() []Widget

func (*Vertical) Draw

func (this *Vertical) Draw(img draw.Image)

func (*Vertical) HorizontalStretch

func (this *Vertical) HorizontalStretch() int

func (*Vertical) Parent

func (this *Vertical) Parent() Widget

func (*Vertical) Update

func (this *Vertical) Update()

type Widget

type Widget interface {
	SizeI

	Parent() Widget
	Layout() Layout
	Offset() image.Point

	// Rectangle indicating content region
	ContentRect() image.Rectangle
	// Rectangle that includes the border and content regions
	BorderRect() image.Rectangle

	Update()
	Draw(draw.Image)

	MouseExitedEvent() bool
	MouseEnteredEvent(image.Point) bool
	MouseMoveEvent(where image.Point, from image.Point) bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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