ferrumgui

package module
v0.0.0-...-3f3fba7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

FerrumGUI

Cross-platform GUI framework for Go with a Rust GPU engine.

Public API is idiomatic Go. Rendering and windowing live behind a stable C ABI. No WebView, Electron, HTML, CSS, or JavaScript required.

Status: Under active development toward v0.1.0. Not an official release. Default consumer path is Purego (no CGO). Optional CGO via -tags ferrumgui_cgo. See ROADMAP.md and docs/PLATFORM_SUPPORT.md.

Requirements

Use case Tools
Consume via go get (Purego, shipped platforms) Go 1.25+; no Rust/C toolchain required
Build native engine from source Go 1.25+, Rust stable, platform C toolchain

Module path: github.com/ZYCT10/ferrumgui

import gui "github.com/ZYCT10/ferrumgui"

Minimal surface: NewApp, themes, NewWindow, widgets, layouts, SetContent, Run, Dispatch.

Quick start (developers)

git clone https://github.com/ZYCT10/FerrumGUI.git
cd FerrumGUI

# Windows
powershell -File scripts/dev.ps1 setup
powershell -File scripts/dev.ps1 build
powershell -File scripts/dev.ps1 test

# Unix
make setup && make build && make test

C ABI headers are generated by first-party MIT tools/abigen from abi/ferrumgui.json (go run ./tools/abigen --check).

Documentation

License

MIT — see LICENSE. Third-party notices: THIRD-PARTY-NOTICES.md.

Documentation

Overview

Package ferrumgui is a cross-platform GUI toolkit for Go with a Rust GPU engine.

The public API is idiomatic Go. Native rendering is provided by an internal Rust engine exposed through a stable C ABI. Application code must not use CGO or unsafe pointers.

Phase 5 adds light/dark themes, style overrides, Checkbox, TextInput, Slider, ScrollView, Tabs, and Dialog on top of Label/Button/VBox/HBox. NewApp → NewWindow → SetContent → Run is the supported path.

Suggested import alias:

import gui "github.com/ZYCT10/ferrumgui"
Example

Example shows constructing widgets without opening a native window.

package main

import (
	"fmt"

	gui "github.com/ZYCT10/ferrumgui"
)

func main() {
	label := gui.NewLabel("hello")
	button := gui.NewButton("go")
	box := gui.VBox(label, button)
	fmt.Println(label.Text(), button.Text(), len(box.Children()))
}
Output:
hello go 2

Index

Examples

Constants

View Source
const (
	// StateDisabled is app-writable; skips hit-testing and dims the widget.
	StateDisabled uint32 = 1 << 0
	// StateSelected is app-writable; applies a selected/tint appearance.
	StateSelected uint32 = 1 << 1
	// StateError is app-writable; applies an error/danger border.
	StateError uint32 = 1 << 2
	// StateHovered is engine-managed (pointer over); read via StateFlags.
	StateHovered uint32 = 1 << 3
	// StatePressed is engine-managed (pointer down); read via StateFlags.
	StatePressed uint32 = 1 << 4
	// StateFocused is engine-managed (text focus); read via StateFlags.
	StateFocused uint32 = 1 << 5
	// StateChecked is derived from checkbox checked; read via StateFlags.
	StateChecked uint32 = 1 << 6
)

Widget state bit flags (aligned with FG_STATE_* in the C ABI).

View Source
const ABIVersion = 1

ABIVersion is the expected native C ABI major version. It must match ferrumgui_abi_version() from the Rust engine.

View Source
const Version = "0.1.0"

Version is the Go module semantic version for this source tree.

Variables

View Source
var (
	// ErrNotImplemented is returned for APIs that are designed but not wired yet.
	ErrNotImplemented = errors.New("ferrumgui: not implemented yet")

	// ErrClosed is returned when an operation is attempted on a closed resource.
	ErrClosed = errors.New("ferrumgui: resource closed")

	// ErrInvalidHandle is returned when a native handle is invalid or stale.
	ErrInvalidHandle = errors.New("ferrumgui: invalid handle")

	// ErrWrongThread is returned when a UI operation runs off the UI thread.
	ErrWrongThread = errors.New("ferrumgui: operation requires the UI thread; use App.Dispatch")

	// ErrGPU is returned when GPU initialization or rendering fails.
	ErrGPU = errors.New("ferrumgui: GPU error")

	// ErrInvalidArg is returned for invalid widget construction arguments.
	ErrInvalidArg = errors.New("ferrumgui: invalid argument")
)
View Source
var DefaultLocale = Locale{ID: "en-US"}

DefaultLocale is used when the host locale is unknown.

View Source
var RTLLocaleIDs = []string{"ar", "he", "fa", "ur"}

RTLLocaleIDs lists locales that require right-to-left layout when a bidi engine ships.

Functions

func DragDropSupported

func DragDropSupported() bool

DragDropSupported reports whether native drag-and-drop is implemented.

func F

func F(v float32) *float32

F returns a pointer to v for use in Style / Layout optional fields.

func OpenURL

func OpenURL(url string) error

OpenURL opens a URL with the system default handler. Caller must ensure explicit user intent.

func SetLocale

func SetLocale(loc Locale, table map[string]string)

SetLocale registers a translation table for a locale ID (in-memory stub).

func T

func T(loc Locale, key string) string

T resolves a message key for the given locale, falling back to English then the key itself.

Types

type Accordion

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

Accordion is a stack of expandable sections.

func NewAccordion

func NewAccordion(titles []string, pages ...Widget) *Accordion

NewAccordion builds sections from parallel titles and page widgets.

type AlignItems

type AlignItems uint8

AlignItems is cross-axis alignment for flex containers.

const (
	// AlignUnset keeps the widget-kind default.
	AlignUnset AlignItems = AlignItems(bindings.AlignUnset)
	// AlignStart packs items toward the start of the cross axis.
	AlignStart AlignItems = AlignItems(bindings.AlignStart)
	// AlignCenter centers items on the cross axis.
	AlignCenter AlignItems = AlignItems(bindings.AlignCenter)
	// AlignEnd packs items toward the end of the cross axis.
	AlignEnd AlignItems = AlignItems(bindings.AlignEnd)
	// AlignStretch stretches items across the cross axis.
	AlignStretch AlignItems = AlignItems(bindings.AlignStretch)
)

type App

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

App is the root application object.

func NewApp

func NewApp() (*App, error)

NewApp creates a new application instance backed by the Rust engine.

func (*App) ApplyTokens

func (a *App) ApplyTokens(tokens Tokens) error

ApplyTokens stores the token set and applies its colors as the live engine theme. Widgets using explicit Style keep their overrides; theme-default paint updates.

func (*App) Close

func (a *App) Close() error

Close releases application resources.

func (*App) Dispatch

func (a *App) Dispatch(fn func()) error

Dispatch schedules fn to run on the UI thread. Safe to call from other goroutines. Before Run starts, jobs are queued and flushed when the event loop begins.

func (*App) LoadFontFile

func (a *App) LoadFontFile(path string) error

LoadFontFile queues a TTF/OTF file for the renderer font database. The caller must ensure redistribution rights. Applies on the next paint.

func (*App) NewWindow

func (a *App) NewWindow(title string, width, height int) (*Window, error)

NewWindow creates a top-level window that opens when Run starts.

func (*App) Run

func (a *App) Run() error

Run starts the UI event loop and blocks until the application exits.

func (*App) ScaleFactor

func (a *App) ScaleFactor() float64

ScaleFactor returns the last DPI scale observed for the primary window (1.0 before Run).

func (*App) SetReducedMotion

func (a *App) SetReducedMotion(reduced bool) error

SetReducedMotion enables accessibility mode where animations snap to their end state.

func (*App) SetTheme

func (a *App) SetTheme(mode ThemeMode) error

SetTheme switches to a built-in Light or Dark theme and refreshes App tokens. ThemeCustom is rejected; use ApplyTokens / NewTheme for custom palettes.

func (*App) SetTokens

func (a *App) SetTokens(tokens Tokens) error

SetTokens stores tokens on the App and pushes the color palette to the engine (runtime theme switch / redraw). Prefer ApplyTokens for clarity.

func (*App) SystemAppearance

func (a *App) SystemAppearance() SystemAppearance

SystemAppearance returns the last OS appearance hint captured on the UI thread.

func (*App) Tokens

func (a *App) Tokens() Tokens

Tokens returns a copy of the current design-token set.

type Avatar

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

Avatar is a circle showing initials (bitmap decode deferred).

func NewAvatar

func NewAvatar(initials string) *Avatar

NewAvatar creates an avatar with initials (e.g. "AB").

func (*Avatar) SetStyle

func (a *Avatar) SetStyle(style Style) error

type Badge

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

Badge is a compact label chip.

func NewBadge

func NewBadge(text string) *Badge

NewBadge creates a badge.

func (*Badge) SetStyle

func (b *Badge) SetStyle(style Style) error

func (*Badge) SetText

func (b *Badge) SetText(text string) error

func (*Badge) Text

func (b *Badge) Text() string

type Button

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

Button is a clickable button.

func NewButton

func NewButton(text string) *Button

NewButton creates a button widget.

func (*Button) Enabled

func (b *Button) Enabled() bool

Enabled reports whether the button is enabled.

func (*Button) HasError

func (b *Button) HasError() bool

HasError reports whether error appearance is set.

func (*Button) OnClick

func (b *Button) OnClick(handler func())

OnClick registers a click handler. The handler runs on the UI thread.

func (*Button) Selected

func (b *Button) Selected() bool

Selected reports whether selected appearance is set.

func (*Button) SetEnabled

func (b *Button) SetEnabled(enabled bool) error

SetEnabled enables or disables the button (disabled skips clicks and dims).

func (*Button) SetError

func (b *Button) SetError(on bool) error

SetError toggles error appearance.

func (*Button) SetSelected

func (b *Button) SetSelected(selected bool) error

SetSelected toggles selected appearance (e.g. toggle-button look).

func (*Button) SetStyle

func (b *Button) SetStyle(style Style) error

SetStyle applies optional color overrides.

func (*Button) SetText

func (b *Button) SetText(text string) error

SetText updates the button caption. During App.Run this must be called on the UI thread (or via App.Dispatch).

func (*Button) Text

func (b *Button) Text() string

Text returns the button caption.

type Canvas

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

Canvas is a custom drawing surface using high-level commands (no GPU handles).

func NewCanvas

func NewCanvas(app *App) (*Canvas, error)

NewCanvas creates a canvas widget rooted at the given app.

func (*Canvas) Clear

func (c *Canvas) Clear() error

Clear removes all queued draw commands.

func (*Canvas) FillRect

func (c *Canvas) FillRect(x, y, w, h float32, color Color) error

FillRect queues a filled rectangle in local coordinates.

func (*Canvas) StrokeRect

func (c *Canvas) StrokeRect(x, y, w, h, width float32, color Color) error

StrokeRect queues a stroked rectangle outline.

type Card

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

Card is a padded surface around one child.

func NewCard

func NewCard(child Widget) *Card

NewCard wraps child in a card surface.

func (*Card) SetStyle

func (c *Card) SetStyle(style Style) error

type Checkbox

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

Checkbox is a toggle control with a label.

func NewCheckbox

func NewCheckbox(text string, checked bool) *Checkbox

NewCheckbox creates a checkbox.

func (*Checkbox) Checked

func (c *Checkbox) Checked() bool

Checked returns the current state (local cache; refreshed after engine events).

func (*Checkbox) Enabled

func (c *Checkbox) Enabled() bool

Enabled reports whether the checkbox is enabled.

func (*Checkbox) HasError

func (c *Checkbox) HasError() bool

HasError reports whether error appearance is set.

func (*Checkbox) OnChange

func (c *Checkbox) OnChange(handler func(bool))

OnChange registers a handler invoked after the user toggles the checkbox.

func (*Checkbox) SetChecked

func (c *Checkbox) SetChecked(checked bool) error

SetChecked updates the checked state. During App.Run this must be called on the UI thread (or via App.Dispatch).

func (*Checkbox) SetEnabled

func (c *Checkbox) SetEnabled(enabled bool) error

SetEnabled enables or disables the checkbox.

func (*Checkbox) SetError

func (c *Checkbox) SetError(on bool) error

SetError toggles error appearance.

func (*Checkbox) SetStyle

func (c *Checkbox) SetStyle(style Style) error

SetStyle applies optional color overrides.

type Color

type Color struct {
	R, G, B, A float32
}

Color is an RGBA color with channels in 0..=1.

func C

func C(c Color) *Color

C returns a pointer to c for use in Style optional fields.

func RGB

func RGB(r, g, b uint8) Color

RGB returns an opaque color from 0..=255 channels.

func RGBA

func RGBA(r, g, b, a uint8) Color

RGBA returns a color from 0..=255 channels.

type ColorOverrides

type ColorOverrides struct {
	Background *Color
	Foreground *Color
	Primary    *Color
	OnPrimary  *Color
	Surface    *Color
	Border     *Color
	Danger     *Color
	Success    *Color
}

ColorOverrides are optional color-role replacements merged onto a base theme. Nil fields keep the base value. Any non-nil field yields ThemeCustom.

type ColorTokens

type ColorTokens struct {
	Background Color
	Foreground Color
	Primary    Color
	OnPrimary  Color
	Surface    Color
	Border     Color
	Danger     Color
	Success    Color
}

ColorTokens are named color roles.

type Container

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

Container lays out child widgets.

func HBox

func HBox(children ...Widget) *Container

HBox creates a horizontal container.

func VBox

func VBox(children ...Widget) *Container

VBox creates a vertical container.

func (*Container) Children

func (c *Container) Children() []Widget

Children returns a copy of the container children.

func (*Container) SetLayout

func (c *Container) SetLayout(layout Layout) error

SetLayout applies flex/gap/align overrides for this container.

func (*Container) SetStyle

func (c *Container) SetStyle(style Style) error

SetStyle applies optional color overrides (currently unused for boxes).

type Dialog

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

Dialog is a modal overlay with a title and body. Starts closed.

func NewDialog

func NewDialog(title string, body Widget) *Dialog

NewDialog creates a closed dialog.

func (*Dialog) Close

func (d *Dialog) Close() error

Close hides the dialog.

func (*Dialog) IsOpen

func (d *Dialog) IsOpen() bool

IsOpen reports whether the dialog is visible.

func (*Dialog) OnClose

func (d *Dialog) OnClose(handler func())

OnClose registers a handler for backdrop dismiss.

func (*Dialog) Open

func (d *Dialog) Open() error

Open shows the dialog.

func (*Dialog) SetOpen

func (d *Dialog) SetOpen(open bool) error

SetOpen opens or closes the dialog. During App.Run this must be called on the UI thread (or via App.Dispatch).

func (*Dialog) SetStyle

func (d *Dialog) SetStyle(style Style) error

SetStyle applies optional color overrides.

type Dim

type Dim struct {
	Kind  DimKind
	Value float32
}

Dim is a size override for width/height/min/max.

func Auto

func Auto() Dim

Auto returns an auto dimension.

func Percent

func Percent(v float32) Dim

Percent returns a fractional dimension (0..=1).

func Px

func Px(v float32) Dim

Px returns a length dimension in logical pixels.

type DimKind

type DimKind uint8

DimKind selects how a layout dimension is interpreted.

const (
	// DimUnset keeps the widget-kind default size.
	DimUnset DimKind = DimKind(bindings.DimUnset)
	// DimAuto uses Taffy auto sizing.
	DimAuto DimKind = DimKind(bindings.DimAuto)
	// DimLength is an absolute size in logical pixels.
	DimLength DimKind = DimKind(bindings.DimLength)
	// DimPercent is a fraction of the parent size (1.0 = 100%).
	DimPercent DimKind = DimKind(bindings.DimPercent)
)

type ElevationTokens

type ElevationTokens struct {
	None, Low, Mid, High float32
}

ElevationTokens are shadow-blur steps in logical pixels.

type FileDialog

type FileDialog struct{}

FileDialog provides native open/save/directory pickers (blocking).

Call from App.Dispatch while Run is active so the dialog runs on the UI thread. Cancellation returns ErrNotImplemented.

func (FileDialog) PickDirectory

func (FileDialog) PickDirectory() (string, error)

PickDirectory shows a native directory picker and returns the chosen path.

func (FileDialog) PickOpenFile

func (FileDialog) PickOpenFile() (string, error)

PickOpenFile shows a native open-file dialog and returns the chosen path.

func (FileDialog) PickSaveFile

func (FileDialog) PickSaveFile() (string, error)

PickSaveFile shows a native save-file dialog and returns the chosen path.

type FontFamily

type FontFamily int

FontFamily selects a generic system font family.

const (
	// FontSans is the default sans-serif family.
	FontSans FontFamily = 1
	// FontSerif is a serif family.
	FontSerif FontFamily = 2
	// FontMono is a monospace family.
	FontMono FontFamily = 3
)

type Grid

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

Grid is a CSS-like grid with equal flexible columns and auto rows. Children are placed in row-major order.

func NewGrid

func NewGrid(columns int, children ...Widget) *Grid

NewGrid creates a grid with the given column count (values < 1 become 1).

func (*Grid) Children

func (g *Grid) Children() []Widget

Children returns a copy of the grid children.

func (*Grid) Columns

func (g *Grid) Columns() int

Columns returns the configured column count.

func (*Grid) SetLayout

func (g *Grid) SetLayout(layout Layout) error

SetLayout applies gap/padding/align overrides for this grid.

func (*Grid) SetStyle

func (g *Grid) SetStyle(style Style) error

SetStyle applies optional color overrides.

type GroupBox

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

GroupBox is a titled border around one child widget.

func NewGroupBox

func NewGroupBox(title string, child Widget) *GroupBox

NewGroupBox creates a group box around child.

func (*GroupBox) SetStyle

func (g *GroupBox) SetStyle(style Style) error

type Icon

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

Icon displays a text glyph fallback (no icon-font dependency).

func NewIcon

func NewIcon(glyph string) *Icon

NewIcon creates an icon from a short glyph string.

func (*Icon) SetStyle

func (ic *Icon) SetStyle(style Style) error

type Image

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

Image is a STUB placeholder until a license-checked bitmap decoder ships.

func NewImage

func NewImage(alt string) *Image

NewImage creates an image placeholder with accessibility alt text.

func (*Image) Alt

func (i *Image) Alt() string

Alt returns the accessibility description.

func (*Image) SetStyle

func (i *Image) SetStyle(style Style) error

type JustifyContent

type JustifyContent uint8

JustifyContent is main-axis distribution for flex containers.

const (
	// JustifyUnset keeps the widget-kind default.
	JustifyUnset JustifyContent = JustifyContent(bindings.JustifyUnset)
	// JustifyStart packs toward the start.
	JustifyStart JustifyContent = JustifyContent(bindings.JustifyStart)
	// JustifyCenter centers along the main axis.
	JustifyCenter JustifyContent = JustifyContent(bindings.JustifyCenter)
	// JustifyEnd packs toward the end.
	JustifyEnd JustifyContent = JustifyContent(bindings.JustifyEnd)
	// JustifySpaceBetween distributes free space between items.
	JustifySpaceBetween JustifyContent = JustifyContent(bindings.JustifySpaceBetween)
	// JustifySpaceAround distributes free space around items.
	JustifySpaceAround JustifyContent = JustifyContent(bindings.JustifySpaceAround)
	// JustifySpaceEvenly distributes equal space between and around items.
	JustifySpaceEvenly JustifyContent = JustifyContent(bindings.JustifySpaceEvenly)
)

type Label

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

Label displays read-only text.

func NewLabel

func NewLabel(text string) *Label

NewLabel creates a label widget.

func (*Label) Enabled

func (l *Label) Enabled() bool

Enabled reports whether the label is enabled.

func (*Label) HasError

func (l *Label) HasError() bool

HasError reports whether error appearance is set.

func (*Label) SetEnabled

func (l *Label) SetEnabled(enabled bool) error

SetEnabled enables or disables the label (visual dimming when disabled).

func (*Label) SetError

func (l *Label) SetError(on bool) error

SetError toggles error appearance (danger border).

func (*Label) SetStyle

func (l *Label) SetStyle(style Style) error

SetStyle applies optional color overrides.

func (*Label) SetText

func (l *Label) SetText(text string) error

SetText updates the label text. During App.Run this must be called on the UI thread (or via App.Dispatch).

func (*Label) Text

func (l *Label) Text() string

Text returns the current label text.

type Layout

type Layout struct {
	FlexGrow       *float32
	FlexShrink     *float32
	Width          *Dim
	Height         *Dim
	MinWidth       *Dim
	MinHeight      *Dim
	MaxWidth       *Dim
	MaxHeight      *Dim
	Gap            *float32
	Padding        *float32
	AlignItems     AlignItems
	JustifyContent JustifyContent
	Position       PositionMode
	Overflow       OverflowMode
	Left           *Dim
	Top            *Dim
	Right          *Dim
	Bottom         *Dim
}

Layout holds optional per-node layout overrides. Nil / zero-kind fields keep widget-kind Taffy defaults.

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

Link is clickable hyperlink-styled text (no automatic navigation).

func NewLink(text string) *Link

NewLink creates a link label.

func (*Link) OnClick

func (l *Link) OnClick(handler func())

func (*Link) SetStyle

func (l *Link) SetStyle(style Style) error

func (*Link) SetText

func (l *Link) SetText(text string) error

func (*Link) Text

func (l *Link) Text() string

type ListView

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

ListView shows a modest string list (not for huge data).

func NewListView

func NewListView(items []string) *ListView

NewListView creates a list view.

type Locale

type Locale struct {
	// ID is a BCP 47 tag such as "en-US".
	ID string
}

Locale identifies a language/region tag (BCP 47). Phase 14 STUB — no ICU/runtime loader yet.

type NumberInput

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

NumberInput is a stepped numeric field.

func NewNumberInput

func NewNumberInput(value, min, max, step float64) *NumberInput

NewNumberInput creates a number input.

func (*NumberInput) OnChange

func (n *NumberInput) OnChange(fn func()) error

func (*NumberInput) Value

func (n *NumberInput) Value() float64

Value returns the current value.

type Observable

type Observable[T any] struct {
	// contains filtered or unexported fields
}

Observable is a minimal optional binding helper (Phase 17). No global store, no FFI.

func NewObservable

func NewObservable[T any](initial T) *Observable[T]

NewObservable creates an observable holding an initial value.

func (*Observable[T]) Get

func (o *Observable[T]) Get() T

Get returns the current value.

func (*Observable[T]) Set

func (o *Observable[T]) Set(v T)

Set updates the value and notifies subscribers.

func (*Observable[T]) Subscribe

func (o *Observable[T]) Subscribe(fn func(T))

Subscribe registers a callback invoked on each Set (caller must not block).

type OverflowMode

type OverflowMode uint8

OverflowMode controls descendant clipping.

const (
	// OverflowUnset keeps the widget-kind default (visible).
	OverflowUnset OverflowMode = OverflowMode(bindings.OverflowUnset)
	// OverflowVisible allows descendants to paint/hit outside bounds.
	OverflowVisible OverflowMode = OverflowMode(bindings.OverflowVisible)
	// OverflowHidden clips descendants outside the node bounds (paint + hit-test).
	OverflowHidden OverflowMode = OverflowMode(bindings.OverflowHidden)
)

type Overlay

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

Overlay places layers above a base widget within the same bounds.

func NewOverlay

func NewOverlay(base Widget, layers ...Widget) *Overlay

NewOverlay creates an overlay with a base and optional layers (bottom → top).

func (*Overlay) SetLayout

func (o *Overlay) SetLayout(layout Layout) error

SetLayout applies layout overrides for this overlay container.

func (*Overlay) SetStyle

func (o *Overlay) SetStyle(style Style) error

SetStyle applies optional color overrides.

type PositionMode

type PositionMode uint8

PositionMode selects CSS-like positioning.

const (
	// PositionUnset keeps the widget-kind default.
	PositionUnset PositionMode = PositionMode(bindings.PosUnset)
	// PositionRelative keeps normal flow and establishes a containing block.
	PositionRelative PositionMode = PositionMode(bindings.PosRelative)
	// PositionAbsolute takes the node out of flow; use Left/Top/Right/Bottom.
	PositionAbsolute PositionMode = PositionMode(bindings.PosAbsolute)
)

type Progress

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

Progress is a determinate bar (value 0..1).

func NewProgress

func NewProgress(value float32) *Progress

NewProgress creates a progress bar.

func (*Progress) SetEnabled

func (p *Progress) SetEnabled(enabled bool) error

func (*Progress) SetStyle

func (p *Progress) SetStyle(style Style) error

func (*Progress) SetValue

func (p *Progress) SetValue(value float32) error

SetValue sets fill fraction (0..1).

func (*Progress) Value

func (p *Progress) Value() float32

Value returns the fill fraction (0..1).

type Radio

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

Radio is one option within a RadioGroup.

func NewRadio

func NewRadio(text string, selected bool) *Radio

NewRadio creates a radio option (attach via NewRadioGroup).

func (*Radio) OnChange

func (r *Radio) OnChange(handler func(bool))

func (*Radio) Selected

func (r *Radio) Selected() bool

type RadioGroup

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

RadioGroup provides exclusive selection among Radio children.

func NewRadioGroup

func NewRadioGroup(options ...*Radio) *RadioGroup

NewRadioGroup creates a horizontal radio group from options.

func (*RadioGroup) Options

func (g *RadioGroup) Options() []*Radio

func (*RadioGroup) SetStyle

func (g *RadioGroup) SetStyle(style Style) error

type RadiusTokens

type RadiusTokens struct {
	None, S, M, L float32
}

RadiusTokens are corner-radius steps in logical pixels.

type RangeSlider

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

RangeSlider selects an interval on a track.

func NewRangeSlider

func NewRangeSlider(low, high, min, max float32) *RangeSlider

NewRangeSlider creates a dual-thumb slider.

func (*RangeSlider) OnChange

func (r *RangeSlider) OnChange(fn func()) error

type ScrollView

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

ScrollView clips and scrolls a single child vertically.

func NewScrollView

func NewScrollView(child Widget) *ScrollView

NewScrollView wraps child in a scrollable viewport.

func (*ScrollView) SetStyle

func (s *ScrollView) SetStyle(style Style) error

SetStyle applies optional color overrides.

type Select

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

Select is a single-choice dropdown (Combo/Dropdown share this implementation).

func NewCombo

func NewCombo(options []string, selected int) *Select

NewCombo is an alias for NewSelect.

func NewSelect

func NewSelect(options []string, selected int) *Select

NewSelect creates a select with the given options and initial index.

func (*Select) OnChange

func (s *Select) OnChange(fn func()) error

OnChange registers a callback when the selection changes.

func (*Select) Selected

func (s *Select) Selected() int

Selected returns the chosen option index.

func (*Select) SetStyle

func (s *Select) SetStyle(style Style) error

type Separator

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

Separator is a horizontal or vertical rule line.

func NewSeparator

func NewSeparator(horizontal bool) *Separator

NewSeparator creates a separator. When horizontal is true the line spans the layout width.

func (*Separator) Horizontal

func (s *Separator) Horizontal() bool

Horizontal reports orientation.

func (*Separator) SetStyle

func (s *Separator) SetStyle(style Style) error

type SizeTokens

type SizeTokens struct {
	ControlHeight float32
	Icon          float32
	HitTarget     float32
}

SizeTokens are control sizing steps in logical pixels.

type Slider

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

Slider is a numeric range control.

func NewSlider

func NewSlider(value, min, max float32) *Slider

NewSlider creates a slider with value clamped to [min, max].

Example

ExampleNewSlider shows slider clamping helpers on the Go side.

package main

import (
	"fmt"

	gui "github.com/ZYCT10/ferrumgui"
)

func main() {
	s := gui.NewSlider(50, 0, 100)
	fmt.Printf("%.0f\n", s.Value())
}
Output:
50

func (*Slider) Enabled

func (s *Slider) Enabled() bool

Enabled reports whether the slider is enabled.

func (*Slider) HasError

func (s *Slider) HasError() bool

HasError reports whether error appearance is set.

func (*Slider) OnChange

func (s *Slider) OnChange(handler func(float32))

OnChange registers a handler for user drags.

func (*Slider) SetEnabled

func (s *Slider) SetEnabled(enabled bool) error

SetEnabled enables or disables the slider.

func (*Slider) SetError

func (s *Slider) SetError(on bool) error

SetError toggles error appearance.

func (*Slider) SetStyle

func (s *Slider) SetStyle(style Style) error

SetStyle applies optional color overrides.

func (*Slider) SetValue

func (s *Slider) SetValue(value float32) error

SetValue updates the slider value. During App.Run this must be called on the UI thread (or via App.Dispatch).

func (*Slider) Value

func (s *Slider) Value() float32

Value returns the current slider value.

type SpaceTokens

type SpaceTokens struct {
	XS, S, M, L, XL, XXL float32
}

SpaceTokens are spacing steps in logical pixels.

type Spacer

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

Spacer is flexible empty space in a flex container (default flex_grow=1).

func NewSpacer

func NewSpacer() *Spacer

NewSpacer creates a flex spacer (default flex_grow=1).

func (*Spacer) SetLayout

func (s *Spacer) SetLayout(layout Layout) error

SetLayout applies layout overrides (typically FlexGrow).

type Spinner

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

Spinner is an indeterminate activity indicator (engine rotates paint each frame).

func NewSpinner

func NewSpinner() *Spinner

NewSpinner creates a spinner.

func (*Spinner) SetStyle

func (s *Spinner) SetStyle(style Style) error

type SplitView

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

SplitView lays out two children with a draggable divider.

func NewSplitView

func NewSplitView(horizontal bool, ratio float32, first, second Widget) *SplitView

NewSplitView creates a split container.

type Stack

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

Stack layers children in the same bounds (paint order = argument order).

func NewStack

func NewStack(children ...Widget) *Stack

NewStack creates an overlapping stack of widgets.

func (*Stack) Children

func (s *Stack) Children() []Widget

Children returns a copy of the stack children.

func (*Stack) SetLayout

func (s *Stack) SetLayout(layout Layout) error

SetLayout applies layout overrides for this stack.

func (*Stack) SetStyle

func (s *Stack) SetStyle(style Style) error

SetStyle applies optional color overrides.

type StubWidget

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

StubWidget marks deferred widgets in the gallery (DatePicker, Menu bar, …).

func NewStubWidget

func NewStubWidget(label string) *StubWidget

NewStubWidget creates a labeled STUB placeholder.

type Style

type Style struct {
	Background   *Color
	Foreground   *Color
	BorderColor  *Color
	BorderWidth  *float32
	CornerRadius *float32
	Padding      *float32
	Margin       *float32
	Opacity      *float32
	FontSize     *float32
	ShadowBlur   *float32
	FontFamily   FontFamily // 0 = unset
	FontWeight   uint16     // 0 = unset; else 100..=900
	FontItalic   bool
	TextWrap     TextWrap     // 0 = unset
	TextOverflow TextOverflow // 0 = unset
}

Style holds optional per-widget visual overrides. Padding/Margin also update layout on apply. CornerRadius is stored for API compatibility; GPU rounded fills arrive later. ShadowBlur draws a soft offset rect.

type Switch

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

Switch is a boolean on/off control (distinct paint from Checkbox).

func NewSwitch

func NewSwitch(text string, on bool) *Switch

NewSwitch creates a switch.

func (*Switch) On

func (s *Switch) On() bool

func (*Switch) OnChange

func (s *Switch) OnChange(handler func(bool))

func (*Switch) SetEnabled

func (s *Switch) SetEnabled(enabled bool) error

func (*Switch) SetOn

func (s *Switch) SetOn(on bool) error

func (*Switch) SetStyle

func (s *Switch) SetStyle(style Style) error

type SystemAppearance

type SystemAppearance int

SystemAppearance reports the OS window chrome preference when known.

const (
	// SystemAppearanceUnknown means the engine has not observed a theme yet.
	SystemAppearanceUnknown SystemAppearance = iota
	// SystemAppearanceLight is the OS light preference.
	SystemAppearanceLight
	// SystemAppearanceDark is the OS dark preference.
	SystemAppearanceDark
)

type Table

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

Table shows column headers and virtualized body cells.

func NewTable

func NewTable(columns []string, rowCount uint32, rowHeight float32) *Table

NewTable creates a table widget.

func (*Table) SetWindowCells

func (t *Table) SetWindowCells(cells []string) error

SetWindowCells sets flat visible cell values (row-major).

type Tabs

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

Tabs is a tabbed container; only the selected page is shown.

func NewTabs

func NewTabs(titles []string, pages ...Widget) *Tabs

NewTabs creates tabs from parallel titles and page widgets.

Example

ExampleNewTabs shows tab construction.

package main

import (
	"fmt"

	gui "github.com/ZYCT10/ferrumgui"
)

func main() {
	tabs := gui.NewTabs(
		[]string{"A", "B"},
		gui.NewLabel("page a"),
		gui.NewLabel("page b"),
	)
	fmt.Println(tabs.Selected())
}
Output:
0

func (*Tabs) OnChange

func (t *Tabs) OnChange(handler func(int))

OnChange registers a handler for user tab switches.

func (*Tabs) Selected

func (t *Tabs) Selected() int

Selected returns the selected tab index.

func (*Tabs) SetSelected

func (t *Tabs) SetSelected(index int) error

SetSelected selects a tab by index. During App.Run this must be called on the UI thread (or via App.Dispatch).

func (*Tabs) SetStyle

func (t *Tabs) SetStyle(style Style) error

SetStyle applies optional color overrides.

type TextArea

type TextArea struct {
	TextInput
}

TextArea is a multi-line editable field (same editing model as TextInput).

func NewTextArea

func NewTextArea(text string) *TextArea

NewTextArea creates a multi-line text area with initial text.

type TextInput

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

TextInput is a single-line editable field.

Unicode editing uses grapheme clusters (emoji ZWJ, combining marks, CJK). BiDi/RTL shaping is performed by glyphon (Shaping::Advanced); the public API stores UTF-8 and does not expose a custom shaper.

Keyboard (when focused): arrows + Shift selection, Backspace/Delete, Ctrl+A/C/X/V/Z/Y, Escape clears focus. Tab / Shift+Tab cycle focus among focusable controls. Clipboard access happens only on explicit Ctrl+C/X/V.

IME: composition/preedit is painted when the platform delivers winit Ime events; coverage is validated on Windows x86_64 first—other platforms are not claimed until interactive smoke exists (see PLATFORMS).

func NewPasswordInput

func NewPasswordInput(text string) *TextInput

NewPasswordInput creates a single-line password field (value is never copied to the clipboard by the engine; display is masked).

func NewTextInput

func NewTextInput(text string) *TextInput

NewTextInput creates a text input with initial text.

func (*TextInput) Enabled

func (t *TextInput) Enabled() bool

Enabled reports whether the text input is enabled.

func (*TextInput) HasError

func (t *TextInput) HasError() bool

HasError reports whether error appearance is set.

func (*TextInput) OnChange

func (t *TextInput) OnChange(handler func(string))

OnChange registers a handler for user edits.

func (*TextInput) Password

func (t *TextInput) Password() bool

Password reports whether password masking is enabled.

func (*TextInput) SetEnabled

func (t *TextInput) SetEnabled(enabled bool) error

SetEnabled enables or disables the text input.

func (*TextInput) SetError

func (t *TextInput) SetError(on bool) error

SetError toggles error / validation appearance.

func (*TextInput) SetPassword

func (t *TextInput) SetPassword(password bool) error

SetPassword toggles password masking. When masked, clipboard copy yields empty.

func (*TextInput) SetStyle

func (t *TextInput) SetStyle(style Style) error

SetStyle applies optional color overrides.

func (*TextInput) SetText

func (t *TextInput) SetText(text string) error

SetText replaces the field contents. During App.Run this must be called on the UI thread (or via App.Dispatch).

func (*TextInput) Text

func (t *TextInput) Text() string

Text returns the current value (refreshed from the engine when live).

type TextOverflow

type TextOverflow int

TextOverflow controls clipped single-line overflow.

const (
	// TextOverflowClip clips without an ellipsis.
	TextOverflowClip TextOverflow = 1
	// TextOverflowEllipsis truncates with an ellipsis.
	TextOverflowEllipsis TextOverflow = 2
)

type TextWrap

type TextWrap int

TextWrap controls shaped-text wrapping.

const (
	// TextWrapNone disables wrapping (single line).
	TextWrapNone TextWrap = 1
	// TextWrapWord wraps at word boundaries.
	TextWrapWord TextWrap = 2
	// TextWrapGlyph wraps at glyph boundaries.
	TextWrapGlyph TextWrap = 3
	// TextWrapWordOrGlyph prefers words, else glyphs.
	TextWrapWordOrGlyph TextWrap = 4
)

type ThemeMode

type ThemeMode int

ThemeMode selects a built-in or custom application theme.

const (
	// ThemeLight is the default light palette.
	ThemeLight ThemeMode = ThemeMode(bindings.ThemeLight)
	// ThemeDark is the dark palette.
	ThemeDark ThemeMode = ThemeMode(bindings.ThemeDark)
	// ThemeCustom marks a palette built with overrides / ApplyTokens.
	ThemeCustom ThemeMode = ThemeMode(bindings.ThemeCustom)
)

type Toast

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

Toast is a transient banner message.

func NewToast

func NewToast(message string) *Toast

NewToast creates a toast.

func (*Toast) SetVisible

func (t *Toast) SetVisible(visible bool) error

SetVisible shows or hides the toast.

type Tokens

type Tokens struct {
	Color     ColorTokens
	Space     SpaceTokens
	Type      TypeTokens
	Radius    RadiusTokens
	Elevation ElevationTokens
	Size      SizeTokens
	// contains filtered or unexported fields
}

Tokens is a design-token set (colors, space, type, radius, elevation, size). Values are plain data resolved by the app into Style / Layout; nothing executes.

func Inherit

func Inherit(base ThemeMode, o ColorOverrides) Tokens

Inherit returns NewTheme(base, o) — Light/Dark inheritance with overrides.

func NewTheme

func NewTheme(base ThemeMode, o ColorOverrides) Tokens

NewTheme builds tokens from a Light/Dark base with optional color overrides. Any override marks the result as ThemeCustom.

func TokensDark

func TokensDark() Tokens

TokensDark returns the built-in dark design tokens.

func TokensForMode

func TokensForMode(mode ThemeMode) Tokens

TokensForMode returns TokensLight or TokensDark. ThemeCustom falls back to TokensLight (use NewTheme for custom palettes).

func TokensLight

func TokensLight() Tokens

TokensLight returns the built-in light design tokens.

func (Tokens) LayoutPad

func (t Tokens) LayoutPad(pad float32) Layout

LayoutPad returns a Layout with uniform padding from the space scale.

func (Tokens) Mode

func (t Tokens) Mode() ThemeMode

Mode reports the theme mode these tokens belong to.

func (Tokens) StyleDanger

func (t Tokens) StyleDanger() Style

StyleDanger builds a danger-accent Style.

func (Tokens) StylePrimary

func (t Tokens) StylePrimary() Style

StylePrimary builds a primary-accent Style (e.g. filled button look).

func (Tokens) StyleSurface

func (t Tokens) StyleSurface() Style

StyleSurface builds a surface Style from tokens (bg/fg/border/radius/pad).

func (Tokens) WithColorOverrides

func (t Tokens) WithColorOverrides(o ColorOverrides) Tokens

WithColorOverrides returns a copy with non-nil color roles replaced. Marks the result ThemeCustom when any override is set.

type Tooltip

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

Tooltip shows helper text (typically in an overlay layer).

func NewTooltip

func NewTooltip(text string) *Tooltip

NewTooltip creates a tooltip node.

type TypeTokens

type TypeTokens struct {
	Caption float32
	Body    float32
	Button  float32
	Title   float32
}

TypeTokens are font sizes in logical pixels.

type VirtualList

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

VirtualList virtualizes rows (engine paints a visible window only).

func NewVirtualList

func NewVirtualList(rowCount uint32, rowHeight float32) *VirtualList

NewVirtualList creates a virtual list with logical row count.

func (*VirtualList) SetWindowLabels

func (v *VirtualList) SetWindowLabels(labels []string) error

SetWindowLabels sets labels for currently visible rows (length ≈ viewport).

type Widget

type Widget interface {
	// contains filtered or unexported methods
}

Widget is a node in the UI tree.

func WithLayout

func WithLayout(inner Widget, layout Layout) Widget

WithLayout returns a widget that applies layout overrides after materialization. Useful for Absolute positioning of leaf widgets inside Stack/Overlay.

type Window

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

Window is a native top-level window.

func (*Window) Close

func (w *Window) Close() error

Close closes the window and releases native resources.

func (*Window) ConfirmClose

func (w *Window) ConfirmClose() error

ConfirmClose completes an intercepted close and requests exit.

func (*Window) ScaleFactor

func (w *Window) ScaleFactor() (float64, error)

ScaleFactor returns the last observed DPI scale for this window.

func (*Window) SetContent

func (w *Window) SetContent(node Widget) error

SetContent sets the root widget tree for the window.

func (*Window) SetFullscreen

func (w *Window) SetFullscreen(fullscreen bool) error

SetFullscreen toggles borderless fullscreen (best effort).

func (*Window) SetMaxSize

func (w *Window) SetMaxSize(width, height int) error

SetMaxSize sets maximum inner size. Zero clears an axis while running.

func (*Window) SetMinSize

func (w *Window) SetMinSize(width, height int) error

SetMinSize sets minimum inner size. Zero clears an axis while running.

func (*Window) SetOnClose

func (w *Window) SetOnClose(fn func()) error

SetOnClose installs a close intercept. Call ConfirmClose from the callback to exit.

func (*Window) SetResizable

func (w *Window) SetResizable(resizable bool) error

SetResizable enables or disables user resizing.

func (*Window) SetSize

func (w *Window) SetSize(width, height int) error

SetSize sets the inner size in logical pixels.

func (*Window) SetTitle

func (w *Window) SetTitle(title string) error

SetTitle sets the window title (before or during Run).

Directories

Path Synopsis
examples
hello command
Command hello demonstrates themes, controls, tabs, scrolling, and a dialog.
Command hello demonstrates themes, controls, tabs, scrolling, and a dialog.
widget-gallery command
Minimal Phase 11 widget gallery (Windows + CGO).
Minimal Phase 11 widget gallery (Windows + CGO).
internal
bindings
Package bindings wraps the FerrumGUI C ABI for use by the public Go API.
Package bindings wraps the FerrumGUI C ABI for use by the public Go API.
native
Package native registers embedded FerrumGUI engine artifacts for the secure loader (internal/nativeload).
Package native registers embedded FerrumGUI engine artifacts for the secure loader (internal/nativeload).
nativeload
Package nativeload extracts and loads embedded FerrumGUI engine shared libraries.
Package nativeload extracts and loads embedded FerrumGUI engine shared libraries.
platform
Package platform contains OS-thread and platform helpers for FerrumGUI.
Package platform contains OS-thread and platform helpers for FerrumGUI.
tools
abigen command

Jump to

Keyboard shortcuts

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