Documentation
¶
Overview ¶
Package std provides a collection of standard components that can be used with the ui framework.
Index ¶
- Variables
- type AccordionCallbackData
- type AccordionData
- type BaseButtonComponent
- type ButtonCallbackData
- type ButtonData
- type ButtonState
- type ContainerData
- type DropZoneCallbackData
- type DropdownCallbackData
- type DropdownData
- type DropdownItem
- type EditboxCallbackData
- type EditboxData
- type ElementData
- type ImageMode
- type LabelData
- type ListItemCallbackData
- type ListItemData
- type OnActionFunc
- type PaperData
- type PictureData
- type ScrollPaneData
- type SpacingData
- type SwitchData
- type TabbarTabCallbackData
- type TabbarTabData
- type ToolbarButtonCallbackData
- type ToolbarButtonData
- type ToolbarData
- type ToolbarPositioning
- type ViewportCallbackData
- type ViewportData
- type ViewportMouseEvent
Constants ¶
This section is empty.
Variables ¶
var ( AccordionHeaderPadding = 2 AccordionHeaderContentSpacing = 5 AccordionHeaderIconSize = 24 AccordionHeaderFontSize = float32(20) AccordionHeaderFontFile = "ui:///roboto-regular.ttf" AccordionExpandedIconFile = "ui:///expanded.png" AccordionCollapsedIconFile = "ui:///collapsed.png" )
var ( ButtonSidePadding = 6 ButtonContentSpacing = 5 ButtonIconSize = 24 ButtonHeight = 28 ButtonFontFile = "ui:///roboto-regular.ttf" ButtonFontSize = float32(18) )
var ( DropdownFontSize = float32(18) DropdownFontFile = "ui:///roboto-regular.ttf" DropdownIconSize = 24 DropdownIconFile = "ui:///expanded.png" )
var ( DropdownItemIndicatorSize = 20 DropdownItemIndicatorPadding = 5 )
var ( DropdownListFontSize = float32(18) DropdownListFontFile = "ui:///roboto-regular.ttf" )
var ( EditboxMinWidth = 100 EditboxHeight = 28 EditboxFontFile = "ui:///roboto-regular.ttf" EditboxFontSize = float32(18) )
var ( LabelFontFile = "ui:///roboto-regular.ttf" LabelFontSize = float32(24.0) )
var ( PaperPadding = 5 PaperBorderSize = float32(1.0) PaperRoundness = float32(10.0) )
var ( TabbarHeight = 40 TabbarItemSpacing = 2 TabbarSidePadding = 5 )
var ( TabbarTabHeight = TabbarHeight TabbarTabTopPadding = 5 TabbarTabSidePadding = 10 TabbarTabContentSpacing = 5 TabbarTabIconSize = 24 TabbarTabFontFile = "ui:///roboto-regular.ttf" TabbarTabFontSize = float32(20) TabbarTabCloseIconFile = "ui:///close.png" TabbarTabRadius = float32(15) )
var ( PrimaryColor ui.Color = ui.RGB(0x40, 0x89, 0xBD) OnPrimaryColor ui.Color = ui.RGB(0x00, 0x00, 0x00) PrimaryLightColor ui.Color = ui.RGB(0x7C, 0xAE, 0xEB) OnPrimaryLightColor ui.Color = ui.RGB(0x00, 0x00, 0x00) PrimaryDarkColor ui.Color = ui.RGB(0x32, 0x59, 0x73) OnPrimaryDarkColor ui.Color = ui.RGB(0xFF, 0xFF, 0xFF) SecondaryColor ui.Color = ui.RGB(0x8B, 0xC3, 0x4A) OnSecondaryColor ui.Color = ui.RGB(0x00, 0x00, 0x00) SecondaryLightColor ui.Color = ui.RGB(0xA9, 0xC2, 0x8A) OnSecondaryLightColor ui.Color = ui.RGB(0x00, 0x00, 0x00) SecondaryDarkColor ui.Color = ui.RGB(0x4B, 0x6B, 0x3A) OnSecondaryDarkColor ui.Color = ui.RGB(0xFF, 0xFF, 0xFF) BackgroundColor ui.Color = ui.RGB(0x3B, 0x3B, 0x3B) OnBackgroundColor ui.Color = ui.RGB(0xFF, 0xFF, 0xFF) SurfaceColor ui.Color = ui.RGB(0xFF, 0xFF, 0xFF) OnSurfaceColor ui.Color = ui.RGB(0x00, 0x00, 0x00) ErrorColor ui.Color = ui.RGB(0xB3, 0x1E, 0x00) OnErrorColor ui.Color = ui.RGB(0xFF, 0xFF, 0xFF) OutlineColor ui.Color = ui.RGB(0xB0, 0xB0, 0xB0) HoverOverlayColor ui.Color = ui.RGBA(0x00, 0x00, 0x00, 0x40) PressOverlayColor ui.Color = ui.RGBA(0x00, 0x00, 0x00, 0x80) ModalOverlayColor ui.Color = ui.RGBA(0x00, 0x00, 0x00, 0xA0) )
var ( ToolbarHeight = 64 ToolbarBorderSize = 1 ToolbarSidePadding = 5 ToolbarItemSpacing = 10 ToolbarItemHeight = ToolbarHeight - 2*ToolbarBorderSize )
var ( ToolbarButtonSidePadding = 4 ToolbarButtonContentSpacing = 5 ToolbarButtonIconSize = 24 ToolbarButtonFontFile = "ui:///roboto-regular.ttf" ToolbarButtonFontSize = float32(20) ToolbarBottonSelectionHeight = float32(5.0) )
var ( ToolbarSeparatorWidth = 3 ToolbarSeparatorLineSize = float32(1.0) ToolbarSeparatorLineLengthRatio = float32(0.7) )
var ( ViewportInitialFBWidth = 400 ViewportInitialFBHeight = 300 )
var Accordion = co.Define(&accordionComponent{})
var Button = co.Define(&buttonComponent{})
Button is a component that allows a user click on it to activate a process.
var Container = co.Define(&containerComponent{})
Container represents a component that holds other components and has some sort of visual boundary.
var DropZone = co.Define(&dropZoneComponent{})
DropZone is a transparent component that handles file drop events.
It is intended to be used as a container for a different component that provides a visual aid (e.g. an upload icon or some type of viewport).
var Dropdown = co.Define(&dropdownComponent{})
var Editbox = co.Define(&editboxComponent{})
Editbox is a component that allows a user to input a string.
var Element = co.Element
Element represents the most basic component, which is translated to a UI Element. All higher-order components eventually boil down to an Element.
var Label = co.Define(&labelComponent{})
Label represents a component that visualizes a text string.
var List = co.Define(&listComponent{})
List represents a container that holds a sequence of ListItem components in a vertical orientation.
var ListItem = co.Define(&listItemComponent{})
ListItem represents a component to be displayed in a List.
var (
ListItemPadding = 2
)
var (
ListItemSpacing = 2
)
var Modal = co.Define(&modalComponent{})
var Paper = co.Define(&paperComponent{})
Paper represents an outlined container.
var Picture = co.Define(&pictureComponent{})
var ScrollPane = co.Define(&scrollPaneComponent{})
ScrollPane is a container component that provides scrolling functionality in order to accommodate all children.
var Spacing = co.Define(&spacingComponent{})
Spacing represents an invisible component that requests that a specific amount of visual space be reserved for it.
var Switch = co.Define(&switchComponent{})
Switch is a container that can switch between different views depending on the specified SwitchData.
var Tabbar = co.Define(&tabbarComponent{})
var TabbarTab = co.Define(&tabbarTabComponent{})
var Toolbar = co.Define(&toolbarComponent{})
Toolbar represents a container that holds key controls (mostly buttons) in a horizontal fashion.
var ToolbarButton = co.Define(&toolbarButtonComponent{})
var ToolbarSeparator = co.Define(&toolbarSeparatorComponent{})
var Viewport = co.Define(&viewportComponent{})
Viewport represents a component that uses low-level API calls to render an external scene, unlike other components that rely on the Canvas API.
Functions ¶
This section is empty.
Types ¶
type AccordionCallbackData ¶
type AccordionCallbackData struct {
OnToggle OnActionFunc
}
AccordionCallbackData holds the callback data for an Accordion container.
type AccordionData ¶
AccordionData holds the data for an Accordion container.
type BaseButtonComponent ¶
type BaseButtonComponent struct {
// contains filtered or unexported fields
}
BaseButtonComponent provides a basic mouse event handling for a button component.
Users are expected to compose this structure into a component implementation that can do the actual rendering.
func (*BaseButtonComponent) OnClickFunc ¶
func (c *BaseButtonComponent) OnClickFunc() OnActionFunc
func (*BaseButtonComponent) OnMouseEvent ¶
func (c *BaseButtonComponent) OnMouseEvent(element *ui.Element, event ui.MouseEvent) bool
func (*BaseButtonComponent) SetOnClickFunc ¶
func (c *BaseButtonComponent) SetOnClickFunc(onAction OnActionFunc)
func (*BaseButtonComponent) State ¶
func (c *BaseButtonComponent) State() ButtonState
type ButtonCallbackData ¶
type ButtonCallbackData struct {
OnClick OnActionFunc
}
ButtonCallbackData holds the callback data for the Button component.
type ButtonData ¶
ButtonData holds the data for the Button component.
type ButtonState ¶
type ButtonState int
ButtonState indicates the state of a Button control.
const ( // ButtonStateUp indicates that the button is in its default state. ButtonStateUp ButtonState = iota // ButtonStateOver indicates that the cursor is over the button. ButtonStateOver // ButtonStateDown indicates that the cursor is pressing on the button. ButtonStateDown )
type ContainerData ¶
type ContainerData struct {
BackgroundColor opt.T[ui.Color]
BorderColor opt.T[ui.Color]
BorderSize ui.Spacing
Padding ui.Spacing
Layout ui.Layout
}
ContainerData holds the data for a Container component.
type DropZoneCallbackData ¶
DropZoneCallbackData can be used to specify callback data for a DropZone component.
type DropdownCallbackData ¶
type DropdownCallbackData struct {
OnItemSelected func(key any)
}
DropdownCallbackData holds the callback data for a Dropdown container.
type DropdownData ¶
type DropdownData struct {
Items []DropdownItem
SelectedKey any
}
DropdownData holds the data for a Dropdown container.
type DropdownItem ¶
DropdownItem represents a single dropdown entry.
type EditboxCallbackData ¶
type EditboxCallbackData struct {
// OnChanged is called when a new string is confirmed by the user.
OnChanged func(text string)
}
EditboxCallbackData holds the callback data for the Editbox component.
type EditboxData ¶
type EditboxData struct {
// Text specifies the committed text in the Editbox.
Text string
}
EditboxData holds the data for the Editbox component.
type ElementData ¶
type ElementData = co.ElementData
ElementData is the struct that should be used when configuring an Element component's data.
type ImageMode ¶
type ImageMode int
ImageMode determines how an image is displayed within a Picture control.
const ( // ImageModeStretch will stretch the image to cover the // available draw area in the control. ImageModeStretch ImageMode = iota // ImageModeFit will preserve the aspect ratio of the image // and will scale it up or down so that the image takes as // much space of the draw area as possible, without exiting // the bounds of the area. ImageModeFit // ImageModeCover will preserve the aspect ratio of the image // while also ensuring it covers the entire draw area. This // usually means that part of the image will be outside the // bounds of the control and will not be visible. ImageModeCover )
type LabelData ¶
type LabelData struct {
Font *ui.Font
FontSize opt.T[float32]
FontColor opt.T[ui.Color]
Text string
}
LabelData holds the data for the Label component.
type ListItemCallbackData ¶
type ListItemCallbackData struct {
OnSelected OnActionFunc
}
ListItemCallbackData holds the callback data for a ListItem component.
type ListItemData ¶
type ListItemData struct {
Selected bool
}
ListItemData holds the data for a ListItem component.
type OnActionFunc ¶
type OnActionFunc func()
OnActionFunc can be used to get notifications about action (click) events.
type PictureData ¶
type PictureData struct {
// BackgroundColor specifies the color to be rendered behind the image.
BackgroundColor opt.T[ui.Color]
// Image specifies the Image to be displayed.
Image *ui.Image
// ImageColor specifies an optional multiplier color.
ImageColor opt.T[ui.Color]
// Mode specifies how the image will be scaled and visualized within the
// Picture component.
Mode ImageMode
}
PictureData represents the available data properties for the Picture component.
type ScrollPaneData ¶
type ScrollPaneData struct {
// DisableHorizontal stops the pane from scrolling horizontally.
DisableHorizontal bool
// DisableVertical stops the pane from scrolling vertically.
DisableVertical bool
// Focused specifies whether this scroll pane should automatically get
// the focus.
Focused bool
}
ScrollPaneData holds the available configuration options for the ScrollPane component.
type SpacingData ¶
SpacingData holds the configuration data for a Spacing component.
type SwitchData ¶
type SwitchData struct {
// ChildKey holds the key of the child component to be rendered.
// If this does not match any child then nothing is rendered.
ChildKey string
}
SwitchData holds the data for a Switch component.
type TabbarTabCallbackData ¶
type TabbarTabCallbackData struct {
OnClick OnActionFunc
OnClose OnActionFunc
}
TabbarTabCallbackData holds the callback data for a TabbarTab component.
type TabbarTabData ¶
TabbarTabData holds the data for a TabbarTab component.
type ToolbarButtonCallbackData ¶
type ToolbarButtonCallbackData struct {
OnClick OnActionFunc
}
ToolbarButtonCallbackData holds the callback handlers for a ToolbarButton component.
type ToolbarButtonData ¶
ToolbarButtonData holds the data for a ToolbarButton component.
type ToolbarData ¶
type ToolbarData struct {
Positioning ToolbarPositioning
}
ToolbarData can be used to specify configuration for the Toolbar component.
type ToolbarPositioning ¶
type ToolbarPositioning int
ToolbarPositioning determines the visual appearance of the toolbar, depending on where it is intended to be placed on the screen.
const ( ToolbarPositioningTop ToolbarPositioning = iota ToolbarPositioningMiddle ToolbarPositioningBottom )
type ViewportCallbackData ¶
type ViewportCallbackData struct {
OnKeyboardEvent func(event ui.KeyboardEvent) bool
OnMouseEvent func(event ViewportMouseEvent) bool
OnRender func(framebuffer render.Framebuffer, size ui.Size)
}
ViewportCallbackData holds the callback data for a Viewport component.
type ViewportData ¶
ViewportData holds the data for a Viewport component.
type ViewportMouseEvent ¶
type ViewportMouseEvent struct {
ui.MouseEvent
X float32
Y float32
}
ViewportMouseEvent is a wrapper on top of ui.MouseEvent which includes X and Y coordinates that are in the [0..1] range, making them size agnostic.