1// Package nefergui is a pure-Go immediate-mode GUI renderer styled with a
2// bounded CSS dialect (see docs/css.md). It draws with Vulkan into DMA-BUF
3// buffers and imports no Wayland library: the application owns the Wayland
4// client (for example with github.com/bnema/neferclient) and feeds events to a
5// Renderer.
6//
7// A view function builds each frame from a Frame; Frame and its Node handles
8// are valid only during that call. Key identifies a child among its siblings
9// across frames; without a key, position and type determine identity. ID is
10// CSS metadata, not frame identity.
11//
12// The frame tree, controls, editors and input routing are implemented in
13// internal/ui; this package is the public facade and re-exports those types.
14//
15// Builds support CGO_ENABLED=0. At runtime NeferGUI requires libvulkan.so.1 and
16// a GPU with DMA-BUF export and DRM syncobj timelines. See docs/runtime.md and
17// docs/troubleshooting.md.
18package nefergui
19
20import "github.com/bnema/nefergui/internal/ui"
21
22// Frame is valid only during one call to the view function. Root builds the
23// application element; Diagnostics reports identity problems in debug builds.
24// Alias methods are listed by go doc github.com/bnema/nefergui/internal/ui.Frame.
25type Frame = ui.Frame
26
27// Node is an ephemeral handle into the current frame. Do not retain it between
28// frames. Container methods (Box, Row, Column, Stack, Scroll, Header, Nav,
29// Main, Section, Aside, Footer, Element) return child nodes; control methods
30// (Button, Checkbox, Radio, Slider, Input, Textarea, Text, Heading, Image,
31// Icon, Separator, Spacer) declare controls. Interactive controls return event
32// snapshots.
33// Alias methods are listed by go doc github.com/bnema/nefergui/internal/ui.Node.
34type Node = ui.Node
35
36// ButtonEvent is an immutable snapshot queried with Activated.
37// Alias methods are listed by go doc github.com/bnema/nefergui/internal/ui.ButtonEvent.
38type ButtonEvent = ui.ButtonEvent
39
40// EditEvent is an immutable snapshot queried with Changed and Submitted.
41// Alias methods are listed by go doc github.com/bnema/nefergui/internal/ui.EditEvent.
42type EditEvent = ui.EditEvent
43
44// ChangeEvent is an immutable snapshot queried with Changed.
45// Alias methods are listed by go doc github.com/bnema/nefergui/internal/ui.ChangeEvent.
46type ChangeEvent = ui.ChangeEvent
47
48// Option families are sealed: ContainerOption, ButtonOption, EditOption,
49// ValueOption and HeadingOption accept the common CSS options (Key, ID,
50// Class, Inline) plus the control-specific options listed on each function.
51type (
52 ContainerOption = ui.ContainerOption
53 ButtonOption = ui.ButtonOption
54 EditOption = ui.EditOption
55 ValueOption = ui.ValueOption
56 HeadingOption = ui.HeadingOption
57)
58
59// commonOption belongs to every option family; disabledOption to every
60// interactive control family. Both are concrete internal types, aliased so
61// the constructors below can return them without a second implementation.
62type (
63 commonOption = ui.CommonOption
64 disabledOption = ui.DisabledOption
65)
66
67// Key identifies an element among its siblings across frames.
68func Key(key string) commonOption { return ui.Key(key) }
69
70// ID sets the CSS ID; it does not affect frame identity.
71func ID(id string) commonOption { return ui.ID(id) }
72
73// Class adds a CSS class.
74func Class(class string) commonOption { return ui.Class(class) }
75
76// Inline applies inline CSS declarations.
77func Inline(src string) commonOption { return ui.Inline(src) }
78
79// Disabled blocks focus and interaction on an interactive control.
80func Disabled(v bool) disabledOption { return ui.Disabled(v) }
81
82// Level sets the accessibility heading level (1 through 6).
83func Level(level int) HeadingOption { return ui.Level(level) }
84
85// Placeholder sets the text shown in an empty editor.
86func Placeholder(v string) EditOption { return ui.Placeholder(v) }
87
88// Password masks displayed editor text and blocks copy and cut.
89func Password(v bool) EditOption { return ui.Password(v) }
90
91// Rect is an integer logical-pixel rectangle in surface coordinates, used by
92// Frame.SetInputRects and Output.InputRects.
93type Rect = ui.Rect
94
95// InputKind classifies an Input; Modifiers is a bit set of held modifiers.
96type (
97 InputKind = ui.InputKind
98 Modifiers = ui.Modifiers
99)
100
101const (
102 InputPointerMotion = ui.InputPointerMotion
103 InputPointerPress = ui.InputPointerPress
104 InputPointerRelease = ui.InputPointerRelease
105 InputPointerAxis = ui.InputPointerAxis
106 InputPointerLeave = ui.InputPointerLeave
107 InputKey = ui.InputKey
108 InputFocusIn = ui.InputFocusIn
109 InputFocusOut = ui.InputFocusOut
110 InputReset = ui.InputReset
111
112 ModShift = ui.ModShift
113 ModCtrl = ui.ModCtrl
114 ModAlt = ui.ModAlt
115 ModSuper = ui.ModSuper
116)