guigui

package module
v0.0.0-...-20427f5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

Guigui (ぐいぐい)

An immediate-mode-like GUI framework for Go

[!CAUTION] This project is an alpha version, and everything may change in the future.

[!WARNING] Except for minor changes like typo fixes, we have not yet established a development policy for accepting changes. For new features, please file an issue or make your proposal in Discussion.

  • Pure Go implementation without any use of HTML, CSS, or JavaScript
  • Hi-DPI support for clear visuals on modern displays
  • Built-in internationalization (I18N) support for multiple languages
  • Efficient rendering with optimized draw calls for better performance
Light Mode Dark Mode
Light Mode Dark Mode
git clone https://github.com/guigui-gui/guigui.git
cd guigui
go run ./example/gallery

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DispatchEvent

func DispatchEvent(widget Widget, eventName string, args ...any)

func RequestRebuild

func RequestRebuild(widget Widget)

func RequestRedraw

func RequestRedraw(widget Widget)

func Run

func Run(root Widget, options *RunOptions) error

func RunWithCustomFunc

func RunWithCustomFunc(root Widget, options *RunOptions, f func(game ebiten.Game, options *ebiten.RunGameOptions) error) error

func SetEventHandler

func SetEventHandler(widget Widget, eventName string, handler any)

Types

type ChildAdder

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

func (*ChildAdder) AddChild

func (c *ChildAdder) AddChild(widget Widget)

TODO: Rename this to AddWidget.

type ChildLayouter

type ChildLayouter struct {
}

func (*ChildLayouter) LayoutWidget

func (c *ChildLayouter) LayoutWidget(widget Widget, bounds image.Rectangle)

type ColorMode

type ColorMode int
const (
	ColorModeLight ColorMode = iota
	ColorModeDark
)

type Constraints

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

func FixedHeightConstraints

func FixedHeightConstraints(h int) Constraints

func FixedWidthConstraints

func FixedWidthConstraints(w int) Constraints

func (*Constraints) FixedHeight

func (c *Constraints) FixedHeight() (int, bool)

func (*Constraints) FixedWidth

func (c *Constraints) FixedWidth() (int, bool)

type Context

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

func (*Context) AppBounds

func (c *Context) AppBounds() image.Rectangle

func (*Context) AppScale

func (c *Context) AppScale() float64

func (*Context) AppendAppLocales

func (c *Context) AppendAppLocales(locales []language.Tag) []language.Tag

func (*Context) AppendLocales

func (c *Context) AppendLocales(locales []language.Tag) []language.Tag

func (*Context) ColorMode

func (c *Context) ColorMode() ColorMode

func (*Context) DelegateFocus

func (c *Context) DelegateFocus(from Widget, to Widget)

func (*Context) DeviceScale

func (c *Context) DeviceScale() float64

func (*Context) IsAutoColorModeUsed

func (c *Context) IsAutoColorModeUsed() bool

func (*Context) IsEnabled

func (c *Context) IsEnabled(widget Widget) bool

func (*Context) IsFocused

func (c *Context) IsFocused(widget Widget) bool

func (*Context) IsFocusedOrHasFocusedChild

func (c *Context) IsFocusedOrHasFocusedChild(widget Widget) bool

func (*Context) IsVisible

func (c *Context) IsVisible(widget Widget) bool

func (*Context) Model

func (c *Context) Model(widget Widget, key any) any

func (*Context) Opacity

func (c *Context) Opacity(widget Widget) float64

func (*Context) PassThrough

func (c *Context) PassThrough(widget Widget) bool

func (*Context) Scale

func (c *Context) Scale() float64

func (*Context) SetAppLocales

func (c *Context) SetAppLocales(locales []language.Tag)

func (*Context) SetAppScale

func (c *Context) SetAppScale(scale float64)

func (*Context) SetColorMode

func (c *Context) SetColorMode(mode ColorMode)

func (*Context) SetContainer

func (c *Context) SetContainer(widget Widget, container bool)

func (*Context) SetCustomDraw

func (c *Context) SetCustomDraw(widget Widget, customDraw CustomDrawFunc)

func (*Context) SetEnabled

func (c *Context) SetEnabled(widget Widget, enabled bool)

func (*Context) SetFloat

func (c *Context) SetFloat(widget Widget, float bool)

func (*Context) SetFocused

func (c *Context) SetFocused(widget Widget, focused bool)

func (*Context) SetOpacity

func (c *Context) SetOpacity(widget Widget, opacity float64)

func (*Context) SetPassThrough

func (c *Context) SetPassThrough(widget Widget, passThrough bool)

func (*Context) SetVisible

func (c *Context) SetVisible(widget Widget, visible bool)

func (*Context) SetWindowTitle

func (c *Context) SetWindowTitle(title string)

func (*Context) SetZDelta

func (c *Context) SetZDelta(widget Widget, zDelta int)

func (*Context) UseAutoColorMode

func (c *Context) UseAutoColorMode()

func (*Context) ZDelta

func (c *Context) ZDelta(widget Widget) int

type CustomDrawFunc

type CustomDrawFunc func(dst, widgetImage *ebiten.Image, op *ebiten.DrawImageOptions)

type DefaultWidget

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

func (*DefaultWidget) Build

func (*DefaultWidget) Build(context *Context, adder *ChildAdder) error

func (*DefaultWidget) CursorShape

func (*DefaultWidget) CursorShape(context *Context, widgetBounds *WidgetBounds) (ebiten.CursorShapeType, bool)

func (*DefaultWidget) Draw

func (*DefaultWidget) Draw(context *Context, widgetBounds *WidgetBounds, dst *ebiten.Image)

func (*DefaultWidget) HandleButtonInput

func (*DefaultWidget) HandleButtonInput(context *Context, widgetBounds *WidgetBounds) HandleInputResult

func (*DefaultWidget) HandlePointingInput

func (*DefaultWidget) HandlePointingInput(context *Context, widgetBounds *WidgetBounds) HandleInputResult

func (*DefaultWidget) Layout

func (*DefaultWidget) Layout(context *Context, widgetBounds *WidgetBounds, layouter *ChildLayouter)

func (*DefaultWidget) Measure

func (d *DefaultWidget) Measure(context *Context, constraints Constraints) image.Point

func (*DefaultWidget) Model

func (*DefaultWidget) Model(key any) any

func (*DefaultWidget) OnFocusChanged

func (*DefaultWidget) OnFocusChanged(context *Context, focused bool)

func (*DefaultWidget) Tick

func (*DefaultWidget) Tick(context *Context, widgetBounds *WidgetBounds) error

type HandleInputResult

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

func AbortHandlingInputByWidget

func AbortHandlingInputByWidget(widget Widget) HandleInputResult

func HandleInputByWidget

func HandleInputByWidget(widget Widget) HandleInputResult

type Layout

type Layout interface {
	LayoutWidgets(context *Context, bounds image.Rectangle, layouter WidgetLayouter)
	Measure(context *Context, constraints Constraints) image.Point
}

type LayoutDirection

type LayoutDirection int
const (
	LayoutDirectionHorizontal LayoutDirection = iota
	LayoutDirectionVertical
)

type LinearLayout

type LinearLayout struct {
	Direction LayoutDirection
	Items     []LinearLayoutItem
	Gap       int
	Padding   Padding
}

func (LinearLayout) AppendItemBounds

func (l LinearLayout) AppendItemBounds(boundsArr []image.Rectangle, context *Context, bounds image.Rectangle) []image.Rectangle

func (LinearLayout) LayoutWidgets

func (l LinearLayout) LayoutWidgets(context *Context, bounds image.Rectangle, layouter WidgetLayouter)

func (LinearLayout) Measure

func (l LinearLayout) Measure(context *Context, constraints Constraints) image.Point

type LinearLayoutItem

type LinearLayoutItem struct {
	Widget Widget
	Size   Size
	Layout Layout
}

type Padding

type Padding struct {
	Start  int
	Top    int
	End    int
	Bottom int
}

type RunOptions

type RunOptions struct {
	Title          string
	WindowSize     image.Point
	WindowMinSize  image.Point
	WindowMaxSize  image.Point
	WindowFloating bool
	AppScale       float64

	RunGameOptions *ebiten.RunGameOptions
}

type Size

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

func FixedSize

func FixedSize(value int) Size

func FlexibleSize

func FlexibleSize(value int) Size

type Widget

type Widget interface {
	Model(key any) any
	Build(context *Context, adder *ChildAdder) error
	Layout(context *Context, widgetBounds *WidgetBounds, layouter *ChildLayouter)
	HandlePointingInput(context *Context, widgetBounds *WidgetBounds) HandleInputResult
	HandleButtonInput(context *Context, widgetBounds *WidgetBounds) HandleInputResult
	Tick(context *Context, widgetBounds *WidgetBounds) error
	CursorShape(context *Context, widgetBounds *WidgetBounds) (ebiten.CursorShapeType, bool)
	Draw(context *Context, widgetBounds *WidgetBounds, dst *ebiten.Image)
	Measure(context *Context, constraints Constraints) image.Point

	// OnFocusChanged is called when the widget is focused or unfocused.
	// OnFocusChanged can be called even when the widget is not in the tree.
	OnFocusChanged(context *Context, focused bool)
	// contains filtered or unexported methods
}

type WidgetBounds

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

func (*WidgetBounds) Bounds

func (w *WidgetBounds) Bounds() image.Rectangle

func (*WidgetBounds) IsHitAtCursor

func (w *WidgetBounds) IsHitAtCursor() bool

func (*WidgetBounds) VisibleBounds

func (w *WidgetBounds) VisibleBounds() image.Rectangle

type WidgetLayouter

type WidgetLayouter interface {
	LayoutWidget(widget Widget, bounds image.Rectangle)
}

type WidgetWithPadding

type WidgetWithPadding[T Widget] struct {
	DefaultWidget
	// contains filtered or unexported fields
}

func (*WidgetWithPadding[T]) Build

func (w *WidgetWithPadding[T]) Build(context *Context, adder *ChildAdder) error

func (*WidgetWithPadding[T]) Layout

func (w *WidgetWithPadding[T]) Layout(context *Context, widgetBounds *WidgetBounds, layouter *ChildLayouter)

func (*WidgetWithPadding[T]) Measure

func (w *WidgetWithPadding[T]) Measure(context *Context, constraints Constraints) image.Point

func (*WidgetWithPadding[T]) SetPadding

func (w *WidgetWithPadding[T]) SetPadding(padding Padding)

func (*WidgetWithPadding[T]) Widget

func (w *WidgetWithPadding[T]) Widget() T

type WidgetWithSize

type WidgetWithSize[T Widget] struct {
	DefaultWidget
	// contains filtered or unexported fields
}

func (*WidgetWithSize[T]) Build

func (w *WidgetWithSize[T]) Build(context *Context, adder *ChildAdder) error

func (*WidgetWithSize[T]) Layout

func (w *WidgetWithSize[T]) Layout(context *Context, widgetBounds *WidgetBounds, layouter *ChildLayouter)

func (*WidgetWithSize[T]) Measure

func (w *WidgetWithSize[T]) Measure(context *Context, constraints Constraints) image.Point

func (*WidgetWithSize[T]) SetFixedHeight

func (w *WidgetWithSize[T]) SetFixedHeight(height int)

func (*WidgetWithSize[T]) SetFixedSize

func (w *WidgetWithSize[T]) SetFixedSize(size image.Point)

func (*WidgetWithSize[T]) SetFixedWidth

func (w *WidgetWithSize[T]) SetFixedWidth(width int)

func (*WidgetWithSize[T]) SetIntrinsicSize

func (w *WidgetWithSize[T]) SetIntrinsicSize()

func (*WidgetWithSize[T]) SetMeasureFunc

func (w *WidgetWithSize[T]) SetMeasureFunc(f func(context *Context, constraints Constraints) image.Point)

func (*WidgetWithSize[T]) Widget

func (w *WidgetWithSize[T]) Widget() T

Directories

Path Synopsis
example
counter command
drawer command
expander command
gallery command
gridlayout command
panels command
todo command
internal
vettool command

Jump to

Keyboard shortcuts

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