Documentation ¶
Overview ¶
Package d2gui provides higher-level ui component management
Index ¶
- Constants
- type AnimatedSprite
- func (w AnimatedSprite) GetOffset() (x, y int)
- func (w AnimatedSprite) GetPosition() (x, y int)
- func (w AnimatedSprite) ScreenPos() (x, y int)
- func (w AnimatedSprite) SetExpanding(expanding bool)
- func (w AnimatedSprite) SetLayer(layer int)
- func (w AnimatedSprite) SetMouseClickHandler(handler MouseHandler)
- func (w AnimatedSprite) SetMouseEnterHandler(handler MouseMoveHandler)
- func (w AnimatedSprite) SetMouseLeaveHandler(handler MouseMoveHandler)
- func (w AnimatedSprite) SetPosition(x, y int)
- func (w AnimatedSprite) SetScreenPos(x, y int)
- func (w AnimatedSprite) SetVisible(visible bool)
- type AnimationDirection
- type Box
- func (box *Box) Close()
- func (box *Box) GetLayout() *Layout
- func (box *Box) IsInRect(px, py int) bool
- func (box *Box) IsOpen() bool
- func (box *Box) Load() error
- func (box *Box) OnMouseButtonDown(event d2interface.MouseEvent) bool
- func (box *Box) Open()
- func (box *Box) Render(target d2interface.Surface) error
- func (box *Box) SetOptions(options []*LabelButton)
- func (box *Box) SetPadding(paddingX, paddingY int)
- func (box *Box) Toggle()
- type Button
- func (w *Button) GetOffset() (x, y int)
- func (w *Button) GetPosition() (x, y int)
- func (w *Button) ScreenPos() (x, y int)
- func (w *Button) SetExpanding(expanding bool)
- func (w *Button) SetLayer(layer int)
- func (w *Button) SetMouseClickHandler(handler MouseHandler)
- func (w *Button) SetMouseEnterHandler(handler MouseMoveHandler)
- func (w *Button) SetMouseLeaveHandler(handler MouseMoveHandler)
- func (w *Button) SetPosition(x, y int)
- func (w *Button) SetScreenPos(x, y int)
- func (w *Button) SetVisible(visible bool)
- type ButtonStyle
- type FontStyle
- type GuiManager
- func (m *GuiManager) Advance(elapsed float64) error
- func (m *GuiManager) HideCursor()
- func (m *GuiManager) HideLoadScreen()
- func (m *GuiManager) OnMouseButtonDown(event d2interface.MouseEvent) bool
- func (m *GuiManager) OnMouseButtonUp(event d2interface.MouseEvent) bool
- func (m *GuiManager) OnMouseMove(event d2interface.MouseMoveEvent) bool
- func (m *GuiManager) Render(target d2interface.Surface) error
- func (m *GuiManager) SetLayout(layout *Layout)
- func (m *GuiManager) ShowCursor()
- func (m *GuiManager) ShowLoadScreen(progress float64)
- type HorizontalAlign
- type Label
- func (w *Label) GetOffset() (x, y int)
- func (w *Label) GetPosition() (x, y int)
- func (l *Label) GetText() string
- func (w *Label) ScreenPos() (x, y int)
- func (l *Label) SetColor(col color.RGBA) error
- func (w *Label) SetExpanding(expanding bool)
- func (l *Label) SetHoverColor(col color.RGBA)
- func (l *Label) SetIsBlinking(isBlinking bool)
- func (l *Label) SetIsHovered(isHovered bool) error
- func (w *Label) SetLayer(layer int)
- func (w *Label) SetMouseClickHandler(handler MouseHandler)
- func (w *Label) SetMouseEnterHandler(handler MouseMoveHandler)
- func (w *Label) SetMouseLeaveHandler(handler MouseMoveHandler)
- func (w *Label) SetPosition(x, y int)
- func (w *Label) SetScreenPos(x, y int)
- func (l *Label) SetText(text string) error
- func (w *Label) SetVisible(visible bool)
- type LabelButton
- func (lb *LabelButton) GetLayout() *Layout
- func (lb *LabelButton) IsHovered() bool
- func (lb *LabelButton) IsInRect(px, py int) bool
- func (lb *LabelButton) Load(renderer d2interface.Renderer, asset *d2asset.AssetManager)
- func (lb *LabelButton) SetCanHover(val bool)
- func (lb *LabelButton) SetHoverColor(col color.RGBA)
- func (lb *LabelButton) SetLabel(val string)
- type Layout
- func (l *Layout) AddAnimatedSprite(imagePath, palettePath string, direction AnimationDirection) (*AnimatedSprite, error)
- func (l *Layout) AddButton(text string, buttonStyle ButtonStyle) (*Button, error)
- func (l *Layout) AddLabel(text string, fontStyle FontStyle) (*Label, error)
- func (l *Layout) AddLabelWithColor(text string, fontStyle FontStyle, col color.RGBA) (*Label, error)
- func (l *Layout) AddLayout(positionType PositionType) *Layout
- func (l *Layout) AddLayoutFromSource(source *Layout) *Layout
- func (l *Layout) AddSpacerDynamic() *SpacerDynamic
- func (l *Layout) AddSpacerStatic(width, height int) *SpacerStatic
- func (l *Layout) AddSprite(imagePath, palettePath string) (*Sprite, error)
- func (l *Layout) AdjustEntryPlacement()
- func (l *Layout) Clear()
- func (w *Layout) GetOffset() (x, y int)
- func (w *Layout) GetPosition() (x, y int)
- func (l *Layout) GetSize() (width, height int)
- func (w *Layout) ScreenPos() (x, y int)
- func (w *Layout) SetExpanding(expanding bool)
- func (l *Layout) SetHorizontalAlign(horizontalAlign HorizontalAlign)
- func (w *Layout) SetLayer(layer int)
- func (w *Layout) SetMouseClickHandler(handler MouseHandler)
- func (w *Layout) SetMouseEnterHandler(handler MouseMoveHandler)
- func (w *Layout) SetMouseLeaveHandler(handler MouseMoveHandler)
- func (w *Layout) SetPosition(x, y int)
- func (w *Layout) SetScreenPos(x, y int)
- func (l *Layout) SetSize(width, height int)
- func (l *Layout) SetVerticalAlign(verticalAlign VerticalAlign)
- func (w *Layout) SetVisible(visible bool)
- type LayoutScrollbar
- func (scrollbar *LayoutScrollbar) Advance(elapsed float64) error
- func (scrollbar *LayoutScrollbar) IsArrowDownClicked() bool
- func (scrollbar *LayoutScrollbar) IsArrowUpClicked() bool
- func (scrollbar *LayoutScrollbar) IsInArrowDownRect(px, py int) bool
- func (scrollbar *LayoutScrollbar) IsInArrowUpRect(px, py int) bool
- func (scrollbar *LayoutScrollbar) IsInSliderRect(px, py int) bool
- func (scrollbar *LayoutScrollbar) IsSliderClicked() bool
- func (scrollbar *LayoutScrollbar) Load(ui *d2ui.UIManager) error
- func (scrollbar *LayoutScrollbar) OnArrowDownClick()
- func (scrollbar *LayoutScrollbar) OnArrowUpClick()
- func (scrollbar *LayoutScrollbar) OnMouseMove(event d2interface.MouseMoveEvent)
- func (scrollbar *LayoutScrollbar) OnSliderMouseClick(event d2interface.MouseEvent)
- func (scrollbar *LayoutScrollbar) Render(target d2interface.Surface)
- func (scrollbar *LayoutScrollbar) SetArrowDownClicked(value bool)
- func (scrollbar *LayoutScrollbar) SetArrowUpClicked(value bool)
- func (scrollbar *LayoutScrollbar) SetSliderClicked(value bool)
- type MouseHandler
- type MouseMoveHandler
- type PositionType
- type SpacerDynamic
- func (w *SpacerDynamic) GetOffset() (x, y int)
- func (w *SpacerDynamic) GetPosition() (x, y int)
- func (w *SpacerDynamic) ScreenPos() (x, y int)
- func (w *SpacerDynamic) SetExpanding(expanding bool)
- func (w *SpacerDynamic) SetLayer(layer int)
- func (w *SpacerDynamic) SetMouseClickHandler(handler MouseHandler)
- func (w *SpacerDynamic) SetMouseEnterHandler(handler MouseMoveHandler)
- func (w *SpacerDynamic) SetMouseLeaveHandler(handler MouseMoveHandler)
- func (w *SpacerDynamic) SetPosition(x, y int)
- func (w *SpacerDynamic) SetScreenPos(x, y int)
- func (w *SpacerDynamic) SetVisible(visible bool)
- type SpacerStatic
- func (w *SpacerStatic) GetOffset() (x, y int)
- func (w *SpacerStatic) GetPosition() (x, y int)
- func (w *SpacerStatic) ScreenPos() (x, y int)
- func (w *SpacerStatic) SetExpanding(expanding bool)
- func (w *SpacerStatic) SetLayer(layer int)
- func (w *SpacerStatic) SetMouseClickHandler(handler MouseHandler)
- func (w *SpacerStatic) SetMouseEnterHandler(handler MouseMoveHandler)
- func (w *SpacerStatic) SetMouseLeaveHandler(handler MouseMoveHandler)
- func (w *SpacerStatic) SetPosition(x, y int)
- func (w *SpacerStatic) SetScreenPos(x, y int)
- func (w *SpacerStatic) SetVisible(visible bool)
- type Sprite
- func (w *Sprite) GetOffset() (x, y int)
- func (w *Sprite) GetPosition() (x, y int)
- func (w *Sprite) ScreenPos() (x, y int)
- func (s *Sprite) SetEffect(e d2enum.DrawEffect)
- func (w *Sprite) SetExpanding(expanding bool)
- func (w *Sprite) SetLayer(layer int)
- func (w *Sprite) SetMouseClickHandler(handler MouseHandler)
- func (w *Sprite) SetMouseEnterHandler(handler MouseMoveHandler)
- func (w *Sprite) SetMouseLeaveHandler(handler MouseMoveHandler)
- func (w *Sprite) SetPosition(x, y int)
- func (w *Sprite) SetScreenPos(x, y int)
- func (s *Sprite) SetSegmented(segmentsX, segmentsY, frameOffset int)
- func (w *Sprite) SetVisible(visible bool)
- type VerticalAlign
Constants ¶
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) OnMouseButtonDown ¶
func (box *Box) OnMouseButtonDown(event d2interface.MouseEvent) bool
OnMouseButtonDown will be called whenever a mouse button is triggered
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 ¶
SetPadding sets the padding of the box content
type Button ¶
type Button struct {
// contains filtered or unexported fields
}
Button is a user actionable drawable toggle switch
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 GuiManager ¶
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) 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) GetPosition ¶
func (w *Label) GetPosition() (x, y int)
GetPosition returns the widget position
func (*Label) ScreenPos ¶
func (w *Label) ScreenPos() (x, y int)
ScreenPos returns the screen position
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 ¶
SetHoverColor will set the value of hoverColor
func (*Label) SetIsBlinking ¶
SetIsBlinking will set the isBlinking value
func (*Label) SetIsHovered ¶
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) SetVisible ¶
func (w *Label) SetVisible(visible bool)
SetVisible sets the widget's visibility
type LabelButton ¶
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 ¶
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 ¶
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) 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) GetPosition ¶
func (w *Layout) GetPosition() (x, y int)
GetPosition returns the widget position
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) 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) 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 ¶
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