x11ui

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 33 Imported by: 1

README

x11ui

Simple UI framework using github.com/BurntSushi/xgbutil package using Go.

Look for documentation here https://godoc.org/github.com/wiless/x11ui

ScreenShot

Sample Usage

IMAGE ALT TEXT HERE

Theme Usage

Here's how you can use the new theme functions:

1. Setting a Default Theme:

The init() function in theme.go already sets CurrentTheme to DarkTheme by default. You can change this in main.go or any other initialization point.

package main

import (
	"github.com/wiless/x11ui"
	"image/color"
)

func main() {
	app := x11ui.NewApplication("My App", 800, 600, false, false)

	// To use the default LightTheme:
	x11ui.UseLightTheme()

	// To use a DarkTheme with a custom accent color (e.g., red):
	accentColor := color.RGBA{R: 255, A: 255} // Red
	x11ui.SetTheme(x11ui.DarkThemeWithAccent(accentColor))

	// To use a LightTheme with a custom accent color (e.g., blue):
	// accentColor := color.RGBA{B: 255, A: 255} // Blue
	// x11ui.SetTheme(x11ui.LightThemeWithAccent(accentColor))

	// ... rest of your application setup
	app.Show()
}

2. Switching Themes at Runtime:

You can switch themes dynamically using x11ui.SetTheme(), x11ui.UseDarkTheme(), or x11ui.UseLightTheme(). After changing the theme, you'll typically need to trigger a redraw of your UI elements to apply the new colors.

// Example: A button to toggle between dark and light themes
func createThemeToggleButton(app *x11ui.Application) *x11ui.Window {
	btn := app.AddButton("Toggle Theme")
	btn.OnClick(func() {
		if x11ui.CurrentTheme == x11ui.DarkTheme {
			x11ui.UseLightTheme()
		} else {
			x11ui.UseDarkTheme()
		}
		// You might need to explicitly redraw all widgets or the main application window
		// depending on how your UI is structured.
		app.AppWin().RePaint(x11ui.StateNormal) // Repaint the main window
		// For individual widgets, you might need to call their RePaint methods
		// or have a mechanism to propagate theme changes.
	})
	return btn
}

3. Using Accent Themes:

The DarkThemeWithAccent(color) and LightThemeWithAccent(color) functions allow you to customize the theme with a specific accent color. The accent color's hue will be used to derive complementary colors for elements like foreground, bar, and checked checkboxes.

// Example: Create a dark theme with a vibrant purple accent
purpleAccent := color.RGBA{R: 128, G: 0, B: 128, A: 255}
customDarkTheme := x11ui.DarkThemeWithAccent(purpleAccent)
x11ui.SetTheme(customDarkTheme)

// Example: Create a light theme with a bright orange accent
orangeAccent := color.RGBA{R: 255, G: 165, B: 0, A: 255}
customLightTheme := x11ui.LightThemeWithAccent(orangeAccent)
x11ui.SetTheme(customLightTheme)

Important Considerations:

  • Redrawing Widgets: When you change x11ui.CurrentTheme, existing widgets do not automatically update their colors. You need to explicitly trigger a repaint or a theme application method for each widget that needs to reflect the new theme. The RePaint method on Window (and thus on Widget since Window is embedded) can be used for this.
  • Theme Structure: The Theme struct defines all the colors. When creating custom themes, ensure all necessary color fields are set.
  • go-colorful: The theme generation uses go-colorful for color manipulation. If you create your own custom themes, you can leverage colorful.Hsl(), colorful.BlendLuvLCh(), and Clamped() for sophisticated color generation.

Documentation

Overview

Copyright 2010 The draw2d Authors. All rights reserved. created: 21/11/2010 by Laurent Le Goff Package geometry draws some geometric tests. Modifed by : wiless

Index

Constants

This section is empty.

Variables

View Source
var Black = color.RGBA{0, 0, 0, 255}
View Source
var DEBUG_LEVEL = 0
View Source
var DarkGray = color.RGBA{20, 20, 20, 255}
View Source
var DarkGreen = xgraphics.BGRA{0, 150, 0, 255}
View Source
var Green = color.RGBA{0, 255, 0, 255}
View Source
var LightGray = xgraphics.BGRA{200, 200, 200, 255}
View Source
var LightGreen = xgraphics.BGRA{0, 50, 0, 255}
View Source
var White = color.RGBA{255, 255, 255, 255}

Functions

func Arc

func Arc(gc draw2d.GraphicContext, xc, yc, width, height float64)

Arc draws an arc with a positive angle (clockwise)

func ArcNegative

func ArcNegative(gc draw2d.GraphicContext, xc, yc, width, height float64)

ArcNegative draws an arc with a negative angle (anti clockwise).

func Bubble

func Bubble(gc draw2d.GraphicContext, x, y, width, height float64)

Bubble draws a text balloon.

func CubicCurve

func CubicCurve(gc draw2d.GraphicContext, x, y, width, height float64)

CubicCurve draws a cubic curve with its control points.

func CurveRectangle

func CurveRectangle(gc draw2d.GraphicContext, x0, y0,
	rectWidth, rectHeight float64, stroke, fill color.Color)

CurveRectangle draws a rectangle with bezier curves (not rounded rectangle).

func Dash

func Dash(gc draw2d.GraphicContext, x, y, width, height float64)

Dash draws a line with a dash pattern

func Draw

func Draw(gc draw2d.GraphicContext, width, height float64)

Draw all figures in a nice 4x3 grid.

func DrawDummy

func DrawDummy(w *Window, s WidgetState)

func FillString

func FillString(gc draw2d.GraphicContext, x, y, width, height float64)

FillString draws a filled and stroked string.

func FillStroke

func FillStroke(gc draw2d.GraphicContext, x, y, width, height float64)

FillStroke first fills and afterwards strokes a path.

func FillStyle

func FillStyle(gc draw2d.GraphicContext, x, y, width, height float64)

FillStyle demonstrates the difference between even odd and non zero winding rule.

func GetIRect

func GetIRect(w, h int) image.Rectangle

func PathTransform

func PathTransform(gc draw2d.GraphicContext, x, y, width, height float64)

PathTransform scales a path differently in horizontal and vertical direction.

func RandomGraph

func RandomGraph(r image.Rectangle) *image.RGBA

RandomGraph generates an image with a random sine wave graph.

func RegisterFont added in v1.0.2

func RegisterFont(path, name string)

Register Fonts

func SetResourcePath

func SetResourcePath(path, fontName string) error

SetResourcePath sets the path for UI resources like fonts The path parameter is the directory containing the font files.

func SetTheme added in v1.1.1

func SetTheme(newTheme *Theme)

SetTheme allows updating the global theme at runtime. To apply the new theme to existing widgets, they would need to be explicitly redrawn or have their LoadTheme/ApplyTheme methods called.

func SplitSubN

func SplitSubN(s string, n int) []string

func Star

func Star(gc draw2d.GraphicContext, x, y, width, height float64)

Star draws many lines from a center.

func StrokeBorder

func StrokeBorder(img *xgraphics.Image, clr xgraphics.BGRA, margin, width int)

func StrokeBorderImg

func StrokeBorderImg(img *image.RGBA, clr color.Color, margin, width int)

func TrimValues added in v1.0.2

func TrimValues(v float64) float64

func UseDarkTheme added in v1.1.1

func UseDarkTheme()

UseDarkTheme sets the global theme to the predefined DarkTheme.

func UseLightTheme added in v1.1.1

func UseLightTheme()

UseLightTheme sets the global theme to the predefined LightTheme.

func XRectToImageRect

func XRectToImageRect(r xrect.Rect) image.Rectangle

Types

type Alignment added in v1.1.1

type Alignment int

Alignment specifies the position relative to a parent.

const (
	AlignNone Alignment = iota
	AlignTopLeft
	AlignTopCenter
	AlignTopRight
	AlignMiddleLeft
	AlignCenter
	AlignMiddleRight
	AlignBottomLeft
	AlignBottomCenter
	AlignBottomRight
)

type Application

type Application struct {
	NWindows int
	Childs   []*xwindow.Window

	KeyMaps   map[string]Handler
	ClickMaps map[xproto.Window]OnClickFn

	Debug bool
	Dark  bool
	// contains filtered or unexported fields
}

Application represents an X11 application, managing windows and events.

func NewApp

func NewApp(fullscreen bool, width, height int) *Application

NewApp creates a new application with a default title and specified dimensions.

func NewApplication

func NewApplication(title string, width, height int, resizeable, fullApplication bool) *Application

NewApplication creates a new X11 application with the given title, dimensions, and resize/fullscreen options.

func (*Application) AddButton

func (a *Application) AddButton(caption string, geo ...int) *Window

func (*Application) AddToggleBtn

func (a *Application) AddToggleBtn(caption string, geo ...int) *Window

func (*Application) AppWin

func (a *Application) AppWin() *Window

AppWin returns the main application window.

func (*Application) AutoLayout

func (a *Application) AutoLayout(l LayoutDirection, newpos ...int)

AutoLayout sets the automatic layout direction for new child windows.

func (*Application) Close

func (s *Application) Close()

Close terminates the application.

func (*Application) DefaultKeys

func (s *Application) DefaultKeys(enable bool)

DefaultKeys enables or disables default keybindings for the application (e.g., 'q' for close, 'f' for fullscreen).

func (*Application) Empty

func (s *Application) Empty() *Window

Empty returns an empty Window associated with the application's root window.

func (*Application) FullScreen

func (s *Application) FullScreen()

func (*Application) Height

func (a *Application) Height() int

Height returns the height of the application's screen in pixels.

func (*Application) Hide added in v1.0.2

func (s *Application) Hide()

https://specifications.freedesktop.org/wm-spec/1.3/ar01s05.html

func (*Application) InvertBackGround

func (s *Application) InvertBackGround()

func (*Application) Maximize added in v1.0.2

func (s *Application) Maximize()

func (*Application) NewChildWindow

func (a *Application) NewChildWindow(title string, dims ...int) *Window

func (*Application) NewContainer added in v1.1.1

func (a *Application) NewContainer(layout LayoutDirection, dims ...int) *Container

func (*Application) NewFloatingWindow

func (s *Application) NewFloatingWindow(title string, dims ...int) *Window

func (*Application) RegisterGlobalKey

func (s *Application) RegisterGlobalKey(keyname string, fn Handler) bool

RegisterGlobalKey registers a key to be handled globally by the application. This will grab the keyboard, meaning no other application will receive keyboard input.

func (*Application) RegisterKey

func (s *Application) RegisterKey(keyname string, fn Handler) bool

RegisterKey registers a key with a function to be handled by the application.

func (*Application) Restore added in v1.0.2

func (s *Application) Restore()

func (*Application) SetDefaultKeys

func (a *Application) SetDefaultKeys()

func (*Application) SetLayoutPadding added in v1.1.1

func (a *Application) SetLayoutPadding(dx, dy int)

func (*Application) SetLayoutSpacing

func (a *Application) SetLayoutSpacing(dx, dy int)

func (*Application) Show

func (s *Application) Show()

Show starts the application's event loop and displays the main window.

func (*Application) Width

func (a *Application) Width() int

Width returns the width of the application's screen in pixels.

func (*Application) X

func (a *Application) X() *xgbutil.XUtil

X returns the underlying *xgbutil.XUtil connection for the application.

func (*Application) XWin

func (s *Application) XWin() *xwindow.Window

XWin returns the underlying *xwindow.Window of the application's main window.

type Button

type Button struct {
	*Window
}

type ButtonWidget added in v1.1.1

type ButtonWidget struct {
	*Widget
	// contains filtered or unexported fields
}

ButtonWidget represents a clickable button UI element.

func NewButtonWidget added in v1.1.1

func NewButtonWidget(title string, p *Window, dims ...int) *ButtonWidget

NewButtonWidget creates a new ButtonWidget.

func (*ButtonWidget) IsChecked added in v1.1.1

func (bw *ButtonWidget) IsChecked() bool

IsChecked returns true if the toggle button is currently checked.

func (*ButtonWidget) LoadTheme added in v1.1.1

func (bw *ButtonWidget) LoadTheme(str string)

func (*ButtonWidget) Paint added in v1.1.1

func (bw *ButtonWidget) Paint()

SetLabel sets the text displayed on the button.

func (*ButtonWidget) SetChecked added in v1.1.1

func (bw *ButtonWidget) SetChecked(checked bool)

SetChecked sets the checked state of a toggle button.

func (*ButtonWidget) SetFontSize added in v1.1.1

func (bw *ButtonWidget) SetFontSize(size float64)

SetFontSize sets the font size of the button's text.

func (*ButtonWidget) SetKeybFn added in v1.1.1

func (bw *ButtonWidget) SetKeybFn(fn func(key string))

SetKeybFn sets the function to be called when a keyboard event is received.

func (*ButtonWidget) SetLabel added in v1.1.1

func (bw *ButtonWidget) SetLabel(lbl string)

func (*ButtonWidget) SetOnClick added in v1.1.1

func (bw *ButtonWidget) SetOnClick(fn func())

SetOnClick sets the function to be called when the button is clicked.

func (*ButtonWidget) SetTitle added in v1.1.1

func (bw *ButtonWidget) SetTitle(title string)

SetTitle sets the title of the button. This will update the visible label.

func (*ButtonWidget) SetToggle added in v1.1.1

func (bw *ButtonWidget) SetToggle(toggle bool)

SetToggle makes the button a toggle button.

type CheckBox

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

func NewCheckBox

func NewCheckBox(title string, p *Window, dims ...int) *CheckBox

func (*CheckBox) CopyPaste

func (c *CheckBox) CopyPaste(r image.Rectangle)

func (*CheckBox) SetChecked added in v1.1.1

func (c *CheckBox) SetChecked(checked bool)

type Container added in v1.1.1

type Container struct {
	Window // Embed the existing Window struct directly
	// contains filtered or unexported fields
}

func (*Container) AddButton added in v1.1.1

func (c *Container) AddButton(caption string, geo ...int) *ButtonWidget

func (*Container) AddToggleBtn added in v1.1.1

func (c *Container) AddToggleBtn(caption string, geo ...int) *ButtonWidget

func (*Container) AddWidget added in v1.1.1

func (c *Container) AddWidget(widget WindowProvider)

func (*Container) RelayoutChildren added in v1.1.1

func (c *Container) RelayoutChildren()

func (*Container) SetFontSize added in v1.1.1

func (c *Container) SetFontSize(size float64)

func (*Container) SetSpacing added in v1.1.1

func (c *Container) SetSpacing(dx, dy int)

type FactorWidgets

type FactorWidgets interface {
	Move(x, y int)
}

type FontSizeSetter added in v1.1.1

type FontSizeSetter interface {
	SetFontSize(float64)
}

FontSizeSetter interface for widgets that can have their font size set.

type Handler

type Handler func()

Handler is a function type for event handlers.

type HandlerFunctions

type HandlerFunctions struct {
	ClkAdvFn    func(w *Widget, x, y int)
	ClkFn       func()
	HoverFn     func()
	LeaveFn     func()
	KeybFn      func(key string)
	DragStartFn func(w *Widget, global, local image.Point) bool
	DragFn      func(w *Widget, global, local image.Point) bool
	DragEndFn   func(w *Widget, global, local image.Point) bool
	EnableHover bool
}

type ImgButton

type ImgButton struct {
	*Widget
	// contains filtered or unexported fields
}

func NewImgButton

func NewImgButton(title string, p *Window, dims ...int) *ImgButton

func (*ImgButton) DrawImage

func (t *ImgButton) DrawImage(img image.Image)

func (*ImgButton) DrawImageEx added in v1.1.1

func (t *ImgButton) DrawImageEx(img image.Image, eraseBg bool)

func (*ImgButton) DrawJpg

func (t *ImgButton) DrawJpg(jpgdata []byte)

func (*ImgButton) ResizeWidget added in v1.1.1

func (t *ImgButton) ResizeWidget(w, h int)

func (*ImgButton) SetImageAlign added in v1.1.1

func (t *ImgButton) SetImageAlign(alignment Alignment)

func (*ImgButton) SetPicture

func (i *ImgButton) SetPicture(fname string)

type Label

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

func NewLabel

func NewLabel(title string, p *Window, dims ...int) *Label

func (*Label) AutoResize

func (l *Label) AutoResize(auto bool) *Label

func (*Label) InvertColors added in v1.1.1

func (l *Label) InvertColors()

func (*Label) SetAlignMode

func (l *Label) SetAlignMode(align TextAlign) *Label

func (*Label) SetBackground

func (l *Label) SetBackground(c color.Color)

func (*Label) SetFontSize

func (l *Label) SetFontSize(size float64) *Label

func (*Label) SetLabel

func (l *Label) SetLabel(lbl string)

func (*Label) SetTextColor added in v1.1.1

func (l *Label) SetTextColor(c color.Color)

type Layout

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

func CreateLayout

func CreateLayout(x, y, w, h int) *Layout

func NewLayout

func NewLayout(w *Window, x0, y0 int) *Layout

func (*Layout) AddRegion

func (l *Layout) AddRegion(r RegionPainter) *Layout

func (*Layout) AddRegionAt

func (l *Layout) AddRegionAt(r RegionPainter, x, y int) *Layout

func (*Layout) DrawOnWidget

func (l *Layout) DrawOnWidget(w *Widget)

func (*Layout) DrawOnWindow

func (l *Layout) DrawOnWindow(w *Window)

func (*Layout) ImageRect

func (l *Layout) ImageRect() image.Rectangle

func (*Layout) Origin

func (l *Layout) Origin() image.Point

func (*Layout) Resize

func (l *Layout) Resize(x, y, w, h int)

func (*Layout) SetRegion

func (l *Layout) SetRegion(indx int, r RegionPainter)

func (*Layout) Size

func (l *Layout) Size() image.Point

type LayoutDirection

type LayoutDirection int

LayoutDirection specifies the direction for automatic widget layout.

const (
	// LayoutNone indicates no automatic layout direction.
	LayoutNone LayoutDirection = iota
	// LayoutHor indicates horizontal layout.
	LayoutHor
	// LayoutVer indicates vertical layout.
	LayoutVer
)

type OnClickFn

type OnClickFn func(w *Window, x, y int)

OnClickFn defines the signature for advanced click handlers that receive window and coordinate information.

type Pen

type Pen struct {
	color.Color
	Width int
}

type ProgressBar

type ProgressBar struct {
	ShowGrid bool
	NGrids   float64
	// contains filtered or unexported fields
}

func NewProgressBar

func NewProgressBar(title string, p *Window, dims ...int) *ProgressBar

func (*ProgressBar) FmtString

func (p *ProgressBar) FmtString() string

func (*ProgressBar) Margin

func (p *ProgressBar) Margin() float64

func (*ProgressBar) Parent

func (p *ProgressBar) Parent() *Window

func (*ProgressBar) ResetFmtString

func (p *ProgressBar) ResetFmtString()

func (*ProgressBar) SetBackGroundColor

func (p *ProgressBar) SetBackGroundColor(bc color.Color)

func (*ProgressBar) SetBarColor

func (p *ProgressBar) SetBarColor(bc color.Color)

func (*ProgressBar) SetBorderWidth

func (p *ProgressBar) SetBorderWidth(bw float64)

func (*ProgressBar) SetDisplayScale

func (p *ProgressBar) SetDisplayScale(s float64)

func (*ProgressBar) SetFmtString

func (p *ProgressBar) SetFmtString(s string)

func (*ProgressBar) SetMargin

func (p *ProgressBar) SetMargin(m float64)

func (*ProgressBar) SetTextColor

func (p *ProgressBar) SetTextColor(tc color.Color)

func (*ProgressBar) SetValue

func (p *ProgressBar) SetValue(v float64)

Sets the value in the fraction 0 to 1

func (ProgressBar) Value

func (p ProgressBar) Value() float64

return the value in the scale 0 to 1

func (*ProgressBar) Widget

func (p *ProgressBar) Widget() *Window

func (*ProgressBar) X

func (p *ProgressBar) X() *xgbutil.XUtil

type Property

type Property struct {
	X, Y int
	W, H int
}

Property represents geometric properties of a window for animation.

func (Property) Delta

func (p Property) Delta(src Property) (dp Property)

Delta returns the difference between two Property structs.

func (*Property) Scale

func (p *Property) Scale(steps int)

Scale scales the property values. (Currently a stub)

func (*Property) Step

func (p *Property) Step(dp Property)

Step is a placeholder for a step function in animation. (Currently a stub)

type Rect

type Rect struct {
	X, Y          int
	Width, Height int
}

func XRectToRect

func XRectToRect(r xrect.Rect) Rect

func (*Rect) Center

func (r *Rect) Center() (x, y int)

func (*Rect) CenterX

func (r *Rect) CenterX() int

func (*Rect) CenterY

func (r *Rect) CenterY() int

func (*Rect) Grow

func (r *Rect) Grow(dw, dh int) *Rect

func (*Rect) ImageRect

func (r *Rect) ImageRect() image.Rectangle

func (*Rect) MoveTo

func (r *Rect) MoveTo(x, y int) *Rect

func (*Rect) ReSize

func (r *Rect) ReSize(w, h int) *Rect

func (*Rect) ShiftBy

func (r *Rect) ShiftBy(dx, dy int) *Rect

func (*Rect) ShiftDown

func (r *Rect) ShiftDown(dy int) *Rect

func (*Rect) ShiftRight

func (r *Rect) ShiftRight(dx int) *Rect

func (*Rect) WithPadding added in v1.1.1

func (r *Rect) WithPadding(dx, dy int) Rect

type Region

type Region struct {
	Rect
	BG      color.Color
	FG      color.Color
	TC      color.Color
	Margin  float64
	PaintFn RegionPainterFn
}

func NewRegion

func NewRegion(r Rect) Region

type RegionPainter

type RegionPainter interface {
	GetRegion() *Region
	// SetRegion(*Region)
	PaintRegion() *image.RGBA
}

type RegionPainterFn

type RegionPainterFn func() *image.RGBA

type ScrollView

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

func NewScrollView

func NewScrollView(title string, p *Window, dims ...int) *ScrollView

func (*ScrollView) AddWidget

func (s *ScrollView) AddWidget(w *Widget)

func (*ScrollView) IsVisible

func (s *ScrollView) IsVisible() bool

returns if the scrollbars are visible

func (*ScrollView) ScrollChilds

func (s *ScrollView) ScrollChilds(dx, dy int)

func (*ScrollView) ScrollDown

func (s *ScrollView) ScrollDown()

func (*ScrollView) ScrollUp

func (s *ScrollView) ScrollUp()

func (*ScrollView) SetBackground

func (s *ScrollView) SetBackground(c color.Color)

func (*ScrollView) SetMaxSteps

func (s *ScrollView) SetMaxSteps(maxsteps int)

func (*ScrollView) SetStepSize

func (s *ScrollView) SetStepSize(step int)

func (*ScrollView) ShowScrollBars

func (s *ScrollView) ShowScrollBars(show bool)

func (*ScrollView) View

func (s *ScrollView) View() *Window

type Slider added in v1.0.2

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

func NewSlider added in v1.0.2

func NewSlider(title string, p *Window, dims ...int) *Slider

func (*Slider) AddListeners added in v1.0.2

func (s *Slider) AddListeners()

func (*Slider) SetMaxValue added in v1.0.2

func (s *Slider) SetMaxValue(v float64)

func (*Slider) SetStepSize added in v1.0.2

func (s *Slider) SetStepSize(v float64)

func (*Slider) SetValue added in v1.0.2

func (s *Slider) SetValue(v float64)

func (*Slider) Value added in v1.0.2

func (s *Slider) Value() float64

type TextAlign added in v1.1.1

type TextAlign int
const (
	TextAlignTopLeft TextAlign = iota
	TextAlignHVCenter
	TextAlignHCenter
	TextAlignVCenter
)

type TextBox

type TextBox struct {
	*Widget
	// contains filtered or unexported fields
}

func NewTextBox

func NewTextBox(title string, p *Window, dims ...int) *TextBox

NewTextBox creates a child TextBox widget in the roots of Window p

func (*TextBox) AddRulers

func (t *TextBox) AddRulers()

func (*TextBox) AppendLine

func (t *TextBox) AppendLine(str string)

func (*TextBox) InvertColors added in v1.1.1

func (t *TextBox) InvertColors()

func (*TextBox) SetFontSize added in v1.1.1

func (t *TextBox) SetFontSize(size float64) *TextBox

func (*TextBox) SetReadOnly

func (t *TextBox) SetReadOnly(readonly bool)

func (*TextBox) SetText

func (t *TextBox) SetText(txt string)

func (*TextBox) SetTextColor added in v1.1.1

func (t *TextBox) SetTextColor(c color.Color)

func (*TextBox) ShowIBeam

func (t *TextBox) ShowIBeam()

type Theme added in v1.1.1

type Theme struct {
	BackgroundColor        color.Color
	ForegroundColor        color.Color
	LineColor              color.Color
	TextColor              color.Color
	BarColor               color.Color
	CheckboxCheckedColor   color.Color
	CheckboxUncheckedColor color.Color
	CheckboxBorderColor    color.Color
	BaseHue                float64 // Base hue for generating color variations
}

Theme holds all the color definitions for the UI.

var CurrentTheme *Theme

CurrentTheme is the global instance of the active theme.

var DarkTheme *Theme

Predefined themes

var LightTheme *Theme

func DarkThemeWithAccent added in v1.1.1

func DarkThemeWithAccent(accent color.Color) *Theme

DarkThemeWithAccent generates a dark theme with a specified accent color.

func LightThemeWithAccent added in v1.1.1

func LightThemeWithAccent(accent color.Color) *Theme

LightThemeWithAccent generates a light theme with a specified accent color.

type Widget

type Widget struct {
	xrect.Rect

	*Layout

	/// Handlers
	HandlerFunctions
	// contains filtered or unexported fields
}

func NewWidget

func NewWidget(X *xgbutil.XUtil, p *Window, t string, dims ...int) *Widget

wrapper changed

func WidgetFactory

func WidgetFactory(p *Window, dims ...int) *Widget

func (*Widget) Align added in v1.1.1

func (w *Widget) Align(alignment Alignment)

func (*Widget) AttachHandlers

func (w *Widget) AttachHandlers() *Widget

func (*Widget) Close

func (w *Widget) Close()

func (*Widget) Context

func (w *Widget) Context() *draw2dimg.GraphicContext

func (*Widget) CreateChild

func (ww *Widget) CreateChild(dims ...int) *Widget

func (*Widget) GetRect

func (w *Widget) GetRect() Rect

func (*Widget) ID

func (w *Widget) ID() xproto.Window

func (*Widget) InvertColors added in v1.1.1

func (w *Widget) InvertColors()

InvertColors swaps the background and text colors of the widget.

func (*Widget) LoadTheme

func (w *Widget) LoadTheme(str string)

func (*Widget) Move added in v1.1.1

func (w *Widget) Move(x, y int)

func (*Widget) Paint added in v1.1.1

func (w *Widget) Paint()

func (*Widget) PaintRegions

func (w *Widget) PaintRegions()

func (*Widget) RePaint

func (w *Widget) RePaint()

func (*Widget) SetBackground

func (w *Widget) SetBackground(c color.Color)

func (*Widget) SetChildrenFontSize added in v1.1.1

func (w *Widget) SetChildrenFontSize(fsize float64)

func (*Widget) SetFontSize

func (w *Widget) SetFontSize(fsize float64)

func (*Widget) SetModal

func (w *Widget) SetModal(modal bool)

func (*Widget) SetTextColor added in v1.1.1

func (w *Widget) SetTextColor(c color.Color)

func (*Widget) SetTitle

func (w *Widget) SetTitle(title string)

func (*Widget) SetX

func (w *Widget) SetX(X *xgbutil.XUtil)

func (*Widget) UpdateCanvas

func (w *Widget) UpdateCanvas()

func (*Widget) Win

func (w *Widget) Win() *Window

type WidgetState

type WidgetState int

WidgetState represents the visual state of a widget.

const (
	StateNormal WidgetState = iota
	StateHovered
	StatePressed
	StateReleased
	StateChecked // For toggle buttons
	StateSpecial
	StateHoveredChecked
)

type Window

type Window struct {
	//parent *xwindow.Window
	*xwindow.Window

	Rect
	// contains filtered or unexported fields
}

Window represents an X11 window with UI capabilities.

func NewButton

func NewButton(title string, p *Window, dims ...int) *Window

func NewToggleButton

func NewToggleButton(title string, p *Window, dims ...int) *Window

func (*Window) Align added in v1.1.1

func (w *Window) Align(alignment Alignment)

func (*Window) Animate

func (w *Window) Animate(t int)

Animate performs a simple resize animation.

func (*Window) AnimateProperty

func (w *Window) AnimateProperty(d time.Duration, start, stop Property)

AnimateProperty animates a window's properties over a duration. (Currently a stub)

func (*Window) Click

func (w *Window) Click()

Click programmatically triggers the click handlers associated with the window.

func (*Window) CreateRawImage

func (w *Window) CreateRawImage(x, y, ww, hh int) *image.RGBA

CreateRawImage creates a new RGBA image associated with the window for direct drawing.

func (*Window) Draw

func (w *Window) Draw(X *xgbutil.XUtil, e xevent.ExposeEvent)

Draw handles expose events to redraw parts of the window.

func (*Window) Filler

func (w *Window) Filler(x, y int) xgraphics.BGRA

Filler is a function used to fill the window background with a pattern.

func (*Window) Hide added in v1.1.1

func (w *Window) Hide()

func (*Window) IsChecked

func (w *Window) IsChecked() bool

IsChecked returns the checked state of the window if it's a checkbox.

func (*Window) Move added in v1.1.1

func (w *Window) Move(x, y int)

func (*Window) OnClick

func (w *Window) OnClick(fn func())

OnClick sets a simple click handler for the window.

func (*Window) OnClickAdv

func (w *Window) OnClickAdv(fn OnClickFn)

OnClickAdv sets an advanced click handler that receives the window and click coordinates.

func (*Window) OnMove added in v1.1.1

func (w *Window) OnMove(fn func(x, y int))

func (*Window) OnMoveComplete added in v1.1.1

func (w *Window) OnMoveComplete(fn func(x, y int))

func (*Window) OnResizeComplete added in v1.1.1

func (w *Window) OnResizeComplete(fn func(w, h int))

func (*Window) OnSizeChange added in v1.1.1

func (w *Window) OnSizeChange(fn func(w, h int))

func (*Window) Paint added in v1.1.1

func (w *Window) Paint()

func (*Window) PaintOnce

func (w *Window) PaintOnce()

PaintOnce draws the window's background and label a single time.

func (*Window) Plot

func (w *Window) Plot()

Plot draws a random graph on the window. Used for demonstration.

func (Window) RawImage

func (w Window) RawImage() *image.RGBA

RawImage returns the raw image buffer of the window.

func (*Window) ReDrawImage

func (w *Window) ReDrawImage()

ReDrawImage redraws the window from its raw image buffer.

func (*Window) Reparent added in v1.1.1

func (w *Window) Reparent(newParent xproto.Window, x, y int) error

func (*Window) Resize added in v1.1.1

func (w *Window) Resize(width, height int)

func (*Window) SetBGcolor

func (w *Window) SetBGcolor(c color.Color)

SetBGcolor sets the background color of the window using a color.Color and redraws it.

func (*Window) SetBackGround

func (w *Window) SetBackGround(c colorful.Color)

SetBackGround sets the background color of the window using a colorful.Color.

func (*Window) SetMargin

func (w *Window) SetMargin(m float64)

SetMargin sets the margin for the window content.

func (*Window) SetTitle

func (w *Window) SetTitle(t string)

SetTitle sets the title of the window.

func (*Window) Show added in v1.1.1

func (w *Window) Show()

func (*Window) Title

func (w *Window) Title() string

Title returns the title of the window.

func (*Window) Toggle

func (w *Window) Toggle()

Toggle changes the checked state of the window if it's a checkbox.

func (*Window) ToggleVisibility added in v1.1.1

func (w *Window) ToggleVisibility()

func (*Window) UpdatePlot

func (w *Window) UpdatePlot(img image.Image)

UpdatePlot updates the window content from an image.

func (*Window) Win added in v1.1.1

func (w *Window) Win() *Window

func (*Window) X

func (w *Window) X() *xgbutil.XUtil

X returns the underlying *xgbutil.XUtil connection.

func (*Window) XProtoWin

func (w *Window) XProtoWin() xproto.Window

XProtoWin returns the X protocol window ID.

func (*Window) XWin

func (w *Window) XWin() *xwindow.Window

XWin returns the underlying *xwindow.Window.

type WindowProvider added in v1.1.1

type WindowProvider interface {
	Win() *Window
	Paint()
}

WindowProvider interface defines a method to retrieve the underlying *Window.

Directories

Path Synopsis
samples
app1 command
app2 command
app3 command
sample code to test progressbar
sample code to test progressbar
autolayout command
label command
layout command
scrollview command
slider command
sample code to test progressbar
sample code to test progressbar
textbox command
sample code to test progressbar
sample code to test progressbar
transparent_bg command

Jump to

Keyboard shortcuts

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