widget

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnchorLayout

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

锚定布局

func NewAnchorLayout

func NewAnchorLayout(direction anchor.Direction) *AnchorLayout

创建锚点布局

func (*AnchorLayout) AppendChild

func (p *AnchorLayout) AppendChild(child WidgetInterface) *AnchorLayout

设置子节点

func (*AnchorLayout) Destroy

func (p *AnchorLayout) Destroy()

删除自身

func (*AnchorLayout) Direction

func (p *AnchorLayout) Direction(direc anchor.Direction) *AnchorLayout

设置锚定方向

func (*AnchorLayout) GetChild

func (p *AnchorLayout) GetChild() WidgetInterface

获取子节点

func (*AnchorLayout) Layout

func (p *AnchorLayout) Layout(gtx glayout.Context) (dimensions glayout.Dimensions)

渲染

func (*AnchorLayout) Margin

func (p *AnchorLayout) Margin(Top, Left, Bottom, Right float32) *AnchorLayout

设置外边距

func (*AnchorLayout) OnDestroy

func (p *AnchorLayout) OnDestroy(fn func())

注册删除事件

func (*AnchorLayout) RemoveChild

func (p *AnchorLayout) RemoveChild() *AnchorLayout

删除子节点

func (*AnchorLayout) ResetParent

func (p *AnchorLayout) ResetParent(child WidgetInterface)

重新设置父节点

func (*AnchorLayout) Then

func (p *AnchorLayout) Then(fn func(self *AnchorLayout)) *AnchorLayout

绑定函数

func (*AnchorLayout) Update

func (p *AnchorLayout) Update(update bool)

是否更新组件

type Border

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

func NewBorder

func NewBorder(widget WidgetInterface) *Border

创建一个边框

func (*Border) AppendChild

func (p *Border) AppendChild(child WidgetInterface) *Border

设置子节点

func (*Border) Color

func (p *Border) Color(r, g, b, a uint8) *Border

设置边框颜色

func (*Border) CornerRadius

func (p *Border) CornerRadius(radius float32) *Border

设置边框圆角

func (*Border) Destroy

func (p *Border) Destroy()

注销自身,清理所有引用

func (*Border) GetChild

func (p *Border) GetChild() WidgetInterface

获取子节点

func (*Border) Layout

func (p *Border) Layout(gtx glayout.Context) glayout.Dimensions

渲染UI

func (*Border) Margin

func (p *Border) Margin(Top, Left, Bottom, Right float32) *Border

设置外边距

func (*Border) OnDestroy

func (p *Border) OnDestroy(fn func())

注册删除事件

func (*Border) Padding

func (p *Border) Padding(Top, Left, Bottom, Right float32) *Border

设置内边距

func (*Border) RemoveChild

func (p *Border) RemoveChild() *Border

删除子节点

func (*Border) ResetParent

func (p *Border) ResetParent(child WidgetInterface)

重新设置父节点

func (*Border) Then

func (p *Border) Then(fn func(self *Border)) *Border

绑定函数

func (*Border) Update

func (p *Border) Update(update bool)

是否更新组件

func (*Border) Width

func (p *Border) Width(width float32) *Border

设置边框宽度

type Button

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

func NewButton

func NewButton(text string) *Button

创建按钮

func (*Button) Background

func (p *Button) Background(r, g, b, a uint8) *Button

设置背景颜色

func (*Button) Click

func (p *Button) Click() *Button

模拟点击

func (*Button) CornerRadius

func (p *Button) CornerRadius(radius float32) *Button

设置圆角

func (*Button) Destroy

func (p *Button) Destroy()

删除组件

func (*Button) Focus

func (p *Button) Focus() *Button

设置焦点为按钮

func (*Button) FontColor

func (p *Button) FontColor(r, g, b, a uint8) *Button

设置文字颜色

func (*Button) FontSize

func (p *Button) FontSize(size int) *Button

设置字体大小

func (*Button) Layout

func (p *Button) Layout(gtx glayout.Context) glayout.Dimensions

布局

func (*Button) Margin

func (p *Button) Margin(top, left, bottom, right float32) *Button

设置外边距

func (*Button) OnClicked

func (p *Button) OnClicked(fn func(p *Button)) *Button

点击事件

func (*Button) OnDestroy

func (p *Button) OnDestroy(fn func())

注册删除事件

func (*Button) OnFocused

func (p *Button) OnFocused(fn func(p *Button, focus bool)) *Button

获取焦点状态

func (*Button) OnHovered

func (p *Button) OnHovered(fn func(p *Button, hover bool)) *Button

鼠标悬浮事件

func (*Button) OnLongClicked

func (p *Button) OnLongClicked(fn func(p *Button)) *Button

多次点击事件

func (*Button) OnPressed

func (p *Button) OnPressed(fn func(p *Button)) *Button

鼠标按下事件

func (*Button) Padding

func (p *Button) Padding(top, left, bottom, right float32) *Button

设置内边距

func (*Button) Text

func (p *Button) Text(text string) *Button

设置文本

func (*Button) Then

func (p *Button) Then(fn func(self *Button)) *Button

绑定函数

func (*Button) Update

func (p *Button) Update(update bool)

是否更新组件

type CheckBox

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

复选框

func NewCheckBox

func NewCheckBox(text string) *CheckBox

创建复选框

func (*CheckBox) CheckMarkColor

func (p *CheckBox) CheckMarkColor(r, g, b, a uint8) *CheckBox

设置勾选框左边标记的颜色

func (*CheckBox) Checked

func (p *CheckBox) Checked(checked bool) *CheckBox

设置是否勾选

func (*CheckBox) Destroy

func (p *CheckBox) Destroy()

注销自身,清理所有引用

func (*CheckBox) FontColor

func (p *CheckBox) FontColor(r, g, b, a uint8) *CheckBox

设置文字颜色

func (*CheckBox) GetChecked

func (p *CheckBox) GetChecked() bool

获取是否勾选

func (*CheckBox) Layout

func (p *CheckBox) Layout(gtx glayout.Context) glayout.Dimensions

重新设置父节点

func (*CheckBox) Margin

func (p *CheckBox) Margin(Top, Left, Bottom, Right float32) *CheckBox

外边距

func (*CheckBox) OnChecked

func (p *CheckBox) OnChecked(fn func(p *CheckBox, check bool)) *CheckBox

选择事件

func (*CheckBox) OnDestroy

func (p *CheckBox) OnDestroy(fn func())

注册删除事件

func (*CheckBox) OnFocused

func (p *CheckBox) OnFocused(fn func(p *CheckBox, focus bool, value bool)) *CheckBox

焦点事件

func (*CheckBox) OnHovered

func (p *CheckBox) OnHovered(fn func(p *CheckBox, hover bool, check bool)) *CheckBox

鼠标悬浮事件

func (*CheckBox) Size

func (p *CheckBox) Size(size float32) *CheckBox

设置尺寸

func (*CheckBox) Text

func (p *CheckBox) Text(text string) *CheckBox

设置文字

func (*CheckBox) Then

func (p *CheckBox) Then(fn func(self *CheckBox)) *CheckBox

绑定函数

func (*CheckBox) Update

func (p *CheckBox) Update(update bool)

是否更新组件

type ColumnLayout

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

func NewColumnLayout

func NewColumnLayout() *ColumnLayout

创建一个垂直布局

func (*ColumnLayout) AppendFlexAnchorChild

func (p *ColumnLayout) AppendFlexAnchorChild(weight float32, direction anchor.Direction, child WidgetInterface) *ColumnLayout

添加子节点,可以根据方向进行布局堆叠

func (*ColumnLayout) AppendFlexChild

func (p *ColumnLayout) AppendFlexChild(weight float32, child WidgetInterface) *ColumnLayout

添加子节点,并且可以定义权重

func (*ColumnLayout) AppendRigidChild

func (p *ColumnLayout) AppendRigidChild(child WidgetInterface) *ColumnLayout

添加子节点,组件得到基于子组件的固定空间

func (*ColumnLayout) Destroy

func (p *ColumnLayout) Destroy()

注销自身,清理所有引用

func (*ColumnLayout) GetChildAll

func (p *ColumnLayout) GetChildAll() []WidgetInterface

获取所有子节点

func (*ColumnLayout) GetChildAt

func (p *ColumnLayout) GetChildAt(index int) WidgetInterface

获取指定索引的子节点

func (*ColumnLayout) GetChildCount

func (p *ColumnLayout) GetChildCount() int

获取子节点数量

func (*ColumnLayout) Layout

渲染UI

func (*ColumnLayout) Margin

func (p *ColumnLayout) Margin(Top, Left, Bottom, Right float32) *ColumnLayout

设置外边距

func (*ColumnLayout) OnDestroy

func (p *ColumnLayout) OnDestroy(fn func())

注册删除事件

func (*ColumnLayout) RemoveChild

func (p *ColumnLayout) RemoveChild(child WidgetInterface) *ColumnLayout

从组件删除子节点

func (*ColumnLayout) RemoveChildAll

func (p *ColumnLayout) RemoveChildAll() *ColumnLayout

删除所有子节点

func (*ColumnLayout) RemoveChildAt

func (p *ColumnLayout) RemoveChildAt(index int) *ColumnLayout

从指定索引删除子节点

func (*ColumnLayout) ResetParent

func (p *ColumnLayout) ResetParent(child WidgetInterface)

重新设置父节点

func (*ColumnLayout) Then

func (p *ColumnLayout) Then(fn func(self *ColumnLayout)) *ColumnLayout

绑定函数

func (*ColumnLayout) Update

func (p *ColumnLayout) Update(update bool)

是否更新组件

type ContainerLayout

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

容器布局,只用于包裹组件

func NewContainerLayout

func NewContainerLayout() *ContainerLayout

创建锚点布局

func (*ContainerLayout) AppendChild

func (p *ContainerLayout) AppendChild(child WidgetInterface) *ContainerLayout

设置子节点

func (*ContainerLayout) Background

func (p *ContainerLayout) Background(r, g, b, a uint8) *ContainerLayout

背景颜色

func (*ContainerLayout) Destroy

func (p *ContainerLayout) Destroy()

删除自身

func (*ContainerLayout) GetChild

func (p *ContainerLayout) GetChild() WidgetInterface

获取子节点

func (*ContainerLayout) Layout

func (p *ContainerLayout) Layout(gtx glayout.Context) (dimensions glayout.Dimensions)

渲染

func (*ContainerLayout) Margin

func (p *ContainerLayout) Margin(Top, Left, Bottom, Right float32) *ContainerLayout

设置外边距

func (*ContainerLayout) OnDestroy

func (p *ContainerLayout) OnDestroy(fn func())

注册删除事件

func (*ContainerLayout) RemoveChild

func (p *ContainerLayout) RemoveChild() *ContainerLayout

删除子节点

func (*ContainerLayout) ResetParent

func (p *ContainerLayout) ResetParent(child WidgetInterface)

重新设置父节点

func (*ContainerLayout) Then

func (p *ContainerLayout) Then(fn func(self *ContainerLayout)) *ContainerLayout

绑定函数

func (*ContainerLayout) Update

func (p *ContainerLayout) Update(update bool)

是否更新组件

type Editor

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

编辑框

func NewEditor

func NewEditor(hint string) *Editor

创建编辑框

func (*Editor) Alignment

func (p *Editor) Alignment(alignment text.Alignment) *Editor

文本对齐方向

func (*Editor) AllowOnly

func (p *Editor) AllowOnly(filter string) *Editor

仅允许输入指定字符

func (*Editor) CaretPos

func (p *Editor) CaretPos() (line, col int)

方法会返回光标所在的行和列的编号

func (*Editor) ClearSelection

func (p *Editor) ClearSelection() *Editor

清除选择区域,通过将选择区域的结束位置设定为开始位置

func (*Editor) Delete

func (p *Editor) Delete(count int) *Editor

方法会从光标位置删除字符。参数的符号指定删除的方向:正数表示向前删除,负数表示向后删除。

如果有选定的文字,那么会被删除,这会算作删除了一个字符串。

func (*Editor) Destroy

func (p *Editor) Destroy()

注销自身,清理所有引用

func (*Editor) Focus

func (p *Editor) Focus() *Editor

方法会请求为编辑器获取输入焦点

func (*Editor) FontSize

func (p *Editor) FontSize(textSize float32) *Editor

设置文本框字体大小

func (*Editor) GetSelectedText

func (p *Editor) GetSelectedText() string

获取光标位置的字符串

func (*Editor) GetSelection

func (p *Editor) GetSelection() (start, end int)

返回选择区域的开始和结束位置,开始的位置可以大于结束的位置

func (*Editor) GetSelectionLen

func (p *Editor) GetSelectionLen() int

返回选择区域的长度

func (*Editor) GetText

func (p *Editor) GetText() string

获取文本框的文字

func (*Editor) GetTextLen

func (p *Editor) GetTextLen() int

获取文本框文本长度

func (*Editor) Hint

func (p *Editor) Hint(hint string) *Editor

设置提示文字

func (*Editor) HintColor

func (p *Editor) HintColor(r, g, b, a uint8) *Editor

设置提示文字颜色

func (*Editor) Insert

func (p *Editor) Insert(text string) *Editor

方法在选中处插入一段字符串

func (*Editor) KeyboardType

func (p *Editor) KeyboardType(keyboardType text.InputHint) *Editor

设置屏幕键盘类型

func (*Editor) Layout

func (p *Editor) Layout(gtx glayout.Context) glayout.Dimensions

渲染

func (*Editor) LineHeight

func (p *Editor) LineHeight(lineHeight float32) *Editor

设置文字行高

func (*Editor) LineHeightScale

func (p *Editor) LineHeightScale(lineHeightScale float32) *Editor

设置文字行高缩放

func (*Editor) Margin

func (p *Editor) Margin(Top, Left, Bottom, Right float32) *Editor

外边距

func (*Editor) Mask

func (p *Editor) Mask(mask rune) *Editor

设置文字掩盖符号,一般用于密码输入

func (*Editor) MaxLength

func (p *Editor) MaxLength(maxLines int) *Editor

设置最可输入长度

func (*Editor) MoveCaret

func (p *Editor) MoveCaret(startDelta, endDelta int) *Editor

方法移动光标(也就是选择开始)和选择结束,相对于它们当前的位置。正距离向前移动,负距离向后移动。距离是以字形簇为单位,即使字符由多个代码点组成,这也非常接近用户所认为的"字符"。

func (*Editor) OnChange

func (p *Editor) OnChange(fn func(p *Editor, text string)) *Editor

文本改变事件

func (*Editor) OnDestroy

func (p *Editor) OnDestroy(fn func())

注册删除事件

func (*Editor) OnFocused

func (p *Editor) OnFocused(fn func(p *Editor, focus bool, text string)) *Editor

方法返回编辑器是否处于焦点状态。

func (*Editor) OnSelect

func (p *Editor) OnSelect(fn func(p *Editor, text string)) *Editor

选择事件

func (*Editor) OnSubmit

func (p *Editor) OnSubmit(fn func(p *Editor, text string)) *Editor

提交事件

func (*Editor) ReadOnly

func (p *Editor) ReadOnly(readOnly bool) *Editor

设置只读

func (*Editor) SelectionColor

func (p *Editor) SelectionColor(r, g, b, a uint8) *Editor

设置文本框选中部分的背景颜色

func (*Editor) SetCaret

func (p *Editor) SetCaret(start, end int) *Editor

移动光标到 start 的位置,并将选择区域的结束位置设定到 end。start 和 end 是以字符计数的,代表在编辑器文本中的偏移量。

func (*Editor) SingleLine

func (p *Editor) SingleLine(singleLine bool) *Editor

设置单行编辑

func (*Editor) Submit

func (p *Editor) Submit(submit bool) *Editor

将回车键作为提交按钮,启用时文本框自动变为单行文本框

func (*Editor) Text

func (p *Editor) Text(text string) *Editor

设置文字

func (*Editor) TextColor

func (p *Editor) TextColor(r, g, b, a uint8) *Editor

设置文本框文本颜色

func (*Editor) TextWeight

func (p *Editor) TextWeight(textWeight text.Weight) *Editor

设置文本框字体粗细

func (*Editor) Then

func (p *Editor) Then(fn func(self *Editor)) *Editor

绑定函数

func (*Editor) Update

func (p *Editor) Update(update bool)

是否更新组件

func (*Editor) WrapPolicy

func (p *Editor) WrapPolicy(wrapPolicy text.WrapPolicy) *Editor

设置如何显示文本换行

type Label added in v0.0.2

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

func NewLabel added in v0.0.2

func NewLabel(text string) *Label

设置文本

func (*Label) Alignment added in v0.0.2

func (p *Label) Alignment(alignment text.Alignment) *Label

设置文本对齐方式

func (*Label) Destroy added in v0.0.2

func (p *Label) Destroy()

注销自身,清理所有引用

func (*Label) FontColor added in v0.0.2

func (p *Label) FontColor(r, g, b, a uint8) *Label

设置文字颜色

func (*Label) FontSize added in v0.0.2

func (p *Label) FontSize(size float32) *Label

设置文本大小

func (*Label) Layout added in v0.0.2

func (p *Label) Layout(gtx glayout.Context) glayout.Dimensions

布局

func (*Label) LineHeight added in v0.0.2

func (p *Label) LineHeight(lineHeight float32) *Label

设置文本行高

func (*Label) LineHeightScale added in v0.0.2

func (p *Label) LineHeightScale(lineHeightScale float32) *Label

设置文本行高缩放

func (*Label) Margin added in v0.0.2

func (p *Label) Margin(Top, Left, Bottom, Right float32) *Label

外边距

func (*Label) MaxLines added in v0.0.2

func (p *Label) MaxLines(maxLines int) *Label

设置文本最大行

func (*Label) OnDestroy added in v0.0.2

func (p *Label) OnDestroy(fn func())

注册删除事件

func (*Label) Text added in v0.0.2

func (p *Label) Text(text string) *Label

设置文本内容

func (*Label) Then added in v0.0.2

func (p *Label) Then(fn func(self *Label)) *Label

绑定函数

func (*Label) Truncator added in v0.0.2

func (p *Label) Truncator(truncator string) *Label

设置文本超出最大行显示的文本

func (*Label) Update added in v0.0.2

func (p *Label) Update(update bool)

是否更新组件

func (*Label) WrapPolicy added in v0.0.2

func (p *Label) WrapPolicy(wrapPolicy text.WrapPolicy) *Label

设置如何显示文本换行

type ListLayout

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

列表布局

func NewListLayout

func NewListLayout(axis axis.Axis) *ListLayout

创建一个指定方向的列表布局

func (*ListLayout) AppendChild

func (p *ListLayout) AppendChild(child WidgetInterface) *ListLayout

添加子节点

func (*ListLayout) Axis

func (p *ListLayout) Axis(axis axis.Axis) *ListLayout

设置方向

func (*ListLayout) Destroy

func (p *ListLayout) Destroy()

删除组件

func (*ListLayout) GetChildAll

func (p *ListLayout) GetChildAll() []WidgetInterface

获取所有子节点

func (*ListLayout) GetChildAt

func (p *ListLayout) GetChildAt(index int) WidgetInterface

获取指定索引的子节点

func (*ListLayout) GetChildCount

func (p *ListLayout) GetChildCount() int

获取子节点数量

func (*ListLayout) Layout

func (p *ListLayout) Layout(gtx glayout.Context) glayout.Dimensions

渲染UI

func (*ListLayout) Margin

func (p *ListLayout) Margin(Top, Left, Bottom, Right float32) *ListLayout

设置外边距

func (*ListLayout) OnDestroy

func (p *ListLayout) OnDestroy(fn func())

注册删除事件

func (*ListLayout) RemoveChild

func (p *ListLayout) RemoveChild(child WidgetInterface) *ListLayout

从组件中删除子节点

func (*ListLayout) RemoveChildAll

func (p *ListLayout) RemoveChildAll() *ListLayout

删除所有子节点

func (*ListLayout) RemoveChildAt

func (p *ListLayout) RemoveChildAt(index int) *ListLayout

从指定索引删除子节点

func (*ListLayout) ResetParent

func (p *ListLayout) ResetParent(child WidgetInterface)

重新设置父节点

func (*ListLayout) ScrollBgColor

func (p *ListLayout) ScrollBgColor(r, g, b, a uint8) *ListLayout

滚动条背景颜色

func (*ListLayout) ScrollBy

func (p *ListLayout) ScrollBy(offset float32) *ListLayout

滚动到列表的指定位置

func (*ListLayout) ScrollColor

func (p *ListLayout) ScrollColor(r, g, b, a uint8) *ListLayout

滚动条鼠标默认颜色

func (*ListLayout) ScrollCornerRadius

func (p *ListLayout) ScrollCornerRadius(radius float32) *ListLayout

滚动条的圆角

func (*ListLayout) ScrollHoverColor

func (p *ListLayout) ScrollHoverColor(r, g, b, a uint8) *ListLayout

滚动条鼠标悬浮颜色

func (*ListLayout) ScrollMinLen

func (p *ListLayout) ScrollMinLen(minLen float32) *ListLayout

滚动条最小长度

func (*ListLayout) ScrollPadding

func (p *ListLayout) ScrollPadding(width, height float32) *ListLayout

滚动条的间距宽高

func (*ListLayout) ScrollPaddingEnable

func (p *ListLayout) ScrollPaddingEnable(enable bool) *ListLayout

是否启用滚动条间距,如果禁用,滚动条会覆着在列表上

func (*ListLayout) ScrollToEnd

func (p *ListLayout) ScrollToEnd(scrollToEnd bool) *ListLayout

当设置为true,会让列表在更新item后保持滚动到最后更新位置

func (*ListLayout) ScrollToItem

func (p *ListLayout) ScrollToItem(index int) *ListLayout

滚动到列表中存在的指定项的位置

func (*ListLayout) ScrollWidth

func (p *ListLayout) ScrollWidth(width float32) *ListLayout

滚动条的宽度

func (*ListLayout) Then

func (p *ListLayout) Then(fn func(self *ListLayout)) *ListLayout

绑定函数

func (*ListLayout) Update

func (p *ListLayout) Update(update bool)

是否更新组件

type MultiChildLayoutInterface

type MultiChildLayoutInterface[T any] interface {
	WidgetInterface
	// 重新设置父节点
	ResetParent(child WidgetInterface)
	// 外边距
	Margin(Top, Left, Bottom, Right float32) T
	// 从指定索引删除子节点
	RemoveChildAt(index int) T
	// 从组件删除子节点
	RemoveChild(child WidgetInterface) T
	// 删除所有子节点
	RemoveChildAll() T
	// 获取子节点
	GetChildAll() []WidgetInterface
	// 获取指定索引的子节点
	GetChildAt(index int) WidgetInterface
	// 获取子节点数量
	GetChildCount() int
}

多子节点布局接口

type RadioButtons

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

复选框

func NewRadioButtons

func NewRadioButtons(axis axis.Axis) *RadioButtons

创建一个指定方向的复选框

func (*RadioButtons) AppendRadioButton

func (p *RadioButtons) AppendRadioButton(key, text string) *RadioButtons

添加子节点

func (*RadioButtons) Axis

func (p *RadioButtons) Axis(axis axis.Axis) *RadioButtons

设置方向

func (*RadioButtons) Destroy

func (p *RadioButtons) Destroy()

注销自身,清理所有引用

func (*RadioButtons) FontColor

func (p *RadioButtons) FontColor(r, g, b, a uint8) *RadioButtons

设置文字颜色

func (*RadioButtons) Layout

重新设置父节点

func (*RadioButtons) Margin

func (p *RadioButtons) Margin(Top, Left, Bottom, Right float32) *RadioButtons

外边距

func (*RadioButtons) OnDestroy

func (p *RadioButtons) OnDestroy(fn func())

注册删除事件

func (*RadioButtons) OnFocused

func (p *RadioButtons) OnFocused(fn func(p *RadioButtons, key string)) *RadioButtons

焦点事件

func (*RadioButtons) OnHovered

func (p *RadioButtons) OnHovered(fn func(p *RadioButtons, key string)) *RadioButtons

鼠标悬浮事件

func (*RadioButtons) OnSelected

func (p *RadioButtons) OnSelected(fn func(p *RadioButtons, key string)) *RadioButtons

选择事件

func (*RadioButtons) RadioMarkColor

func (p *RadioButtons) RadioMarkColor(r, g, b, a uint8) *RadioButtons

设置单选框左边标记的颜色

func (*RadioButtons) Size

func (p *RadioButtons) Size(size float32) *RadioButtons

设置字体大小

func (*RadioButtons) Then

func (p *RadioButtons) Then(fn func(self *RadioButtons)) *RadioButtons

绑定函数

func (*RadioButtons) Update

func (p *RadioButtons) Update(update bool)

是否更新组件

type RowLayout

type RowLayout struct {
	HorizontalWidget *glayout.Flex
	// contains filtered or unexported fields
}

func NewRowLayout

func NewRowLayout() *RowLayout

创建一个水平布局

func (*RowLayout) AppendFlexAnchorChild

func (p *RowLayout) AppendFlexAnchorChild(weight float32, direction anchor.Direction, child WidgetInterface) *RowLayout

添加子节点,可以根据方向进行布局堆叠

func (*RowLayout) AppendFlexChild

func (p *RowLayout) AppendFlexChild(weight float32, child WidgetInterface) *RowLayout

添加子节点,并且可以定义权重

func (*RowLayout) AppendRigidChild

func (p *RowLayout) AppendRigidChild(child WidgetInterface) *RowLayout

添加子节点,组件得到基于子组件的固定空间

func (*RowLayout) Destroy

func (p *RowLayout) Destroy()

注销自身,清理所有引用

func (*RowLayout) GetChildAll

func (p *RowLayout) GetChildAll() []WidgetInterface

获取所有子节点

func (*RowLayout) GetChildAt

func (p *RowLayout) GetChildAt(index int) WidgetInterface

获取指定索引的子节点

func (*RowLayout) GetChildCount

func (p *RowLayout) GetChildCount() int

获取子节点数量

func (*RowLayout) Layout

func (p *RowLayout) Layout(gtx glayout.Context) glayout.Dimensions

渲染UI

func (*RowLayout) Margin

func (p *RowLayout) Margin(Top, Left, Bottom, Right float32) *RowLayout

设置外边距

func (*RowLayout) OnDestroy

func (p *RowLayout) OnDestroy(fn func())

注册删除事件

func (*RowLayout) RemoveChild

func (p *RowLayout) RemoveChild(child WidgetInterface) *RowLayout

从组件删除子节点

func (*RowLayout) RemoveChildAll

func (p *RowLayout) RemoveChildAll() *RowLayout

删除所有子节点

func (*RowLayout) RemoveChildAt

func (p *RowLayout) RemoveChildAt(index int) *RowLayout

从指定索引删除子节点

func (*RowLayout) ResetParent

func (p *RowLayout) ResetParent(child WidgetInterface)

重新设置父节点

func (*RowLayout) Then

func (p *RowLayout) Then(fn func(self *RowLayout)) *RowLayout

绑定函数

func (*RowLayout) Update

func (p *RowLayout) Update(update bool)

是否可见

type SingleChildLayoutInterface

type SingleChildLayoutInterface[T any] interface {
	WidgetInterface
	// 重新设置父节点
	ResetParent(child WidgetInterface)
	// 外边距
	Margin(Top, Left, Bottom, Right float32) T
	// 设置子节点
	AppendChild(childs WidgetInterface) T
	// 获取子节点
	GetChild() WidgetInterface
	// 删除子节点
	RemoveChild() T
}

单子节点布局接口

type Slider added in v0.0.7

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

func NewSlider added in v0.0.7

func NewSlider(axis axis.Axis) *Slider

创建滑块组件,值为0-1

func (*Slider) Color added in v0.0.7

func (p *Slider) Color(r, g, b, a uint8) *Slider

滑块的颜色

func (*Slider) Destroy added in v0.0.7

func (p *Slider) Destroy()

注销自身,清理所有引用

func (*Slider) FingerSize added in v0.0.7

func (p *Slider) FingerSize(size float32) *Slider

滑块可点击的范围

func (*Slider) GetValue added in v0.0.7

func (p *Slider) GetValue() float32

获取滑块的值

func (*Slider) Layout added in v0.0.7

func (p *Slider) Layout(gtx glayout.Context) glayout.Dimensions

渲染组件

func (*Slider) Margin added in v0.0.7

func (p *Slider) Margin(Top, Left, Bottom, Right float32) *Slider

外边距

func (*Slider) OnDestroy added in v0.0.7

func (p *Slider) OnDestroy(fn func())

注册删除事件

func (*Slider) OnDragging added in v0.0.7

func (p *Slider) OnDragging(fn func(p *Slider, value float32)) *Slider

注册拖动事件

func (*Slider) Then added in v0.0.7

func (p *Slider) Then(fn func(self *Slider)) *Slider

绑定函数

func (*Slider) Update added in v0.0.7

func (p *Slider) Update(update bool)

是否更新组件

type Switch added in v0.0.2

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

func NewSwitch added in v0.0.2

func NewSwitch() *Switch

func (*Switch) Destroy added in v0.0.2

func (p *Switch) Destroy()

注销自身,清理所有引用

func (*Switch) DisabledColor added in v0.0.2

func (p *Switch) DisabledColor(r, g, b, a uint8) *Switch

禁用颜色

func (*Switch) Enabled added in v0.0.2

func (p *Switch) Enabled(value bool) *Switch

启用开关

func (*Switch) EnabledColor added in v0.0.2

func (p *Switch) EnabledColor(r, g, b, a uint8) *Switch

启用颜色

func (*Switch) Layout added in v0.0.2

func (p *Switch) Layout(gtx glayout.Context) glayout.Dimensions

布局

func (*Switch) Margin added in v0.0.2

func (p *Switch) Margin(Top, Left, Bottom, Right float32) *Switch

外边距

func (*Switch) OnChange added in v0.0.2

func (p *Switch) OnChange(fn func(p *Switch, value bool)) *Switch

选择事件

func (*Switch) OnDestroy added in v0.0.2

func (p *Switch) OnDestroy(fn func())

注册删除事件

func (*Switch) Then added in v0.0.2

func (p *Switch) Then(fn func(self *Switch)) *Switch

绑定函数

func (*Switch) TrackColor added in v0.0.2

func (p *Switch) TrackColor(r, g, b, a uint8) *Switch

轨道颜色

func (*Switch) Update added in v0.0.2

func (p *Switch) Update(update bool)

是否更新组件

type WidgetInterface

type WidgetInterface interface {
	// 渲染UI
	Layout(gtx glayout.Context) glayout.Dimensions
	//  删除函数注册
	OnDestroy(fn func())
	// 删除组件
	Destroy()

	// 是否更新组件
	Update(update bool)
}

定义一个通用的布局接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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