Documentation
¶
Index ¶
- Constants
- Variables
- func Absf32(x float32) float32
- func AutoFocus()
- func Blur()
- func CapAbove[T cmp.Ordered](v *T, f T)
- func CapBelow[T cmp.Ordered](v *T, c T)
- func CurrentId() any
- func CycleFocus(dir int)
- func CycleFocusOnTab()
- func DeleteHookedData(data any, itemKey any)
- func DirListing(path string) []os.DirEntry
- func Element(attrs Attrs)
- func ElementId(id any, attrs Attrs)
- func FallbackFontFor(ch rune, aspect FontAspect) (FontId, GlyphId)
- func FirstRender() bool
- func FloatHSLToRGB(h float64, s float64, l float64) (float64, float64, float64)
- func Focus()
- func FocusImmediate()
- func FocusImmediateOn(id any)
- func FocusOnClick()
- func GetLastId() any
- func GlyphOutline(fontId FontId, glyphId GlyphId) font.GlyphOutline
- func GlyphWidth(fontId FontId, glyphId GlyphId) float32
- func HasFocus() bool
- func HasFocusWithin() bool
- func Hash[T any](h *xxhash.Digest, v *T)
- func HashSlice[T any](h *xxhash.Digest, v []T)
- func HashString(h *xxhash.Digest, s string)
- func HashStringHeader(h *xxhash.Digest, s string)
- func IdHasFocus(id any) bool
- func IdIsClicked(id any) bool
- func IdIsHovered(id any) bool
- func IdReceivedFocusNow(id any) bool
- func Image(fpath string, maxSize Vec2)
- func InitFontSubsystem()
- func IsActive() bool
- func IsClicked() bool
- func IsHovered() bool
- func IsHoveredDirectly() bool
- func IsIdHoveredDirectly(id any) bool
- func Layout(attrs Attrs, builder func())
- func LayoutId(id any, attrs Attrs, builder func())
- func LoadImage(fpath string) *image.RGBA
- func LookupImage(id ImageId) *image.RGBA
- func MainCrossAxes(row bool) (int, int)
- func ModAttrs(fns ...func(*Attrs))
- func Nil()
- func PressAction() bool
- func ProfileNextFrame(outputFilename string)
- func PushSurface(s Surface)
- func ReadFileContent(fpath string) []byte
- func ReceivedFocusNow() bool
- func RectContainsPoint(r Rect, p Vec2) bool
- func RelId(id any) scopeId
- func RequestNextFrame()
- func RequestPaste()
- func RequestTextCopy(text string)
- func SafeTruncateUTF8(s string, limit int) string
- func ScaleFactor(fontId FontId) float32
- func ScrollOnInput()
- func SetActive()
- func ShapedTextLayout(shaped ShapedText, attrs TextAttrs, selectionFrom int, selectionTo int)
- func Text(label string, attrs TextAttrs)
- func UnsetActive()
- func Use[T any](itemKey any) *T
- func UseData[T any](data any, itemKey any) *T
- func UseFontBytes(data []byte) error
- func UseFontFile(fpath string)
- func UseFontFiles(fpaths ...string)
- func UseFontsDirectories(dirpaths ...string)
- func UseWithInit[T any](itemKey any, initFn func() *T) *T
- func XAdvance(fontId FontId, glyphId GlyphId) float32
- type Alignment
- type Attrs
- type Border
- type ClipStackOp
- type Color
- type Container
- type Direction
- type FaceLookupKey
- type Font
- type FontAspect
- type FontFace
- type FontId
- type FrameFn
- type FrameOutputData
- type Glyph
- type GlyphId
- type GlyphSegmentProps
- type GlyphsSegment
- type Handle
- type HookEntryKey
- type HoverableArtifacts
- type ImageId
- type KeyCode
- type KeyCombo
- type Modifiers
- type MouseAction
- type MouseButton
- type Rect
- type RenderData
- type Shadow
- type ShadowMapKey
- type ShapedText
- type ShapedTextLine
- type Stretch
- type Style
- type Surface
- type TextAttrs
- type TextLayout
- type TextStyle
- type Vec2
- type Vec4
- type Weight
Constants ¶
const ( KeyCodeNone KeyCode = iota KeyLeft = 128 + iota KeyRight KeyUp KeyDown KeyEnter KeyEscape KeyHome KeyEnd KeyDeleteBackward KeyDeleteForward KeyPageUp KeyPageDown KeyTab KeySpace KeyCtrl KeyShift KeyAlt KeySuper KeyCommand KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyBack )
const ( HUE = 0 SATURATION = 1 LIGHT = 2 ALPHA = 3 )
const LOG_FONTS = false
const PAD_BOTTOM = 2
const PAD_LEFT = 3
const PAD_RIGHT = 1
const PAD_TOP = 0
const StretchCondensed = font.StretchCondensed
const StretchExpanded = font.StretchExpanded
const StretchExtraCondensed = font.StretchExtraCondensed
const StretchExtraExpanded = font.StretchExtraExpanded
const StretchNormal = font.StretchNormal
const StretchSemiCondensed = font.StretchSemiCondensed
const StretchSemiExpanded = font.StretchSemiExpanded
const StretchUltraCondensed = font.StretchUltraCondensed
const StretchUltraExpanded = font.StretchUltraExpanded
const StyleItalic = font.StyleItalic
const StyleNormal = font.StyleNormal
const WeightBlack = font.WeightBlack
const WeightBold = font.WeightBold
const WeightExtraBold = font.WeightExtraBold
const WeightExtraLight = font.WeightExtraLight
const WeightLight = font.WeightLight
const WeightMedium = font.WeightMedium
const WeightNormal = font.WeightNormal
const WeightSemibold = font.WeightSemibold
const WeightThin = font.WeightThin
Variables ¶
var FrameInput struct { Mouse MouseAction Motion Vec2 // mouse movement Scroll Vec2 Key KeyCode Text string // text inputted this frame (could come from IME completion) }
transient (frame level) input state
var InputState struct { MousePoint Vec2 MouseButton MouseButton DownKeys []KeyCode // control keys state Modifiers Modifiers Composition string // text being input via IME }
persistent input state
var LayoutTime time.Duration
to be filled here
var Monospace = []string{"Noto Sans Mono", "Menlo", "Terminus", "Consolas", "Lucida Console"}
var SurfaceCount int
var TotalFrameTime time.Duration
to be filled by the backend
Functions ¶
func AutoFocus ¶
func AutoFocus()
grab focus if this is our first render and nothing else is focused
func CycleFocus ¶
func CycleFocus(dir int)
dir should be 1 or -1, but an arbitrary number should work too ..
func CycleFocusOnTab ¶
func CycleFocusOnTab()
func DeleteHookedData ¶
func DirListing ¶
func FallbackFontFor ¶
func FallbackFontFor(ch rune, aspect FontAspect) (FontId, GlyphId)
func FirstRender ¶
func FirstRender() bool
func FloatHSLToRGB ¶
taken from https://github.com/alessani/ColorConverter/blob/master/ColorSpaceUtilities.h
func FocusImmediate ¶
func FocusImmediate()
func FocusImmediateOn ¶
func FocusImmediateOn(id any)
func GlyphOutline ¶
func GlyphOutline(fontId FontId, glyphId GlyphId) font.GlyphOutline
func GlyphWidth ¶
func HasFocusWithin ¶
func HasFocusWithin() bool
func HashString ¶
func HashStringHeader ¶
func IdHasFocus ¶
func IdIsClicked ¶
func IdIsHovered ¶
func IdReceivedFocusNow ¶
func Image ¶
FIXME: we shuold be able to also specify minSize and border radius, perhaps border color too!
func InitFontSubsystem ¶
func InitFontSubsystem()
must be called by backend before starting event loop
func IsHoveredDirectly ¶
func IsHoveredDirectly() bool
func IsIdHoveredDirectly ¶
func MainCrossAxes ¶
func PressAction ¶
func PressAction() bool
func ProfileNextFrame ¶
func ProfileNextFrame(outputFilename string)
func PushSurface ¶
func PushSurface(s Surface)
func ReadFileContent ¶
func ReceivedFocusNow ¶
func ReceivedFocusNow() bool
func RectContainsPoint ¶
func RelId ¶
func RelId(id any) scopeId
for when you don't want the id to be globally unique .. FIXME FIXME it does not seem like this thing actually works ..
func RequestNextFrame ¶
func RequestNextFrame()
func RequestPaste ¶
func RequestPaste()
func RequestTextCopy ¶
func RequestTextCopy(text string)
func SafeTruncateUTF8 ¶
Generated by ChatGPT (initially)
func ScaleFactor ¶
func ScrollOnInput ¶
func ScrollOnInput()
func ShapedTextLayout ¶
func ShapedTextLayout(shaped ShapedText, attrs TextAttrs, selectionFrom int, selectionTo int)
func UnsetActive ¶
func UnsetActive()
func UseFontBytes ¶
func UseFontFile ¶
func UseFontFile(fpath string)
func UseFontFiles ¶
func UseFontFiles(fpaths ...string)
func UseFontsDirectories ¶
func UseFontsDirectories(dirpaths ...string)
func UseWithInit ¶
Types ¶
type Attrs ¶
type Attrs struct {
// padding order is: top right bottom left
Padding Vec4
Gap float32
// 0 means opaque, 1 means transperant (opacity = 1)
// using this instead of opacity because the zero value is the good default
Transperancy float32
MainAlign Alignment
CrossAlign Alignment
// properties for self with respect to parent!
Grow float32
SelfAlign Alignment // override the parent's cross-align setting
MinSize Vec2
MaxSize Vec2
Float Vec2
Background Vec4
Gradient Vec4 // diff applied to background
Border
Shadow
Corners Vec4
// flags
// Layout things ..
Row bool
Wrap bool
ExpandAcross bool
Floats bool
// size is not determined by content but by size constraints, flex growth, and cross axis expansion
ExtrinsicSize bool
// Event things
ClickThrough bool
Focusable bool // items that can receive focus via clicking or tab-cycling
// clip content drawn outside container boundaries
// defaults to no clipping, because clip by default can have some undesirable side effects
Clip bool
// When certain interactions feel off if animated
NoAnimate bool
}
type Direction ¶
type Direction byte
func ParagraphBidi ¶
works with a single line of text, not an article with multiple paragraphs!
type FaceLookupKey ¶
type FaceLookupKey struct {
Family string
Aspect FontAspect
}
type FontAspect ¶
func DefaultFontAspect ¶
func DefaultFontAspect() FontAspect
type FontFace ¶
type FontFace struct {
FontId FontId
FaceLookupKey
Filepath string
// Inverted "Units Per eM"
InvUPM float32
// Extents
Ascender float32
Descender float32
LineGap float32
// contains filtered or unexported fields
}
FontFace holds some generic traits/info about the font face
type FrameOutputData ¶
type FrameOutputData struct {
Surfaces []Surface
Copy string // things we want to put into the clipboard
Paste bool // to request a clipboard read!
NextFrameRequested bool
FrameHasChanges bool
}
func RunFrameFn ¶
func RunFrameFn(frameFn FrameFn) FrameOutputData
RunFrame is meant to be called by the app & rendering backend
type GlyphId ¶
func LookupGlyph ¶
type GlyphSegmentProps ¶
type GlyphSegmentProps struct {
Dir Direction
// contains filtered or unexported fields
}
type GlyphsSegment ¶
type GlyphsSegment struct {
GlyphSegmentProps
Width float32
Height float32
Glyphs []Glyph
}
type HookEntryKey ¶
type HoverableArtifacts ¶
type ImageId ¶
type ImageId uint32
FIXME we need to manage images in a way that allows them to be added and removed dynamically without interfering with caching! in other words, we need to use a handles system!
func GetImageId ¶
type KeyCombo ¶
func ActiveCombo ¶
func ActiveCombo() KeyCombo
type MouseButton ¶
type MouseButton uint8
const ( MousePrimary MouseButton = iota MouseSecondary MouseTertiary )
mirrors the values in gioui
type Rect ¶
func GetContentRect ¶
func GetContentRect() Rect
func GetContentRectOf ¶
func GetResolvedRectOf ¶
func GetScreenRect ¶
func GetScreenRect() Rect
Get the screen rect of the current element from the previous frame data
func GetScreenRectOf ¶
func RectIntersect ¶
type RenderData ¶
type RenderData struct {
Attrs
ResolvedSize Vec2
RelativeOrigin Vec2
ResolvedOrigin Vec2
// contains filtered or unexported fields
}
func GetRenderData ¶
func GetRenderData() RenderData
func GetRenderDataOf ¶
func GetRenderDataOf(id any) RenderData
type ShadowMapKey ¶
type ShadowMapKey struct {
// contains filtered or unexported fields
}
type ShapedText ¶
type ShapedText struct {
Runes []rune
BaseDir Direction
Lines []ShapedTextLine
}
func ShapeText ¶
func ShapeText(text string, attrs TextAttrs) ShapedText
type ShapedTextLine ¶
type ShapedTextLine struct {
Segments []GlyphsSegment
Width float32
Height float32
}
type Surface ¶
type Surface struct {
Rect Rect
Color1 Vec4
Color2 Vec4
Corners Vec4 // corner radius
Stroke float32 // for borders!
ImageId ImageId
ImageScale bool // if set, scales image down to fit surface!
FontId FontId
GlyphId GlyphId
GlyphOffset Vec2
Clip ClipStackOp
Transperancy float32
PopTransperancy bool
}
type TextAttrs ¶
type TextAttrs struct {
TextStyle
MaxWidth f32
}
func DefaultTextAttrs ¶
func DefaultTextAttrs() TextAttrs
type TextLayout ¶
type TextLayout struct {
Segments []GlyphsSegment
}
type TextStyle ¶
type TextStyle struct {
Families []string
FontAspect
Color Vec4
Size f32
}
func DefaultTextStyle ¶
func DefaultTextStyle() TextStyle
type Vec2 ¶
type Vec2 = [2]f32
var CaretPos Vec2
applications can set this to make the IME box appears in the right place
var WindowSize Vec2
to be set by backend
func GetAvailableSize ¶
func GetAvailableSize() Vec2
func GetResolvedSize ¶
func GetResolvedSize() Vec2