widget

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Run() error
}

func NewFuncAction

func NewFuncAction(f func()) Action

func NewLinkAction

func NewLinkAction(link string) Action

type Audio

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

func NewAudio

func NewAudio(path string, repeat bool) (*Audio, error)

func (*Audio) Click

func (w *Audio) Click()

func (*Audio) Close

func (a *Audio) Close()

func (Audio) Color

func (w Audio) Color(state StateWidget) Color

func (Audio) IsHover

func (w Audio) IsHover(x, y int32) bool

func (*Audio) KeyboardEvent

func (w *Audio) KeyboardEvent(key *sdl.KeyboardEvent)

func (Audio) Position

func (w Audio) Position() Position

func (*Audio) Render

func (a *Audio) Render(r *sdl.Renderer) error

func (*Audio) SetAction

func (w *Audio) SetAction(a Action)

func (*Audio) SetActionColor

func (w *Audio) SetActionColor(c Color)

func (*Audio) SetColor

func (w *Audio) SetColor(c Color)

func (*Audio) SetHoverColor

func (w *Audio) SetHoverColor(c Color)

func (*Audio) SetPosition

func (w *Audio) SetPosition(x, y int32)

func (*Audio) SetSize

func (w *Audio) SetSize(width, height int32)

func (*Audio) SetState

func (w *Audio) SetState(s StateWidget)

func (*Audio) SetStateToPlay

func (a *Audio) SetStateToPlay(s StateWidget)

func (Audio) Size

func (w Audio) Size() (int32, int32)

Size return the width and height block

func (Audio) State

func (w Audio) State() StateWidget

State getter

func (*Audio) Unfocus

func (w *Audio) Unfocus()

Unfocus remove the focus on the widget focus define the last interaction with the widget (ex with input)

type Block

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

type Color

type Color struct {
	Red   uint8
	Green uint8
	Blue  uint8
	Alpha uint8
}
var (
	ColorWhite = Color{
		Red:   255,
		Green: 255,
		Blue:  255,
		Alpha: 255,
	}
	ColorBlack Color = Color{
		Red:   0,
		Green: 0,
		Blue:  0,
		Alpha: 255,
	}
	ColorRed Color = Color{
		Red:   255,
		Green: 0,
		Blue:  0,
		Alpha: 255,
	}
	ColorGreen Color = Color{
		Red:   0,
		Green: 255,
		Blue:  0,
		Alpha: 255,
	}
	ColorBlue Color = Color{
		Red:   0,
		Green: 0,
		Blue:  255,
		Alpha: 255,
	}
	ColorNoColor Color = Color{
		Red:   0,
		Green: 0,
		Blue:  0,
		Alpha: 0,
	}
)

Alpha 0: alpha disable Alpha 0: min oppacity Alpha 255: max oppacity

type Colors

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

type Ellipse

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

func NewEllipse

func NewEllipse(w, h int32) *Ellipse

func (*Ellipse) Click

func (w *Ellipse) Click()

func (*Ellipse) Close

func (e *Ellipse) Close()

func (Ellipse) Color

func (w Ellipse) Color(state StateWidget) Color

func (Ellipse) IsHover

func (e Ellipse) IsHover(x, y int32) bool

IsHover override the widget IsHover to check is mouse is hover the circle

func (*Ellipse) KeyboardEvent

func (w *Ellipse) KeyboardEvent(key *sdl.KeyboardEvent)

func (Ellipse) Position

func (w Ellipse) Position() Position

func (*Ellipse) Render

func (e *Ellipse) Render(r *sdl.Renderer) error

func (*Ellipse) SetAction

func (w *Ellipse) SetAction(a Action)

func (*Ellipse) SetActionColor

func (w *Ellipse) SetActionColor(c Color)

func (*Ellipse) SetColor

func (w *Ellipse) SetColor(c Color)

func (*Ellipse) SetHoverColor

func (w *Ellipse) SetHoverColor(c Color)

func (*Ellipse) SetPosition

func (e *Ellipse) SetPosition(x, y int32)

func (*Ellipse) SetSize

func (e *Ellipse) SetSize(w, h int32)

func (*Ellipse) SetState

func (w *Ellipse) SetState(s StateWidget)

func (*Ellipse) SetStyle

func (e *Ellipse) SetStyle(s EllipseStyle)

func (Ellipse) Size

func (w Ellipse) Size() (int32, int32)

Size return the width and height block

func (Ellipse) State

func (w Ellipse) State() StateWidget

State getter

func (*Ellipse) Unfocus

func (w *Ellipse) Unfocus()

Unfocus remove the focus on the widget focus define the last interaction with the widget (ex with input)

type EllipseStyle

type EllipseStyle uint8
const (
	EllipseStyleFill EllipseStyle = iota
	EllipseStyleBorder
)

type Font

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

func NewFont

func NewFont(file string, size int) (Font, error)

func (*Font) Close

func (f *Font) Close()

type Input

type Input struct {
	Text
	// contains filtered or unexported fields
}

func NewInput

func NewInput(font Font) (*Input, error)

func (*Input) Click

func (i *Input) Click()

func (Input) Color

func (w Input) Color(state StateWidget) Color

func (Input) IsHover

func (w Input) IsHover(x, y int32) bool

func (*Input) KeyboardEvent

func (i *Input) KeyboardEvent(key *sdl.KeyboardEvent)

func (Input) Position

func (w Input) Position() Position

func (*Input) Render

func (i *Input) Render(r *sdl.Renderer) error

func (*Input) SetAction

func (w *Input) SetAction(a Action)

func (*Input) SetActionColor

func (w *Input) SetActionColor(c Color)

func (*Input) SetColor

func (w *Input) SetColor(c Color)

func (*Input) SetHoverColor

func (w *Input) SetHoverColor(c Color)

func (*Input) SetPosition

func (w *Input) SetPosition(x, y int32)

func (*Input) SetSize

func (w *Input) SetSize(width, height int32)

func (*Input) SetState

func (w *Input) SetState(s StateWidget)

func (Input) Size

func (w Input) Size() (int32, int32)

Size return the width and height block

func (Input) State

func (w Input) State() StateWidget

State getter

func (*Input) Unfocus

func (w *Input) Unfocus()

Unfocus remove the focus on the widget focus define the last interaction with the widget (ex with input)

type Picture

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

func NewPicture

func NewPicture(path string) (*Picture, error)

func (*Picture) Click

func (w *Picture) Click()

func (*Picture) Close

func (p *Picture) Close()

func (Picture) Color

func (w Picture) Color(state StateWidget) Color

func (Picture) IsHover

func (w Picture) IsHover(x, y int32) bool

func (*Picture) KeyboardEvent

func (w *Picture) KeyboardEvent(key *sdl.KeyboardEvent)

func (Picture) Position

func (w Picture) Position() Position

func (*Picture) Render

func (p *Picture) Render(r *sdl.Renderer) error

func (*Picture) SetAction

func (w *Picture) SetAction(a Action)

func (*Picture) SetActionColor

func (w *Picture) SetActionColor(c Color)

func (*Picture) SetColor

func (w *Picture) SetColor(c Color)

func (*Picture) SetHeightRatioWidth

func (p *Picture) SetHeightRatioWidth(height int32)

func (*Picture) SetHoverColor

func (w *Picture) SetHoverColor(c Color)

func (*Picture) SetPosition

func (w *Picture) SetPosition(x, y int32)

func (*Picture) SetSize

func (w *Picture) SetSize(width, height int32)

func (*Picture) SetState

func (w *Picture) SetState(s StateWidget)

func (*Picture) SetWidthRatioHeight

func (p *Picture) SetWidthRatioHeight(width int32)

func (Picture) Size

func (w Picture) Size() (int32, int32)

Size return the width and height block

func (Picture) State

func (w Picture) State() StateWidget

State getter

func (*Picture) Unfocus

func (w *Picture) Unfocus()

Unfocus remove the focus on the widget focus define the last interaction with the widget (ex with input)

type Position

type Position struct {
	X int32
	Y int32
}

Position define a point in the space. X horizontal axe Y horizontal axe

type Rect

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

func NewRect

func NewRect(w, h int32) *Rect

func (*Rect) Click

func (w *Rect) Click()

func (*Rect) Close

func (r *Rect) Close()

func (Rect) Color

func (w Rect) Color(state StateWidget) Color

func (Rect) IsHover

func (w Rect) IsHover(x, y int32) bool

func (*Rect) KeyboardEvent

func (w *Rect) KeyboardEvent(key *sdl.KeyboardEvent)

func (Rect) Position

func (w Rect) Position() Position

func (*Rect) Render

func (r *Rect) Render(renderer *sdl.Renderer) error

func (*Rect) SetAction

func (w *Rect) SetAction(a Action)

func (*Rect) SetActionColor

func (w *Rect) SetActionColor(c Color)

func (*Rect) SetColor

func (w *Rect) SetColor(c Color)

func (*Rect) SetHoverColor

func (w *Rect) SetHoverColor(c Color)

func (*Rect) SetPosition

func (w *Rect) SetPosition(x, y int32)

func (*Rect) SetSize

func (w *Rect) SetSize(width, height int32)

func (*Rect) SetState

func (w *Rect) SetState(s StateWidget)

func (*Rect) SetStyle

func (r *Rect) SetStyle(s RectStyle)

func (Rect) Size

func (w Rect) Size() (int32, int32)

Size return the width and height block

func (Rect) State

func (w Rect) State() StateWidget

State getter

func (*Rect) Unfocus

func (w *Rect) Unfocus()

Unfocus remove the focus on the widget focus define the last interaction with the widget (ex with input)

type RectStyle

type RectStyle uint8
const (
	RectStyleFill RectStyle = iota
	RectStyleBorder
)

type StateWidget

type StateWidget uint8
const (
	StateBase StateWidget = iota
	StateHover
	StateAction
	StateOff
)

type Text

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

func NewText

func NewText(txt string, font Font) (*Text, error)

func (*Text) Click

func (w *Text) Click()

func (*Text) Close

func (t *Text) Close()

func (Text) Color

func (w Text) Color(state StateWidget) Color

func (Text) IsHover

func (w Text) IsHover(x, y int32) bool

func (*Text) KeyboardEvent

func (w *Text) KeyboardEvent(key *sdl.KeyboardEvent)

func (Text) Position

func (w Text) Position() Position

func (*Text) Render

func (t *Text) Render(r *sdl.Renderer) error

func (*Text) Set

func (t *Text) Set(txt string)

func (*Text) SetAction

func (w *Text) SetAction(a Action)

func (*Text) SetActionColor

func (w *Text) SetActionColor(c Color)

func (*Text) SetColor

func (w *Text) SetColor(c Color)

func (*Text) SetHoverColor

func (w *Text) SetHoverColor(c Color)

func (*Text) SetPosition

func (w *Text) SetPosition(x, y int32)

func (*Text) SetSize

func (w *Text) SetSize(width, height int32)

func (*Text) SetState

func (w *Text) SetState(s StateWidget)

func (Text) Size

func (w Text) Size() (int32, int32)

Size return the width and height block

func (*Text) SizeSTR

func (t *Text) SizeSTR() (int32, int32, error)

SizeSTR getter

func (Text) State

func (w Text) State() StateWidget

State getter

func (*Text) Unfocus

func (w *Text) Unfocus()

Unfocus remove the focus on the widget focus define the last interaction with the widget (ex with input)

type Widget

type Widget interface {
	SetColor(c Color)
	SetHoverColor(c Color)
	SetActionColor(c Color)
	SetAction(Action)
	Color(StateWidget) Color
	Position() Position
	SetPosition(x, y int32)
	IsHover(x, y int32) bool
	SetState(s StateWidget)
	State() StateWidget
	SetSize(w, h int32)
	Click()
	Unfocus()
	KeyboardEvent(key *sdl.KeyboardEvent)
	Size() (int32, int32)

	Render(r *sdl.Renderer) error
	Close()
}

Jump to

Keyboard shortcuts

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