std

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package std provides a collection of standard components that can be used with the ui framework.

Index

Constants

View Source
const (
	CheckboxContentSpacing    = 5
	CheckboxIconSize          = 24
	CheckboxFontSize          = float32(20)
	CheckboxFontFile          = "ui:///roboto-regular.ttf"
	CheckboxCheckedIconFile   = "ui:///checked.png"
	CheckboxUncheckedIconFile = "ui:///unchecked.png"
)

Variables

View Source
var (
	AccordionHeaderPadding        = 2
	AccordionHeaderContentSpacing = 5
	AccordionHeaderIconSize       = 24
	AccordionHeaderFontSize       = float32(20)
	AccordionHeaderFontFile       = "ui:///roboto-regular.ttf"
	AccordionExpandedIconFile     = "ui:///expanded.png"
	AccordionCollapsedIconFile    = "ui:///collapsed.png"
)
View Source
var (
	ButtonSidePadding    = 6
	ButtonContentSpacing = 5
	ButtonIconSize       = 24
	ButtonHeight         = 28
	ButtonFontFile       = "ui:///roboto-regular.ttf"
	ButtonFontSize       = float32(18)
)
View Source
var (
	DropdownFontSize = float32(18)
	DropdownFontFile = "ui:///roboto-regular.ttf"
	DropdownIconSize = 24
	DropdownIconFile = "ui:///expanded.png"
)
View Source
var (
	DropdownItemIndicatorSize    = 20
	DropdownItemIndicatorPadding = 5
)
View Source
var (
	DropdownListFontSize = float32(18)
	DropdownListFontFile = "ui:///roboto-regular.ttf"
)
View Source
var (
	LabelFontFile = "ui:///roboto-regular.ttf"
	LabelFontSize = float32(24.0)
)
View Source
var (
	PaperPadding    = 5
	PaperBorderSize = float32(1.0)
	PaperRoundness  = float32(10.0)
)
View Source
var (
	TabbarHeight      = 40
	TabbarItemSpacing = 2
	TabbarSidePadding = 5
)
View Source
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)
)
View Source
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)
)
View Source
var (
	ToolbarHeight      = 48
	ToolbarBorderSize  = 1
	ToolbarSidePadding = 5
	ToolbarItemSpacing = 10
	ToolbarItemHeight  = ToolbarHeight - 2*ToolbarBorderSize
)
View Source
var (
	ToolbarButtonSidePadding     = 4
	ToolbarButtonContentSpacing  = 5
	ToolbarButtonIconSize        = 24
	ToolbarButtonFontFile        = "ui:///roboto-regular.ttf"
	ToolbarButtonFontSize        = float32(20)
	ToolbarBottonSelectionHeight = float32(5.0)
)
View Source
var (
	ToolbarLogoSidePadding     = 4
	ToolbarLogoContentSpacing  = 5
	ToolbarLogoIconSize        = 24
	ToolbarLogoFontFile        = "ui:///roboto-bold.ttf"
	ToolbarLogoFontSize        = float32(20)
	ToolbarLogoSelectionHeight = float32(5.0)
)
View Source
var (
	ToolbarSeparatorWidth           = 3
	ToolbarSeparatorLineSize        = float32(1.0)
	ToolbarSeparatorLineLengthRatio = float32(0.7)
)
View Source
var (
	ViewportInitialFBWidth  = 400
	ViewportInitialFBHeight = 300
)
View Source
var Accordion = co.Define(&accordionComponent{})
View Source
var Button = co.Define(&buttonComponent{})

Button is a component that allows a user click on it to activate a process.

View Source
var Checkbox = co.Define(&checkboxComponent{})
View Source
var CodeArea = co.Define(&codeAreaComponent{})
View Source
var Container = co.Define(&containerComponent{})

Container represents a component that holds other components and has some sort of visual boundary.

View Source
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).

View Source
var Dropdown = co.Define(&dropdownComponent{})
View Source
var EditBox = co.Define(&editboxComponent{})
View Source
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.

View Source
var Label = co.Define(&labelComponent{})

Label represents a component that visualizes a text string.

View Source
var List = co.Define(&listComponent{})

List represents a container that holds a sequence of ListItem components in a vertical orientation.

View Source
var ListItem = co.Define(&listItemComponent{})

ListItem represents a component to be displayed in a List.

View Source
var (
	ListItemPadding = 2
)
View Source
var (
	ListItemSpacing = 2
)
View Source
var Modal = co.Define(&modalComponent{})
View Source
var Paper = co.Define(&paperComponent{})

Paper represents an outlined container.

View Source
var Picture = co.Define(&pictureComponent{})
View Source
var ScrollPane = co.Define(&scrollPaneComponent{})

ScrollPane is a container component that provides scrolling functionality in order to accommodate all children.

View Source
var Spacing = co.Define(&spacingComponent{})

Spacing represents an invisible component that requests that a specific amount of visual space be reserved for it.

View Source
var Switch = co.Define(&switchComponent{})

Switch is a container that can switch between different views depending on the specified SwitchData.

View Source
var Tabbar = co.Define(&tabbarComponent{})
View Source
var TabbarTab = co.Define(&tabbarTabComponent{})
View Source
var Toolbar = co.Define(&toolbarComponent{})

Toolbar represents a container that holds key controls (mostly buttons) in a horizontal fashion.

View Source
var ToolbarButton = co.Define(&toolbarButtonComponent{})
View Source

ToolbarLogo is used to display a logo on the Toolbar. Usually this would be the first item in a Toolbar.

View Source
var ToolbarSeparator = co.Define(&toolbarSeparatorComponent{})
View Source
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

type AccordionData struct {
	Title    string
	Expanded bool
}

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

type ButtonData struct {
	Text    string
	Icon    *ui.Image
	Enabled opt.T[bool]
}

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 CheckboxCallbackData added in v0.16.0

type CheckboxCallbackData struct {
	OnToggle func(bool)
}

type CheckboxData added in v0.16.0

type CheckboxData struct {
	Checked bool
	Label   string
}

type CodeAreaCallbackData added in v0.16.0

type CodeAreaCallbackData struct {
	OnChange func(string)
}

type CodeAreaData added in v0.16.0

type CodeAreaData struct {
	ReadOnly bool
	Code     string
}

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

type DropZoneCallbackData struct {
	OnDrop func(paths []string) bool
}

DropZoneCallbackData can be used to specify callback data for a DropZone component.

type DropdownCallbackData struct {
	OnItemSelected func(key any)
}

DropdownCallbackData holds the callback data for a Dropdown container.

type DropdownData struct {
	Items       []DropdownItem
	SelectedKey any
}

DropdownData holds the data for a Dropdown container.

type DropdownItem struct {
	Key   any
	Label string
}

DropdownItem represents a single dropdown entry.

type EditBoxCallbackData added in v0.16.0

type EditBoxCallbackData struct {
	OnChange func(string)
	OnSubmit func(string)
}

type EditBoxData added in v0.16.0

type EditBoxData struct {
	ReadOnly bool
	Text     string
}

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 PaperData

type PaperData struct {
	Layout ui.Layout
}

PaperData can be used to configure a Paper component.

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

type SpacingData struct {
	Size ui.Size
}

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

type TabbarTabData struct {
	Icon     *ui.Image
	Text     string
	Selected bool
}

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

type ToolbarButtonData struct {
	Icon     *ui.Image
	Text     string
	Enabled  opt.T[bool]
	Selected bool
}

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 ToolbarLogoData added in v0.12.0

type ToolbarLogoData struct {
	Image *ui.Image
	Text  string
}

ToolbarLogoData holds the data for a ToolbarLogo 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

type ViewportData struct {
	API render.API
}

ViewportData holds the data for a Viewport component.

type ViewportMouseEvent

type ViewportMouseEvent struct {
	ui.MouseEvent
	ViewportX float32
	ViewportY 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.

Jump to

Keyboard shortcuts

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