d2gui

package
v0.0.0-...-7f92c57 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package d2gui provides higher-level ui component management

Index

Constants

View Source
const (
	ColorWhite = 0xffffffff
	ColorRed   = 0xdb3f3dff
	ColorGreen = 0x00d000ff
	ColorBlue  = 0x5450d1ff
	ColorBrown = 0xa1925dff
	ColorGrey  = 0x555555ff
)

Constants defining the main shades of basic colors found in the game

Variables

This section is empty.

Functions

This section is empty.

Types

type AnimatedSprite

type AnimatedSprite struct {
	*Sprite
}

AnimatedSprite is a sprite that has animation

func (AnimatedSprite) GetOffset

func (w AnimatedSprite) GetOffset() (x, y int)

GetOffset gets the widget offset

func (AnimatedSprite) GetPosition

func (w AnimatedSprite) GetPosition() (x, y int)

GetPosition returns the widget position

func (AnimatedSprite) ScreenPos

func (w AnimatedSprite) ScreenPos() (x, y int)

ScreenPos returns the screen position

func (AnimatedSprite) SetExpanding

func (w AnimatedSprite) SetExpanding(expanding bool)

SetExpanding tells the widget to expand (or not) when inside of a layout

func (AnimatedSprite) SetLayer

func (w AnimatedSprite) SetLayer(layer int)

SetLayer sets the widget layer (for rendering order)

func (AnimatedSprite) SetMouseClickHandler

func (w AnimatedSprite) SetMouseClickHandler(handler MouseHandler)

SetMouseClickHandler sets the handler function for mouse-click events

func (AnimatedSprite) SetMouseEnterHandler

func (w AnimatedSprite) SetMouseEnterHandler(handler MouseMoveHandler)

SetMouseEnterHandler sets the handler function for mouse-enter events

func (AnimatedSprite) SetMouseLeaveHandler

func (w AnimatedSprite) SetMouseLeaveHandler(handler MouseMoveHandler)

SetMouseLeaveHandler sets the handler function for mouse-leave events

func (AnimatedSprite) SetPosition

func (w AnimatedSprite) SetPosition(x, y int)

SetPosition sets the widget position

func (AnimatedSprite) SetScreenPos

func (w AnimatedSprite) SetScreenPos(x, y int)

SetScreenPos sets the screen position

func (AnimatedSprite) SetVisible

func (w AnimatedSprite) SetVisible(visible bool)

SetVisible sets the widget's visibility

type AnimationDirection

type AnimationDirection int

AnimationDirection is a the animation play direction

const (
	DirectionForward AnimationDirection = iota
	DirectionBackward
)

AnimationDirection types

type Box

type Box struct {
	Options []*LabelButton

	*d2util.Logger
	// contains filtered or unexported fields
}

Box takes a content layout and wraps in a box

func NewBox

func NewBox(
	asset *d2asset.AssetManager,
	renderer d2interface.Renderer,
	ui *d2ui.UIManager,
	contentLayout *Layout,
	width, height, x, y int,
	l d2util.LogLevel,
	title string,
) *Box

NewBox return a new Box instance

func (*Box) Close

func (box *Box) Close()

Close will hide the help overlay

func (*Box) GetLayout

func (box *Box) GetLayout() *Layout

GetLayout returns the box layout

func (*Box) IsInRect

func (box *Box) IsInRect(px, py int) bool

IsInRect checks if the given point is within the box main layout rectangle

func (*Box) IsOpen

func (box *Box) IsOpen() bool

IsOpen returns whether or not the box is opened

func (*Box) Load

func (box *Box) Load() error

Load will setup the layouts and sprites for the box deptending on the parameters

func (*Box) OnMouseButtonDown

func (box *Box) OnMouseButtonDown(event d2interface.MouseEvent) bool

OnMouseButtonDown will be called whenever a mouse button is triggered

func (*Box) Open

func (box *Box) Open()

Open will set the isOpen value to true

func (*Box) Render

func (box *Box) Render(target d2interface.Surface) error

Render the box to the given surface

func (*Box) SetOptions

func (box *Box) SetOptions(options []*LabelButton)

SetOptions sets the box options that will show up at the bottom

func (*Box) SetPadding

func (box *Box) SetPadding(paddingX, paddingY int)

SetPadding sets the padding of the box content

func (*Box) Toggle

func (box *Box) Toggle()

Toggle the visibility state of the menu

type Button

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

Button is a user actionable drawable toggle switch

func (*Button) GetOffset

func (w *Button) GetOffset() (x, y int)

GetOffset gets the widget offset

func (*Button) GetPosition

func (w *Button) GetPosition() (x, y int)

GetPosition returns the widget position

func (*Button) ScreenPos

func (w *Button) ScreenPos() (x, y int)

ScreenPos returns the screen position

func (*Button) SetExpanding

func (w *Button) SetExpanding(expanding bool)

SetExpanding tells the widget to expand (or not) when inside of a layout

func (*Button) SetLayer

func (w *Button) SetLayer(layer int)

SetLayer sets the widget layer (for rendering order)

func (*Button) SetMouseClickHandler

func (w *Button) SetMouseClickHandler(handler MouseHandler)

SetMouseClickHandler sets the handler function for mouse-click events

func (*Button) SetMouseEnterHandler

func (w *Button) SetMouseEnterHandler(handler MouseMoveHandler)

SetMouseEnterHandler sets the handler function for mouse-enter events

func (*Button) SetMouseLeaveHandler

func (w *Button) SetMouseLeaveHandler(handler MouseMoveHandler)

SetMouseLeaveHandler sets the handler function for mouse-leave events

func (*Button) SetPosition

func (w *Button) SetPosition(x, y int)

SetPosition sets the widget position

func (*Button) SetScreenPos

func (w *Button) SetScreenPos(x, y int)

SetScreenPos sets the screen position

func (*Button) SetVisible

func (w *Button) SetVisible(visible bool)

SetVisible sets the widget's visibility

type ButtonStyle

type ButtonStyle int

ButtonStyle is a representation of a button style. Button styles have x and y sebment counts, an image, a palette, a font, and a text offset

const (
	ButtonStyleMedium ButtonStyle = iota
	ButtonStyleNarrow
	ButtonStyleOkCancel
	ButtonStyleShort
	ButtonStyleTall
	ButtonStyleWide
)

Button styles

type FontStyle

type FontStyle int

FontStyle is a representation of a font with a palette

const (
	FontStyle16Units FontStyle = iota
	FontStyle30Units
	FontStyle42Units
	FontStyleExocet10
	FontStyleFormal10Static
	FontStyleFormal11Units
	FontStyleFormal12Static
	FontStyleRediculous
)

Font styles

type GuiManager

type GuiManager struct {
	*d2util.Logger
	// contains filtered or unexported fields
}

GuiManager is a GUI widget manager that handles dynamic layout/positioning of widgets

func CreateGuiManager

func CreateGuiManager(asset *d2asset.AssetManager, l d2util.LogLevel, inputManager d2interface.InputManager) (*GuiManager, error)

CreateGuiManager creates an instance of the GuiManager

func (*GuiManager) Advance

func (m *GuiManager) Advance(elapsed float64) error

Advance advances the GuiManager state

func (*GuiManager) HideCursor

func (m *GuiManager) HideCursor()

HideCursor hides the cursor

func (*GuiManager) HideLoadScreen

func (m *GuiManager) HideLoadScreen()

HideLoadScreen hides the load screen

func (*GuiManager) OnMouseButtonDown

func (m *GuiManager) OnMouseButtonDown(event d2interface.MouseEvent) bool

OnMouseButtonDown handles mouse button click events

func (*GuiManager) OnMouseButtonUp

func (m *GuiManager) OnMouseButtonUp(event d2interface.MouseEvent) bool

OnMouseButtonUp handles the mouse button release events

func (*GuiManager) OnMouseMove

func (m *GuiManager) OnMouseMove(event d2interface.MouseMoveEvent) bool

OnMouseMove handles mouse movement events

func (*GuiManager) Render

func (m *GuiManager) Render(target d2interface.Surface) error

Render renders the GuiManager to the given surface

func (*GuiManager) SetLayout

func (m *GuiManager) SetLayout(layout *Layout)

SetLayout sets the layout of the GuiManager

func (*GuiManager) ShowCursor

func (m *GuiManager) ShowCursor()

ShowCursor makes the cursor visible

func (*GuiManager) ShowLoadScreen

func (m *GuiManager) ShowLoadScreen(progress float64)

ShowLoadScreen shows the loading screen with the given progress

type HorizontalAlign

type HorizontalAlign int

HorizontalAlign type, determines alignment along x-axis within a layout

const (
	HorizontalAlignLeft HorizontalAlign = iota
	HorizontalAlignCenter
	HorizontalAlignRight
)

Horizontal alignment types

type Label

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

Label is renderable text

func (*Label) GetOffset

func (w *Label) GetOffset() (x, y int)

GetOffset gets the widget offset

func (*Label) GetPosition

func (w *Label) GetPosition() (x, y int)

GetPosition returns the widget position

func (*Label) GetText

func (l *Label) GetText() string

GetText returns the label text

func (*Label) ScreenPos

func (w *Label) ScreenPos() (x, y int)

ScreenPos returns the screen position

func (*Label) SetColor

func (l *Label) SetColor(col color.RGBA) error

SetColor sets the label text

func (*Label) SetExpanding

func (w *Label) SetExpanding(expanding bool)

SetExpanding tells the widget to expand (or not) when inside of a layout

func (*Label) SetHoverColor

func (l *Label) SetHoverColor(col color.RGBA)

SetHoverColor will set the value of hoverColor

func (*Label) SetIsBlinking

func (l *Label) SetIsBlinking(isBlinking bool)

SetIsBlinking will set the isBlinking value

func (*Label) SetIsHovered

func (l *Label) SetIsHovered(isHovered bool) error

SetIsHovered will set the isHovered value

func (*Label) SetLayer

func (w *Label) SetLayer(layer int)

SetLayer sets the widget layer (for rendering order)

func (*Label) SetMouseClickHandler

func (w *Label) SetMouseClickHandler(handler MouseHandler)

SetMouseClickHandler sets the handler function for mouse-click events

func (*Label) SetMouseEnterHandler

func (w *Label) SetMouseEnterHandler(handler MouseMoveHandler)

SetMouseEnterHandler sets the handler function for mouse-enter events

func (*Label) SetMouseLeaveHandler

func (w *Label) SetMouseLeaveHandler(handler MouseMoveHandler)

SetMouseLeaveHandler sets the handler function for mouse-leave events

func (*Label) SetPosition

func (w *Label) SetPosition(x, y int)

SetPosition sets the widget position

func (*Label) SetScreenPos

func (w *Label) SetScreenPos(x, y int)

SetScreenPos sets the screen position

func (*Label) SetText

func (l *Label) SetText(text string) error

SetText sets the label text

func (*Label) SetVisible

func (w *Label) SetVisible(visible bool)

SetVisible sets the widget's visibility

type LabelButton

type LabelButton struct {
	*d2util.Logger
	// contains filtered or unexported fields
}

LabelButton is a label that can change when hovered and has a callback function that can be called when clicked

func NewLabelButton

func NewLabelButton(x, y int, text string, col color.RGBA, l d2util.LogLevel, callback func()) *LabelButton

NewLabelButton generates a new instance of LabelButton

func (*LabelButton) GetLayout

func (lb *LabelButton) GetLayout() *Layout

GetLayout returns the laout of the label

func (*LabelButton) IsHovered

func (lb *LabelButton) IsHovered() bool

IsHovered returns the value of isHovered

func (*LabelButton) IsInRect

func (lb *LabelButton) IsInRect(px, py int) bool

IsInRect checks if the given point is within the overlay layout rectangle

func (*LabelButton) Load

func (lb *LabelButton) Load(renderer d2interface.Renderer, asset *d2asset.AssetManager)

Load sets the button handlers and sets the layouts

func (*LabelButton) SetCanHover

func (lb *LabelButton) SetCanHover(val bool)

SetCanHover sets the value of canHover

func (*LabelButton) SetHoverColor

func (lb *LabelButton) SetHoverColor(col color.RGBA)

SetHoverColor sets the hover color of the Label

func (*LabelButton) SetLabel

func (lb *LabelButton) SetLabel(val string)

SetLabel sets the text of label label

type Layout

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

Layout is a gui element container which will automatically position/align gui elements. Layouts are gui elements as well, so they can be nested in other layouts.

func CreateLayout

func CreateLayout(renderer d2interface.Renderer, positionType PositionType, assetManager *d2asset.AssetManager) *Layout

CreateLayout creates a new GUI layout

func (*Layout) AddAnimatedSprite

func (l *Layout) AddAnimatedSprite(imagePath, palettePath string, direction AnimationDirection) (*AnimatedSprite, error)

AddAnimatedSprite given a path, palette, and direction will add an animated sprite as a layout entry

func (*Layout) AddButton

func (l *Layout) AddButton(text string, buttonStyle ButtonStyle) (*Button, error)

AddButton given a string and ButtonStyle, adds a button as a layout entry

func (*Layout) AddLabel

func (l *Layout) AddLabel(text string, fontStyle FontStyle) (*Label, error)

AddLabel given a string and a FontStyle, adds a text label as a layout entry

func (*Layout) AddLabelWithColor

func (l *Layout) AddLabelWithColor(text string, fontStyle FontStyle, col color.RGBA) (*Label, error)

AddLabelWithColor given a string and a FontStyle and a Color, adds a text label as a layout entry

func (*Layout) AddLayout

func (l *Layout) AddLayout(positionType PositionType) *Layout

AddLayout adds a nested layout to this layout, given a position type. Returns a pointer to the nested layout

func (*Layout) AddLayoutFromSource

func (l *Layout) AddLayoutFromSource(source *Layout) *Layout

AddLayoutFromSource adds a nested layout to this layout, given a position type. Returns a pointer to the nested layout

func (*Layout) AddSpacerDynamic

func (l *Layout) AddSpacerDynamic() *SpacerDynamic

AddSpacerDynamic adds a spacer which has dynamic width and height. The width and height are computed based off of the position/alignment type of the layout and the dimensions/positions of the layout entries.

func (*Layout) AddSpacerStatic

func (l *Layout) AddSpacerStatic(width, height int) *SpacerStatic

AddSpacerStatic adds a spacer with explicitly defined height and width

func (*Layout) AddSprite

func (l *Layout) AddSprite(imagePath, palettePath string) (*Sprite, error)

AddSprite given a path and palette, adds a Sprite as a layout entry

func (*Layout) AdjustEntryPlacement

func (l *Layout) AdjustEntryPlacement()

AdjustEntryPlacement calculates and sets the position for all layout entries. This is based on the position/horizontal/vertical alignment type set, as well as the expansion types of spacers.

func (*Layout) Clear

func (l *Layout) Clear()

Clear removes all layout entries

func (*Layout) GetOffset

func (w *Layout) GetOffset() (x, y int)

GetOffset gets the widget offset

func (*Layout) GetPosition

func (w *Layout) GetPosition() (x, y int)

GetPosition returns the widget position

func (*Layout) GetSize

func (l *Layout) GetSize() (width, height int)

GetSize returns the layout width and height

func (*Layout) ScreenPos

func (w *Layout) ScreenPos() (x, y int)

ScreenPos returns the screen position

func (*Layout) SetExpanding

func (w *Layout) SetExpanding(expanding bool)

SetExpanding tells the widget to expand (or not) when inside of a layout

func (*Layout) SetHorizontalAlign

func (l *Layout) SetHorizontalAlign(horizontalAlign HorizontalAlign)

SetHorizontalAlign sets the horizontal alignment type of the layout

func (*Layout) SetLayer

func (w *Layout) SetLayer(layer int)

SetLayer sets the widget layer (for rendering order)

func (*Layout) SetMouseClickHandler

func (w *Layout) SetMouseClickHandler(handler MouseHandler)

SetMouseClickHandler sets the handler function for mouse-click events

func (*Layout) SetMouseEnterHandler

func (w *Layout) SetMouseEnterHandler(handler MouseMoveHandler)

SetMouseEnterHandler sets the handler function for mouse-enter events

func (*Layout) SetMouseLeaveHandler

func (w *Layout) SetMouseLeaveHandler(handler MouseMoveHandler)

SetMouseLeaveHandler sets the handler function for mouse-leave events

func (*Layout) SetPosition

func (w *Layout) SetPosition(x, y int)

SetPosition sets the widget position

func (*Layout) SetScreenPos

func (w *Layout) SetScreenPos(x, y int)

SetScreenPos sets the screen position

func (*Layout) SetSize

func (l *Layout) SetSize(width, height int)

SetSize sets the size of the layout

func (*Layout) SetVerticalAlign

func (l *Layout) SetVerticalAlign(verticalAlign VerticalAlign)

SetVerticalAlign sets the vertical alignment type of the layout

func (*Layout) SetVisible

func (w *Layout) SetVisible(visible bool)

SetVisible sets the widget's visibility

type LayoutScrollbar

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

LayoutScrollbar is a scrollbar that can be used with any layout and attaches to a main layout. You need to use a wrapper for your content as main layout in order for the scrollbar to work properly

func NewLayoutScrollbar

func NewLayoutScrollbar(parentLayout, targetLayout *Layout) *LayoutScrollbar

NewLayoutScrollbar attaches a scrollbar to the parentLayout to control the targetLayout

func (*LayoutScrollbar) Advance

func (scrollbar *LayoutScrollbar) Advance(elapsed float64) error

Advance updates the layouts according to the state of the arrown

func (*LayoutScrollbar) IsArrowDownClicked

func (scrollbar *LayoutScrollbar) IsArrowDownClicked() bool

IsArrowDownClicked returns the state of arrow down clicked

func (*LayoutScrollbar) IsArrowUpClicked

func (scrollbar *LayoutScrollbar) IsArrowUpClicked() bool

IsArrowUpClicked returns the state of arrow up clicked

func (*LayoutScrollbar) IsInArrowDownRect

func (scrollbar *LayoutScrollbar) IsInArrowDownRect(px, py int) bool

IsInArrowDownRect checks if the given point is within the overlay layout rectangle

func (*LayoutScrollbar) IsInArrowUpRect

func (scrollbar *LayoutScrollbar) IsInArrowUpRect(px, py int) bool

IsInArrowUpRect checks if the given point is within the overlay layout rectangle

func (*LayoutScrollbar) IsInSliderRect

func (scrollbar *LayoutScrollbar) IsInSliderRect(px, py int) bool

IsInSliderRect checks if the given point is within the overlay layout rectangle

func (*LayoutScrollbar) IsSliderClicked

func (scrollbar *LayoutScrollbar) IsSliderClicked() bool

IsSliderClicked returns the state of the slider

func (*LayoutScrollbar) Load

func (scrollbar *LayoutScrollbar) Load(ui *d2ui.UIManager) error

Load sets the scrollbar layouts and loads the sprites

func (*LayoutScrollbar) OnArrowDownClick

func (scrollbar *LayoutScrollbar) OnArrowDownClick()

OnArrowDownClick will move the slider and the content down

func (*LayoutScrollbar) OnArrowUpClick

func (scrollbar *LayoutScrollbar) OnArrowUpClick()

OnArrowUpClick will move the slider and the content up

func (*LayoutScrollbar) OnMouseMove

func (scrollbar *LayoutScrollbar) OnMouseMove(event d2interface.MouseMoveEvent)

OnMouseMove will affect the slider and the content depending on the state fof it

func (*LayoutScrollbar) OnSliderMouseClick

func (scrollbar *LayoutScrollbar) OnSliderMouseClick(event d2interface.MouseEvent)

OnSliderMouseClick affects the state of the slider

func (*LayoutScrollbar) Render

func (scrollbar *LayoutScrollbar) Render(target d2interface.Surface)

Render draws the scrollbar sprites on the given surface

func (*LayoutScrollbar) SetArrowDownClicked

func (scrollbar *LayoutScrollbar) SetArrowDownClicked(value bool)

SetArrowDownClicked sets the value of sliderClicked

func (*LayoutScrollbar) SetArrowUpClicked

func (scrollbar *LayoutScrollbar) SetArrowUpClicked(value bool)

SetArrowUpClicked sets the value of sliderClicked

func (*LayoutScrollbar) SetSliderClicked

func (scrollbar *LayoutScrollbar) SetSliderClicked(value bool)

SetSliderClicked sets the value of sliderClicked

type MouseHandler

type MouseHandler func(d2interface.MouseEvent)

MouseHandler is a handler function for mouse events

type MouseMoveHandler

type MouseMoveHandler func(d2interface.MouseMoveEvent)

MouseMoveHandler is a handler function for mouse movement events

type PositionType

type PositionType int

PositionType determines layout positioning

const (
	PositionTypeAbsolute PositionType = iota
	PositionTypeVertical
	PositionTypeHorizontal
)

Positioning types

type SpacerDynamic

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

SpacerDynamic is a spacer that will expand within a layout, depending on the layout position and alignment types

func (*SpacerDynamic) GetOffset

func (w *SpacerDynamic) GetOffset() (x, y int)

GetOffset gets the widget offset

func (*SpacerDynamic) GetPosition

func (w *SpacerDynamic) GetPosition() (x, y int)

GetPosition returns the widget position

func (*SpacerDynamic) ScreenPos

func (w *SpacerDynamic) ScreenPos() (x, y int)

ScreenPos returns the screen position

func (*SpacerDynamic) SetExpanding

func (w *SpacerDynamic) SetExpanding(expanding bool)

SetExpanding tells the widget to expand (or not) when inside of a layout

func (*SpacerDynamic) SetLayer

func (w *SpacerDynamic) SetLayer(layer int)

SetLayer sets the widget layer (for rendering order)

func (*SpacerDynamic) SetMouseClickHandler

func (w *SpacerDynamic) SetMouseClickHandler(handler MouseHandler)

SetMouseClickHandler sets the handler function for mouse-click events

func (*SpacerDynamic) SetMouseEnterHandler

func (w *SpacerDynamic) SetMouseEnterHandler(handler MouseMoveHandler)

SetMouseEnterHandler sets the handler function for mouse-enter events

func (*SpacerDynamic) SetMouseLeaveHandler

func (w *SpacerDynamic) SetMouseLeaveHandler(handler MouseMoveHandler)

SetMouseLeaveHandler sets the handler function for mouse-leave events

func (*SpacerDynamic) SetPosition

func (w *SpacerDynamic) SetPosition(x, y int)

SetPosition sets the widget position

func (*SpacerDynamic) SetScreenPos

func (w *SpacerDynamic) SetScreenPos(x, y int)

SetScreenPos sets the screen position

func (*SpacerDynamic) SetVisible

func (w *SpacerDynamic) SetVisible(visible bool)

SetVisible sets the widget's visibility

type SpacerStatic

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

SpacerStatic is a spacer with explicit width and height, meaning that it wont dynamically expand within a layout

func (*SpacerStatic) GetOffset

func (w *SpacerStatic) GetOffset() (x, y int)

GetOffset gets the widget offset

func (*SpacerStatic) GetPosition

func (w *SpacerStatic) GetPosition() (x, y int)

GetPosition returns the widget position

func (*SpacerStatic) ScreenPos

func (w *SpacerStatic) ScreenPos() (x, y int)

ScreenPos returns the screen position

func (*SpacerStatic) SetExpanding

func (w *SpacerStatic) SetExpanding(expanding bool)

SetExpanding tells the widget to expand (or not) when inside of a layout

func (*SpacerStatic) SetLayer

func (w *SpacerStatic) SetLayer(layer int)

SetLayer sets the widget layer (for rendering order)

func (*SpacerStatic) SetMouseClickHandler

func (w *SpacerStatic) SetMouseClickHandler(handler MouseHandler)

SetMouseClickHandler sets the handler function for mouse-click events

func (*SpacerStatic) SetMouseEnterHandler

func (w *SpacerStatic) SetMouseEnterHandler(handler MouseMoveHandler)

SetMouseEnterHandler sets the handler function for mouse-enter events

func (*SpacerStatic) SetMouseLeaveHandler

func (w *SpacerStatic) SetMouseLeaveHandler(handler MouseMoveHandler)

SetMouseLeaveHandler sets the handler function for mouse-leave events

func (*SpacerStatic) SetPosition

func (w *SpacerStatic) SetPosition(x, y int)

SetPosition sets the widget position

func (*SpacerStatic) SetScreenPos

func (w *SpacerStatic) SetScreenPos(x, y int)

SetScreenPos sets the screen position

func (*SpacerStatic) SetVisible

func (w *SpacerStatic) SetVisible(visible bool)

SetVisible sets the widget's visibility

type Sprite

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

Sprite is an image

func (*Sprite) GetOffset

func (w *Sprite) GetOffset() (x, y int)

GetOffset gets the widget offset

func (*Sprite) GetPosition

func (w *Sprite) GetPosition() (x, y int)

GetPosition returns the widget position

func (*Sprite) ScreenPos

func (w *Sprite) ScreenPos() (x, y int)

ScreenPos returns the screen position

func (*Sprite) SetEffect

func (s *Sprite) SetEffect(e d2enum.DrawEffect)

SetEffect sets the draw effect for the sprite

func (*Sprite) SetExpanding

func (w *Sprite) SetExpanding(expanding bool)

SetExpanding tells the widget to expand (or not) when inside of a layout

func (*Sprite) SetLayer

func (w *Sprite) SetLayer(layer int)

SetLayer sets the widget layer (for rendering order)

func (*Sprite) SetMouseClickHandler

func (w *Sprite) SetMouseClickHandler(handler MouseHandler)

SetMouseClickHandler sets the handler function for mouse-click events

func (*Sprite) SetMouseEnterHandler

func (w *Sprite) SetMouseEnterHandler(handler MouseMoveHandler)

SetMouseEnterHandler sets the handler function for mouse-enter events

func (*Sprite) SetMouseLeaveHandler

func (w *Sprite) SetMouseLeaveHandler(handler MouseMoveHandler)

SetMouseLeaveHandler sets the handler function for mouse-leave events

func (*Sprite) SetPosition

func (w *Sprite) SetPosition(x, y int)

SetPosition sets the widget position

func (*Sprite) SetScreenPos

func (w *Sprite) SetScreenPos(x, y int)

SetScreenPos sets the screen position

func (*Sprite) SetSegmented

func (s *Sprite) SetSegmented(segmentsX, segmentsY, frameOffset int)

SetSegmented sets the segment properties of the sprite

func (*Sprite) SetVisible

func (w *Sprite) SetVisible(visible bool)

SetVisible sets the widget's visibility

type VerticalAlign

type VerticalAlign int

VerticalAlign type, determines alignment along y-axis within a layout

const (
	VerticalAlignTop VerticalAlign = iota
	VerticalAlignMiddle
	VerticalAlignBottom
)

VerticalAlign types

Jump to

Keyboard shortcuts

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