MCPcopy Create free account
hub / github.com/SolarLune/masterplan / NewButton

Function NewButton

gui.go:771–800  ·  view source on GitHub ↗
(labelText string, rect, iconSrcRect *sdl.FRect, worldSpace bool, pressedFunc func())

Source from the content-addressed store, hash-verified

769}
770
771func NewButton(labelText string, rect, iconSrcRect *sdl.FRect, worldSpace bool, pressedFunc func()) *Button {
772
773 button := &Button{
774 Label: NewLabel(labelText, rect, worldSpace, AlignCenter),
775 IconSrc: iconSrcRect,
776 OnPressed: pressedFunc,
777 WorldSpace: worldSpace,
778 FadeOnInactive: true,
779 Highlighter: NewHighlighter(nil, worldSpace),
780 BackgroundColor: ColorTransparent,
781 TintByFontColor: true,
782 }
783
784 button.Highlighter.HighlightMode = HighlightUnderline
785
786 if rect == nil {
787 button.Label.RecreateTexture()
788 rect = button.Label.Rectangle()
789
790 if iconSrcRect != nil && labelText != "" {
791 rect.W += float32(iconSrcRect.W)
792 rect.X -= float32(iconSrcRect.W) / 2
793 }
794
795 }
796
797 button.SetRectangle(rect)
798
799 return button
800}
801
802func (button *Button) Update() {
803

Callers 8

NewDropdownFunction · 0.85
SetOptionsMethod · 0.85
SetChoicesMethod · 0.85
NewSoundContentsFunction · 0.85
NewSubPageContentsFunction · 0.85
NewLinkContentsFunction · 0.85
RowsMethod · 0.85
ConstructMenusFunction · 0.85

Calls 5

SetRectangleMethod · 0.95
NewLabelFunction · 0.85
NewHighlighterFunction · 0.85
RectangleMethod · 0.65
RecreateTextureMethod · 0.45

Tested by

no test coverage detected