gui

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ActiveUI

func ActiveUI(ui IUIPanel)

func CloseUI

func CloseUI(ui IUIPanel)

func Draw

func Draw(screen *ebiten.Image)

func Focused

func Focused() bool

Focused 正有焦点接收中

func GetDefaultUIFont

func GetDefaultUIFont() font.Face

func GetDefaultUIImage

func GetDefaultUIImage() *ebiten.Image

func IsFrameClick

func IsFrameClick() bool

func IsFrameHover

func IsFrameHover() bool

func MakeOptionBoxGroup

func MakeOptionBoxGroup(a ...*OptionBox) map[*OptionBox]struct{}

func OnLayout

func OnLayout(w, h int)

func SetBorderDebug

func SetBorderDebug(v bool)

func SetDefaultUIFont

func SetDefaultUIFont(f font.Face)

func SetDefaultUIImage

func SetDefaultUIImage(img *ebiten.Image)

func SetFrameClick

func SetFrameClick()

func SetFrameHover

func SetFrameHover()

func Update

func Update()

Types

type BaseUI

type BaseUI struct {
	X, Y, W, H  int
	Depth       int  //update draw depth
	Visible     bool //`default:"true"` disable draw
	Disabled    bool //disable update
	EnableFocus bool //enable focus

	BGColor color.Color
	BDColor color.Color
	Image   *ebiten.Image
	DrawOp  ebiten.DrawImageOptions
	// contains filtered or unexported fields
}

func (*BaseUI) AddChildren

func (u *BaseUI) AddChildren(cs ...IUIPanel)

func (*BaseUI) Draw

func (u *BaseUI) Draw(screen *ebiten.Image)

func (*BaseUI) Focused

func (u *BaseUI) Focused() bool

func (*BaseUI) GetBDColor

func (u *BaseUI) GetBDColor() color.Color

func (*BaseUI) GetDepth

func (u *BaseUI) GetDepth() int

func (*BaseUI) GetImage

func (u *BaseUI) GetImage() *ebiten.Image

func (*BaseUI) GetParent

func (u *BaseUI) GetParent() IUIPanel

func (*BaseUI) GetWH

func (u *BaseUI) GetWH() (int, int)

GetWH 获取宽高

func (*BaseUI) GetWorldXY

func (u *BaseUI) GetWorldXY() (int, int)

GetWorldXY 获取绝对坐标

func (*BaseUI) GetXY

func (u *BaseUI) GetXY() (int, int)

GetXY 获取相对坐标

func (*BaseUI) IsDisabled

func (u *BaseUI) IsDisabled() bool

func (*BaseUI) IsVisible

func (u *BaseUI) IsVisible() bool

func (*BaseUI) OnClose

func (u *BaseUI) OnClose()

func (*BaseUI) OnLayout

func (u *BaseUI) OnLayout(w, h int)

func (*BaseUI) RemoveChild

func (u *BaseUI) RemoveChild(c IUIPanel)

func (*BaseUI) SetFocused

func (u *BaseUI) SetFocused(focused bool)

func (*BaseUI) SetOnHout

func (u *BaseUI) SetOnHout(f func())

func (*BaseUI) SetOnHover

func (u *BaseUI) SetOnHover(f func())

func (*BaseUI) SetParent

func (u *BaseUI) SetParent(p IUIPanel)

func (*BaseUI) Update

func (u *BaseUI) Update()

type Button

type Button struct {
	BaseUI
	Text string

	AutoSizeByText bool

	TextColor        color.Color
	UIImage          *ebiten.Image
	ImageRect        image.Rectangle
	ImageRectPressed image.Rectangle
	// contains filtered or unexported fields
}

func NewButton

func NewButton(x, y, w, h int, text string) *Button

func NewTextButton

func NewTextButton(x, y int, text string, textColor, bdColor color.Color) *Button

NewTextButton 按text长度自动调整大小无背景UI

func (*Button) Click

func (b *Button) Click()

func (*Button) Draw

func (b *Button) Draw(dst *ebiten.Image)

func (*Button) SetOnClick

func (b *Button) SetOnClick(f func())

func (*Button) Update

func (b *Button) Update()

type CheckBox

type CheckBox struct {
	BaseUI
	Text string

	UIImage          *ebiten.Image
	ImageRect        image.Rectangle
	ImageRectPressed image.Rectangle
	ImageRectMark    image.Rectangle
	// contains filtered or unexported fields
}

func NewCheckBox

func NewCheckBox(x, y int, text string) *CheckBox

func (*CheckBox) Checked

func (c *CheckBox) Checked() bool

func (*CheckBox) Draw

func (c *CheckBox) Draw(dst *ebiten.Image)

func (*CheckBox) SetChecked

func (c *CheckBox) SetChecked(b bool)

func (*CheckBox) SetOnCheckChanged

func (c *CheckBox) SetOnCheckChanged(f func(c *CheckBox))

func (*CheckBox) Update

func (c *CheckBox) Update()

type Dragger

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

func (*Dragger) Offset

func (d *Dragger) Offset() (int, int)

func (*Dragger) Update

func (d *Dragger) Update()

type HScrollBar

type HScrollBar struct {
	BaseUI

	UIImage        *ebiten.Image
	ImageRectBack  image.Rectangle
	ImageRectFront image.Rectangle
	// contains filtered or unexported fields
}

HScrollBar 横向ScrollBar

func NewHScrollBar

func NewHScrollBar() *HScrollBar

func (*HScrollBar) ContentOffset

func (v *HScrollBar) ContentOffset() int

func (*HScrollBar) Draw

func (v *HScrollBar) Draw(dst *ebiten.Image)

func (*HScrollBar) Update

func (v *HScrollBar) Update(wx, wy, contentWidth int)

type IUIPanel

type IUIPanel interface {
	Update()
	Draw(screen *ebiten.Image)
	OnClose()
	OnLayout(w, h int)

	IsDisabled() bool
	IsVisible() bool
	GetXY() (int, int)
	GetWH() (int, int)
	GetWorldXY() (int, int)
	GetDepth() int
	GetBDColor() color.Color
	GetParent() IUIPanel
	SetParent(p IUIPanel)
	GetImage() *ebiten.Image
}

type InputBox

type InputBox struct {
	BaseUI

	DefaultText  string //无Text时默认灰文本
	MaxChars     int    //最大长度
	PasswordChar string //密文显示

	Editable   bool
	Selectable bool

	UIImage   *ebiten.Image
	ImageRect image.Rectangle
	// contains filtered or unexported fields
}

func NewInputBox

func NewInputBox(x, y, w, h int) *InputBox

func (*InputBox) AppendTextHistory

func (i *InputBox) AppendTextHistory(txt string)

func (*InputBox) Draw

func (i *InputBox) Draw(dst *ebiten.Image)

func (*InputBox) SetOnPressEnter

func (i *InputBox) SetOnPressEnter(f func(*InputBox))

func (*InputBox) SetText

func (i *InputBox) SetText(v interface{})

func (*InputBox) Text

func (i *InputBox) Text() string

func (*InputBox) Update

func (i *InputBox) Update()

type OptionBox

type OptionBox struct {
	BaseUI
	Text string

	UIImage          *ebiten.Image
	ImageRect        image.Rectangle
	ImageRectPressed image.Rectangle
	ImageRectMark    image.Rectangle
	// contains filtered or unexported fields
}

func NewOptionBox

func NewOptionBox(x, y int, text string) *OptionBox

func (*OptionBox) Add2OptionBoxGroup

func (o *OptionBox) Add2OptionBoxGroup(g map[*OptionBox]struct{})

func (*OptionBox) Draw

func (o *OptionBox) Draw(dst *ebiten.Image)

func (*OptionBox) Select

func (o *OptionBox) Select()

func (*OptionBox) Selected

func (o *OptionBox) Selected() bool

func (*OptionBox) SetOnSelect

func (o *OptionBox) SetOnSelect(f func(c *OptionBox))

func (*OptionBox) Update

func (o *OptionBox) Update()

type Panel

type Panel struct {
	BaseUI
}

func NewPanel

func NewPanel(x, y, w, h int, bgColor color.Color) *Panel

type TextBox

type TextBox struct {
	BaseUI
	Text      string
	TextColor color.Color

	DisableVScroll bool
	DisableHScroll bool

	UIImage   *ebiten.Image
	ImageRect image.Rectangle
	// contains filtered or unexported fields
}

func NewTextBox

func NewTextBox(x, y, w, h int) *TextBox

func (*TextBox) AppendLine

func (t *TextBox) AppendLine(line string)

func (*TextBox) ContentSize

func (t *TextBox) ContentSize() (int, int)

func (*TextBox) Draw

func (t *TextBox) Draw(dst *ebiten.Image)

func (*TextBox) SetText

func (t *TextBox) SetText(v interface{})

func (*TextBox) Update

func (t *TextBox) Update()

type VScrollBar

type VScrollBar struct {
	BaseUI

	UIImage        *ebiten.Image
	ImageRectBack  image.Rectangle
	ImageRectFront image.Rectangle
	// contains filtered or unexported fields
}

VScrollBar 竖向ScrollBar

func NewVScrollBar

func NewVScrollBar() *VScrollBar

func (*VScrollBar) ContentOffset

func (v *VScrollBar) ContentOffset() int

func (*VScrollBar) Draw

func (v *VScrollBar) Draw(dst *ebiten.Image)

func (*VScrollBar) Update

func (v *VScrollBar) Update(wx, wy, contentHeight int)

Jump to

Keyboard shortcuts

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