Documentation ¶
Overview ¶
Package GiSt contains the style structures for the GoGi GUI framework.
These are all based on the CSS standard: https://www.w3schools.com/cssref/default.asp
The xml struct tags provide the (lowercase) keyword for each tag -- tags can be parsed from strings using these keywords.
Index ¶
- Constants
- Variables
- func CopyGradient(dst, src *rasterx.Gradient)
- func FixFontMods(fn string) string
- func FixGradientStops(grad *rasterx.Gradient)
- func FontNameFromMods(basenm string, str FontStretch, wt FontWeights, sty FontStyles) string
- func FontNameToMods(fn string) (basenm string, str FontStretch, wt FontWeights, sty FontStyles)
- func IsAlignEnd(a Align) bool
- func IsAlignMiddle(a Align) bool
- func IsAlignStart(a Align) bool
- func MatToRasterx(mat *mat32.Mat2) rasterx.Matrix2D
- func ParseDashesString(str string) []float64
- func RasterxToMat(mat *rasterx.Matrix2D) mat32.Mat2
- func SetGradientBounds(grad *rasterx.Gradient, bounds image.Rectangle)
- func SetStylePropsXML(style string, props *map[string]any)
- func StyleInhInit(val, par any) (inh, init bool)
- func StylePropsXML(props map[string]any) string
- func StyleSetError(key string, val any)
- func SubProps(prp map[string]any, selector string) (map[string]any, bool)
- func XMLAttr(name string, attrs []xml.Attr) string
- type ActiveStyler
- type Align
- func (i Align) Desc() string
- func (i Align) Int64() int64
- func (i Align) IsValid() bool
- func (i Align) MarshalText() ([]byte, error)
- func (i *Align) SetInt64(in int64)
- func (i *Align) SetString(s string) error
- func (i Align) String() string
- func (i *Align) UnmarshalText(text []byte) error
- func (i Align) Values() []enums.Enum
- type BaselineShifts
- func (i BaselineShifts) Desc() string
- func (i BaselineShifts) Int64() int64
- func (i BaselineShifts) IsValid() bool
- func (i BaselineShifts) MarshalText() ([]byte, error)
- func (i *BaselineShifts) SetInt64(in int64)
- func (i *BaselineShifts) SetString(s string) error
- func (i BaselineShifts) String() string
- func (i *BaselineShifts) UnmarshalText(text []byte) error
- func (i BaselineShifts) Values() []enums.Enum
- type Border
- type BorderStyles
- func (i BorderStyles) Desc() string
- func (i BorderStyles) Int64() int64
- func (i BorderStyles) IsValid() bool
- func (i BorderStyles) MarshalText() ([]byte, error)
- func (i *BorderStyles) SetInt64(in int64)
- func (i *BorderStyles) SetString(s string) error
- func (i BorderStyles) String() string
- func (i *BorderStyles) UnmarshalText(text []byte) error
- func (i BorderStyles) Values() []enums.Enum
- type ColorSchemeTypes
- func (i ColorSchemeTypes) Desc() string
- func (i ColorSchemeTypes) Int64() int64
- func (i ColorSchemeTypes) IsValid() bool
- func (i ColorSchemeTypes) MarshalText() ([]byte, error)
- func (i *ColorSchemeTypes) SetInt64(in int64)
- func (i *ColorSchemeTypes) SetString(s string) error
- func (i ColorSchemeTypes) String() string
- func (i *ColorSchemeTypes) UnmarshalText(text []byte) error
- func (i ColorSchemeTypes) Values() []enums.Enum
- type ColorSources
- func (i ColorSources) Desc() string
- func (i ColorSources) Int64() int64
- func (i ColorSources) IsValid() bool
- func (i ColorSources) MarshalText() ([]byte, error)
- func (i *ColorSources) SetInt64(in int64)
- func (i *ColorSources) SetString(s string) error
- func (i ColorSources) String() string
- func (i *ColorSources) UnmarshalText(text []byte) error
- func (i ColorSources) Values() []enums.Enum
- type ColorSpec
- func (c *ColorSpec) ApplyXForm(xf mat32.Mat2)
- func (c *ColorSpec) ApplyXFormPt(xf mat32.Mat2, pt mat32.Vec2)
- func (cs *ColorSpec) ColorOrNil() color.Color
- func (cs *ColorSpec) CopyFrom(cp *ColorSpec)
- func (cs *ColorSpec) CopyStopsFrom(cp *ColorSpec)
- func (cs *ColorSpec) IsNil() bool
- func (cs *ColorSpec) NewLinearGradient()
- func (cs *ColorSpec) NewRadialGradient()
- func (cs *ColorSpec) ReadGradAttr(attr xml.Attr) (err error)
- func (cs *ColorSpec) ReadXML(reader io.Reader) error
- func (cs *ColorSpec) RenderColor(opacity float32, bounds image.Rectangle, xform mat32.Mat2) any
- func (cs *ColorSpec) SetColor(cl color.Color)
- func (cs *ColorSpec) SetGradientPoints(bbox mat32.Box2)
- func (c *ColorSpec) SetIFace(val any, ctxt Context, key string) error
- func (cs *ColorSpec) SetName(name string)
- func (cs *ColorSpec) SetShadowGradient(cl color.Color, dir string)
- func (cs *ColorSpec) SetSolid(cl color.RGBA)
- func (cs *ColorSpec) SetString(clrstr string, ctxt Context) bool
- func (cs *ColorSpec) UnmarshalXML(decoder *xml.Decoder, se xml.StartElement) error
- type Context
- type Fill
- type FillRules
- func (i FillRules) Desc() string
- func (i FillRules) Int64() int64
- func (i FillRules) IsValid() bool
- func (i FillRules) MarshalText() ([]byte, error)
- func (i *FillRules) SetInt64(in int64)
- func (i *FillRules) SetString(s string) error
- func (i FillRules) String() string
- func (i *FillRules) UnmarshalText(text []byte) error
- func (i FillRules) Values() []enums.Enum
- type Font
- func (fs *Font) Defaults()
- func (fs *Font) InheritFields(par *Font)
- func (fs *Font) SetDeco(deco TextDecorations)
- func (fs *Font) SetStylePost(props map[string]any)
- func (fs *Font) SetStyleProps(parent *Font, props map[string]any, ctxt Context)
- func (fs *Font) SetUnitContext(ctxt *units.Context)
- func (fs *Font) StyleFromProps(par *Font, props map[string]any, ctxt Context)
- func (fs *Font) ToDots(uc *units.Context)
- type FontFace
- type FontMetrics
- type FontRender
- type FontStretch
- func (i FontStretch) Desc() string
- func (i FontStretch) Int64() int64
- func (i FontStretch) IsValid() bool
- func (i FontStretch) MarshalText() ([]byte, error)
- func (i *FontStretch) SetInt64(in int64)
- func (i *FontStretch) SetString(s string) error
- func (i FontStretch) String() string
- func (i *FontStretch) UnmarshalText(text []byte) error
- func (i FontStretch) Values() []enums.Enum
- type FontStyles
- func (i FontStyles) Desc() string
- func (i FontStyles) Int64() int64
- func (i FontStyles) IsValid() bool
- func (i FontStyles) MarshalText() ([]byte, error)
- func (i *FontStyles) SetInt64(in int64)
- func (i *FontStyles) SetString(s string) error
- func (i FontStyles) String() string
- func (i *FontStyles) UnmarshalText(text []byte) error
- func (i FontStyles) Values() []enums.Enum
- type FontVariants
- func (i FontVariants) Desc() string
- func (i FontVariants) Int64() int64
- func (i FontVariants) IsValid() bool
- func (i FontVariants) MarshalText() ([]byte, error)
- func (i *FontVariants) SetInt64(in int64)
- func (i *FontVariants) SetString(s string) error
- func (i FontVariants) String() string
- func (i *FontVariants) UnmarshalText(text []byte) error
- func (i FontVariants) Values() []enums.Enum
- type FontWeights
- func (i FontWeights) Desc() string
- func (i FontWeights) Int64() int64
- func (i FontWeights) IsValid() bool
- func (i FontWeights) MarshalText() ([]byte, error)
- func (i *FontWeights) SetInt64(in int64)
- func (i *FontWeights) SetString(s string) error
- func (i FontWeights) String() string
- func (i *FontWeights) UnmarshalText(text []byte) error
- func (i FontWeights) Values() []enums.Enum
- type Geom2DInt
- type GradientPoints
- func (i GradientPoints) Desc() string
- func (i GradientPoints) Int64() int64
- func (i GradientPoints) IsValid() bool
- func (i GradientPoints) MarshalText() ([]byte, error)
- func (i *GradientPoints) SetInt64(in int64)
- func (i *GradientPoints) SetString(s string) error
- func (i GradientPoints) String() string
- func (i *GradientPoints) UnmarshalText(text []byte) error
- func (i GradientPoints) Values() []enums.Enum
- type LineCaps
- func (i LineCaps) Desc() string
- func (i LineCaps) Int64() int64
- func (i LineCaps) IsValid() bool
- func (i LineCaps) MarshalText() ([]byte, error)
- func (i *LineCaps) SetInt64(in int64)
- func (i *LineCaps) SetString(s string) error
- func (i LineCaps) String() string
- func (i *LineCaps) UnmarshalText(text []byte) error
- func (i LineCaps) Values() []enums.Enum
- type LineJoins
- func (i LineJoins) Desc() string
- func (i LineJoins) Int64() int64
- func (i LineJoins) IsValid() bool
- func (i LineJoins) MarshalText() ([]byte, error)
- func (i *LineJoins) SetInt64(in int64)
- func (i *LineJoins) SetString(s string) error
- func (i LineJoins) String() string
- func (i *LineJoins) UnmarshalText(text []byte) error
- func (i LineJoins) Values() []enums.Enum
- type Overflow
- func (i Overflow) Desc() string
- func (i Overflow) Int64() int64
- func (i Overflow) IsValid() bool
- func (i Overflow) MarshalText() ([]byte, error)
- func (i *Overflow) SetInt64(in int64)
- func (i *Overflow) SetString(s string) error
- func (i Overflow) String() string
- func (i *Overflow) UnmarshalText(text []byte) error
- func (i Overflow) Values() []enums.Enum
- type Paint
- func (pc *Paint) CopyStyleFrom(cp *Paint)
- func (pc *Paint) Defaults()
- func (pc *Paint) HasFill() bool
- func (pc *Paint) HasNoStrokeOrFill() bool
- func (pc *Paint) HasStroke() bool
- func (pc *Paint) InheritFields(par *Paint)
- func (pc *Paint) SetStyleProps(par *Paint, props map[string]any, ctxt Context)
- func (pc *Paint) SetUnitContextExt(size image.Point)
- func (pc *Paint) StyleFromProps(par *Paint, props map[string]any, ctxt Context)
- func (pc *Paint) StyleToDots(uc *units.Context)
- func (pc *Paint) ToDots()
- func (pc *Paint) ToDotsImpl(uc *units.Context)
- type Prefer
- type Prefs
- type SetStringer
- type Shadow
- func (s *Shadow) BasePos(startPos mat32.Vec2) mat32.Vec2
- func (s *Shadow) BaseSize(startSize mat32.Vec2) mat32.Vec2
- func (s *Shadow) HasShadow() bool
- func (s *Shadow) Margin() SideFloats
- func (s *Shadow) Pos(startPos mat32.Vec2) mat32.Vec2
- func (s *Shadow) Size(startSize mat32.Vec2) mat32.Vec2
- func (s *Shadow) ToDots(uc *units.Context)
- type SideColors
- type SideFloats
- func (sf SideFloats) Add(other SideFloats) SideFloats
- func (s SideFloats) AllSame() bool
- func (s SideFloats) IsZero() bool
- func (sf SideFloats) Max(other SideFloats) SideFloats
- func (sf SideFloats) Min(other SideFloats) SideFloats
- func (sf SideFloats) Pos() mat32.Vec2
- func (sf SideFloats) Size() mat32.Vec2
- func (sf SideFloats) Sub(other SideFloats) SideFloats
- func (sf SideFloats) ToValues() SideValues
- type SideValues
- type Sides
- type SizePrefs
- type Stroke
- type Style
- func (s *Style) AddBoxShadow(shadow ...Shadow)
- func (s *Style) AlignDim(d mat32.Dims) Align
- func (s *Style) BoxShadowMargin() SideFloats
- func (s *Style) BoxShadowPosSize(startPos, startSize mat32.Vec2) (pos mat32.Vec2, sz mat32.Vec2)
- func (s *Style) BoxShadowToDots(uc *units.Context)
- func (s *Style) BoxSpace() SideFloats
- func (s *Style) CopyFrom(cp *Style)
- func (s *Style) CopyUnitContext(ctxt *units.Context)
- func (s *Style) Defaults()
- func (s *Style) EffMargin() SideFloats
- func (s *Style) FontRender() *FontRender
- func (s *Style) FromTemplate() (hasTemplate bool, saveTemplate bool)
- func (s *Style) HasBoxShadow() bool
- func (s *Style) InheritFields(par *Style)
- func (s *Style) LayoutDefaults()
- func (s *Style) LayoutToDots(uc *units.Context)
- func (s *Style) MaxSizeDots() mat32.Vec2
- func (s *Style) MinSizeDots() mat32.Vec2
- func (s *Style) PosDots() mat32.Vec2
- func (s *Style) SaveTemplate()
- func (s *Style) SetFixedHeight(val units.Value)
- func (s *Style) SetFixedWidth(val units.Value)
- func (s *Style) SetMinPrefHeight(val units.Value)
- func (s *Style) SetMinPrefWidth(val units.Value)
- func (s *Style) SetStretchMax()
- func (s *Style) SetStretchMaxHeight()
- func (s *Style) SetStretchMaxWidth()
- func (s *Style) SizeDots() mat32.Vec2
- func (s *Style) StyleFromProps(par *Style, props map[string]any, ctxt Context)
- func (s *Style) StyleToDots(uc *units.Context)
- func (s *Style) ToDots()
- func (s *Style) ToDotsImpl(uc *units.Context)
- type StyleFunc
- func StyleFuncBool[T any](initVal bool, getField func(obj *T) *bool) StyleFunc
- func StyleFuncEnum[T any](initVal enums.Enum, getField func(obj *T) enums.EnumSetter) StyleFunc
- func StyleFuncFloat[T any, F num.Float](initVal F, getField func(obj *T) *F) StyleFunc
- func StyleFuncInt[T any, F num.Integer](initVal F, getField func(obj *T) *F) StyleFunc
- func StyleFuncUnits[T any](initVal units.Value, getField func(obj *T) *units.Value) StyleFunc
- type Text
- func (ts *Text) AlignFactors() (ax, ay float32)
- func (ts *Text) Defaults()
- func (ts *Text) EffLineHeight(fontHeight float32) float32
- func (ts *Text) HasPre() bool
- func (ts *Text) HasWordWrap() bool
- func (ts *Text) InheritFields(par *Text)
- func (ts *Text) SetStylePost(props map[string]any)
- func (ts *Text) ToDots(uc *units.Context)
- type TextAnchors
- func (i TextAnchors) Desc() string
- func (i TextAnchors) Int64() int64
- func (i TextAnchors) IsValid() bool
- func (i TextAnchors) MarshalText() ([]byte, error)
- func (i *TextAnchors) SetInt64(in int64)
- func (i *TextAnchors) SetString(s string) error
- func (i TextAnchors) String() string
- func (i *TextAnchors) UnmarshalText(text []byte) error
- func (i TextAnchors) Values() []enums.Enum
- type TextDecorations
- func (i TextDecorations) BitIndexString() string
- func (i TextDecorations) Desc() string
- func (i TextDecorations) HasFlag(f enums.BitFlag) bool
- func (i TextDecorations) Int64() int64
- func (i TextDecorations) IsValid() bool
- func (i TextDecorations) MarshalText() ([]byte, error)
- func (i *TextDecorations) SetFlag(on bool, f ...enums.BitFlag)
- func (i *TextDecorations) SetInt64(in int64)
- func (i *TextDecorations) SetString(s string) error
- func (i *TextDecorations) SetStringOr(s string) error
- func (i TextDecorations) String() string
- func (i *TextDecorations) UnmarshalText(text []byte) error
- func (i TextDecorations) Values() []enums.Enum
- type TextDirections
- func (i TextDirections) Desc() string
- func (i TextDirections) Int64() int64
- func (i TextDirections) IsValid() bool
- func (i TextDirections) MarshalText() ([]byte, error)
- func (i *TextDirections) SetInt64(in int64)
- func (i *TextDirections) SetString(s string) error
- func (i TextDirections) String() string
- func (i *TextDirections) UnmarshalText(text []byte) error
- func (i TextDirections) Values() []enums.Enum
- type UnicodeBidi
- func (i UnicodeBidi) Desc() string
- func (i UnicodeBidi) Int64() int64
- func (i UnicodeBidi) IsValid() bool
- func (i UnicodeBidi) MarshalText() ([]byte, error)
- func (i *UnicodeBidi) SetInt64(in int64)
- func (i *UnicodeBidi) SetString(s string) error
- func (i UnicodeBidi) String() string
- func (i *UnicodeBidi) UnmarshalText(text []byte) error
- func (i UnicodeBidi) Values() []enums.Enum
- type VectorEffects
- func (i VectorEffects) Desc() string
- func (i VectorEffects) Int64() int64
- func (i VectorEffects) IsValid() bool
- func (i VectorEffects) MarshalText() ([]byte, error)
- func (i *VectorEffects) SetInt64(in int64)
- func (i *VectorEffects) SetString(s string) error
- func (i VectorEffects) String() string
- func (i *VectorEffects) UnmarshalText(text []byte) error
- func (i VectorEffects) Values() []enums.Enum
- type WhiteSpaces
- func (i WhiteSpaces) Desc() string
- func (i WhiteSpaces) Int64() int64
- func (i WhiteSpaces) IsValid() bool
- func (i WhiteSpaces) MarshalText() ([]byte, error)
- func (i *WhiteSpaces) SetInt64(in int64)
- func (i *WhiteSpaces) SetString(s string) error
- func (i WhiteSpaces) String() string
- func (i *WhiteSpaces) UnmarshalText(text []byte) error
- func (i WhiteSpaces) Values() []enums.Enum
Constants ¶
const ( X = mat32.X Y = mat32.Y )
Variables ¶
var ( // BorderRadiusNone indicates to use no border radius, // which creates a fully rectangular element BorderRadiusNone = NewSideValues(units.Px(0)) // BorderRadiusExtraSmall indicates to use extra small // 4px rounded corners BorderRadiusExtraSmall = NewSideValues(units.Px(4)) // BorderRadiusExtraSmallTop indicates to use extra small // 4px rounded corners on the top of the element and no // border radius on the bottom of the element BorderRadiusExtraSmallTop = NewSideValues(units.Px(4), units.Px(4), units.Px(0), units.Px(0)) // BorderRadiusSmall indicates to use small // 8px rounded corners BorderRadiusSmall = NewSideValues(units.Px(8)) // BorderRadiusMedium indicates to use medium // 12px rounded corners BorderRadiusMedium = NewSideValues(units.Px(12)) // BorderRadiusLarge indicates to use large // 16px rounded corners BorderRadiusLarge = NewSideValues(units.Px(16)) // BorderRadiusLargeEnd indicates to use large // 16px rounded corners on the end (right side) // of the element and no border radius elsewhere BorderRadiusLargeEnd = NewSideValues(units.Px(0), units.Px(16), units.Px(16), units.Px(0)) // BorderRadiusLargeTop indicates to use large // 16px rounded corners on the top of the element // and no border radius on the bottom of the element BorderRadiusLargeTop = NewSideValues(units.Px(16), units.Px(16), units.Px(0), units.Px(0)) // BorderRadiusExtraLarge indicates to use extra large // 28px rounded corners BorderRadiusExtraLarge = NewSideValues(units.Px(28)) // BorderRadiusExtraLargeTop indicates to use extra large // 28px rounded corners on the top of the element // and no border radius on the bottom of the element BorderRadiusExtraLargeTop = NewSideValues(units.Px(28), units.Px(28), units.Px(0), units.Px(0)) // BorderRadiusFull indicates to use a full border radius, // which creates a circular/pill-shaped object. // It is defined to be a value that the width/height of an object // will never exceed. BorderRadiusFull = NewSideValues(units.Px(1_000_000_000)) )
Pre-configured border radius values, based on https://m3.material.io/styles/shape/shape-scale-tokens
var ColorSpecCache map[string]*ColorSpec
ColorSpecCache is a cache of named color specs -- only a few are constantly re-used so we save them in the cache instead of constantly recomputing!
var FontSizePoints = map[string]float32{
"xx-small": 7,
"x-small": 7.5,
"small": 10,
"smallf": 10,
"medium": 12,
"large": 14,
"x-large": 18,
"xx-large": 24,
}
FontSizePoints maps standard font names to standard point sizes -- we use dpi zoom scaling instead of rescaling "medium" font size, so generally use these values as-is. smaller and larger relative scaling can move in 2pt increments
var FontStretchNames = []string{"Normal", "UltraCondensed", "ExtraCondensed", "SemiCondensed", "SemiExpanded", "ExtraExpanded", "UltraExpanded", "Condensed", "Expanded", "Condensed", "Expanded"}
FontStretchNames contains the uppercase names of all the valid font stretches used in the regularized font names. The first name is the baseline default and will be omitted from font names. Order must have names that are subsets of other names at the end so they only match if the more specific one hasn't! And also match the FontStretch enum.
var FontStyleNames = []string{"Normal", "Italic", "Oblique"}
FontStyleNames contains the uppercase names of all the valid font styles used in the regularized font names. The first name is the baseline default and will be omitted from font names.
var FontWeightNameVals = []FontWeights{WeightNormal, WeightThin, WeightExtraLight, WeightLight, WeightMedium, WeightSemiBold, WeightExtraBold, WeightBold, WeightBlack}
FontWeightNameVals is 1-to-1 index map from FontWeightNames to corresponding weight value (using more semantic term instead of numerical one)
var FontWeightNames = []string{"Normal", "Thin", "ExtraLight", "Light", "Medium", "SemiBold", "ExtraBold", "Bold", "Black"}
FontWeightNames contains the uppercase names of all the valid font weights used in the regularized font names. The first name is the baseline default and will be omitted from font names. Order must have names that are subsets of other names at the end so they only match if the more specific one hasn't!
var FontWeightToNameMap = map[FontWeights]string{ Weight100: "Thin", WeightThin: "Thin", Weight200: "ExtraLight", WeightExtraLight: "ExtraLight", Weight300: "Light", WeightLight: "Light", Weight400: "", WeightNormal: "", Weight500: "Medium", WeightMedium: "Medium", Weight600: "SemiBold", WeightSemiBold: "SemiBold", Weight700: "Bold", WeightBold: "Bold", Weight800: "ExtraBold", WeightExtraBold: "ExtraBold", Weight900: "Black", WeightBlack: "Black", WeightBolder: "Medium", WeightLighter: "Light", }
FontWeightToNameMap maps all the style enums to canonical regularized font names
var GradientDegToSides = map[string]string{
"0deg": "top",
"360deg": "top",
"45deg": "top right",
"-315deg": "top right",
"90deg": "right",
"-270deg": "right",
"135deg": "bottom right",
"-225deg": "bottom right",
"180deg": "bottom",
"-180deg": "bottom",
"225deg": "bottom left",
"-135deg": "bottom left",
"270deg": "left",
"-90deg": "left",
"315deg": "top left",
"-45deg": "top left",
}
GradientDegToSides maps gradient degree notation to side notation
var LineHeightNormal = units.Px(-1)
LineHeightNormal represents a normal line height, equal to the default height of the font being used.
var RebuildDefaultStyles bool
RebuildDefaultStyles is a global state var used by Prefs to trigger rebuild of all the default styles, which are otherwise compiled and not updated
var ScrollBarWidthDefault = float32(15)
ScrollBarWidthDefault is the default width of a scrollbar in pixels
var StyleBorderFuncs = map[string]StyleFunc{ "border-style": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Style = par.(*Border).Style } else if init { bs.Style.Set(BorderSolid) } return } switch vt := val.(type) { case string: bs.Style.SetString(vt) case BorderStyles: bs.Style.Set(vt) case []BorderStyles: bs.Style.Set(vt...) default: if iv, ok := laser.ToInt(val); ok { bs.Style.Set(BorderStyles(iv)) } else { StyleSetError(key, val) } } }, "border-width": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Width = par.(*Border).Width } else if init { bs.Width.Set() } return } bs.Width.SetAny(val) }, "border-radius": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Radius = par.(*Border).Radius } else if init { bs.Radius.Set() } return } bs.Radius.SetAny(val) }, "border-color": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Color = par.(*Border).Color } else if init { bs.Color.Set(colors.Black) } return } bs.Color.SetAny(val, ctxt) }, }
StyleBorderFuncs are functions for styling the Border object
var StyleFillFuncs = map[string]StyleFunc{ "fill": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Fill) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Color = par.(*Fill).Color } else if init { fs.SetColor(colors.Black) } return } fs.Color.SetIFace(val, ctxt, key) }, "fill-opacity": StyleFuncFloat(float32(1), func(obj *Fill) *float32 { return &(obj.Opacity) }), "fill-rule": StyleFuncEnum(FillRuleNonZero, func(obj *Fill) enums.EnumSetter { return &(obj.Rule) }), }
StyleFillFuncs are functions for styling the Fill object
var StyleFontFuncs = map[string]StyleFunc{ "opacity": StyleFuncFloat(float32(1), func(obj *Font) *float32 { return &(obj.Opacity) }), "font-size": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Size = par.(*Font).Size } else if init { fs.Size.Set(12, units.UnitPt) } return } switch vt := val.(type) { case string: if psz, ok := FontSizePoints[vt]; ok { fs.Size = units.Pt(psz) } else { fs.Size.SetIFace(val, key) } default: fs.Size.SetIFace(val, key) } }, "font-family": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Family = par.(*Font).Family } else if init { fs.Family = "" } return } fs.Family = laser.ToString(val) }, "font-style": StyleFuncEnum(FontNormal, func(obj *Font) enums.EnumSetter { return &(obj.Style) }), "font-weight": StyleFuncEnum(WeightNormal, func(obj *Font) enums.EnumSetter { return &(obj.Weight) }), "font-stretch": StyleFuncEnum(FontStrNormal, func(obj *Font) enums.EnumSetter { return &(obj.Stretch) }), "font-variant": StyleFuncEnum(FontVarNormal, func(obj *Font) enums.EnumSetter { return &(obj.Variant) }), "baseline-shift": StyleFuncEnum(ShiftBaseline, func(obj *Font) enums.EnumSetter { return &(obj.Shift) }), "text-decoration": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Font) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Deco = par.(*Font).Deco } else if init { fs.Deco = DecoNone } return } switch vt := val.(type) { case string: if vt == "none" { fs.Deco = DecoNone } else { fs.Deco.SetString(vt) } case TextDecorations: fs.Deco = vt default: if iv, ok := laser.ToInt(val); ok { fs.Deco = TextDecorations(iv) } else { StyleSetError(key, val) } } }, }
StyleFontFuncs are functions for styling the Font object
var StyleFontRenderFuncs = map[string]StyleFunc{ "color": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*FontRender) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Color = par.(*FontRender).Color } else if init { fs.Color = colors.Black } return } fs.Color = colors.LogFromAny(val, ctxt.ContextColor()) }, "background-color": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*FontRender) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.BackgroundColor = par.(*FontRender).BackgroundColor } else if init { fs.BackgroundColor = ColorSpec{} } return } fs.BackgroundColor.SetIFace(val, ctxt, key) }, }
StyleFontRenderFuncs are functions for styling the FontStyle fields beyond Font
var StyleLayoutFuncs = map[string]StyleFunc{ "z-index": StyleFuncInt(int(0), func(obj *Style) *int { return &(obj.ZIndex) }), "horizontal-align": StyleFuncEnum(AlignLeft, func(obj *Style) enums.EnumSetter { return &(obj.AlignH) }), "vertical-align": StyleFuncEnum(AlignMiddle, func(obj *Style) enums.EnumSetter { return &(obj.AlignV) }), "x": StyleFuncUnits(units.Value{}, func(obj *Style) *units.Value { return &(obj.PosX) }), "y": StyleFuncUnits(units.Value{}, func(obj *Style) *units.Value { return &(obj.PosY) }), "width": StyleFuncUnits(units.Value{}, func(obj *Style) *units.Value { return &(obj.Width) }), "height": StyleFuncUnits(units.Value{}, func(obj *Style) *units.Value { return &(obj.Height) }), "max-width": StyleFuncUnits(units.Value{}, func(obj *Style) *units.Value { return &(obj.MaxWidth) }), "max-height": StyleFuncUnits(units.Value{}, func(obj *Style) *units.Value { return &(obj.MaxHeight) }), "min-width": StyleFuncUnits(units.Px(2), func(obj *Style) *units.Value { return &(obj.MinWidth) }), "min-height": StyleFuncUnits(units.Px(2), func(obj *Style) *units.Value { return &(obj.MinHeight) }), "margin": func(obj any, key string, val any, par any, ctxt Context) { s := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { s.Margin = par.(*Style).Margin } else if init { s.Margin.Set() } return } s.Margin.SetAny(val) }, "padding": func(obj any, key string, val any, par any, ctxt Context) { s := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { s.Padding = par.(*Style).Padding } else if init { s.Padding.Set() } return } s.Padding.SetAny(val) }, "overflow": StyleFuncEnum(OverflowAuto, func(obj *Style) enums.EnumSetter { return &(obj.Overflow) }), "columns": StyleFuncInt(int(0), func(obj *Style) *int { return &(obj.Columns) }), "row": StyleFuncInt(int(0), func(obj *Style) *int { return &(obj.Row) }), "col": StyleFuncInt(int(0), func(obj *Style) *int { return &(obj.Col) }), "row-span": StyleFuncInt(int(0), func(obj *Style) *int { return &(obj.RowSpan) }), "col-span": StyleFuncInt(int(0), func(obj *Style) *int { return &(obj.ColSpan) }), "scrollbar-width": StyleFuncUnits(units.Value{}, func(obj *Style) *units.Value { return &(obj.ScrollBarWidth) }), }
StyleLayoutFuncs are functions for styling the layout style properties; they are still stored on the main style object, but they are done separately to improve clarity
var StyleOutlineFuncs = map[string]StyleFunc{ "outline-style": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Style = par.(*Border).Style } else if init { bs.Style.Set(BorderNone) } return } switch vt := val.(type) { case string: bs.Style.SetString(vt) case BorderStyles: bs.Style.Set(vt) case []BorderStyles: bs.Style.Set(vt...) default: if iv, ok := laser.ToInt(val); ok { bs.Style.Set(BorderStyles(iv)) } else { StyleSetError(key, val) } } }, "outline-width": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Width = par.(*Border).Width } else if init { bs.Width.Set() } return } bs.Width.SetAny(val) }, "outline-radius": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Radius = par.(*Border).Radius } else if init { bs.Radius.Set() } return } bs.Radius.SetAny(val) }, "outline-color": func(obj any, key string, val any, par any, ctxt Context) { bs := obj.(*Border) if inh, init := StyleInhInit(val, par); inh || init { if inh { bs.Color = par.(*Border).Color } else if init { bs.Color.Set(colors.Black) } return } bs.Color.SetAny(val, ctxt) }, }
StyleOutlineFuncs are functions for styling the OutlineStyle object
var StylePaintFuncs = map[string]StyleFunc{ "vector-effect": StyleFuncEnum(VecEffNone, func(obj *Paint) enums.EnumSetter { return &(obj.VecEff) }), "transform": func(obj any, key string, val any, par any, ctxt Context) { pc := obj.(*Paint) if inh, init := StyleInhInit(val, par); inh || init { if inh { pc.XForm = par.(*Paint).XForm } else if init { pc.XForm = mat32.Identity2D() } return } switch vt := val.(type) { case string: pc.XForm.SetString(vt) case *mat32.Mat2: pc.XForm = *vt case mat32.Mat2: pc.XForm = vt } }, }
StylePaintFuncs are functions for styling the Stroke object
var StyleShadowFuncs = map[string]StyleFunc{ "box-shadow.h-offset": StyleFuncUnits(units.Value{}, func(obj *Shadow) *units.Value { return &(obj.HOffset) }), "box-shadow.v-offset": StyleFuncUnits(units.Value{}, func(obj *Shadow) *units.Value { return &(obj.VOffset) }), "box-shadow.blur": StyleFuncUnits(units.Value{}, func(obj *Shadow) *units.Value { return &(obj.Blur) }), "box-shadow.spread": StyleFuncUnits(units.Value{}, func(obj *Shadow) *units.Value { return &(obj.Spread) }), "box-shadow.color": func(obj any, key string, val any, par any, ctxt Context) { ss := obj.(*Shadow) if inh, init := StyleInhInit(val, par); inh || init { if inh { ss.Color = par.(*Shadow).Color } else if init { ss.Color = colors.Black } return } ss.Color = colors.LogFromAny(val, ctxt.ContextColor()) }, "box-shadow.inset": StyleFuncBool(false, func(obj *Shadow) *bool { return &(obj.Inset) }), }
StyleShadowFuncs are functions for styling the Shadow object
var StyleStrokeFuncs = map[string]StyleFunc{ "stroke": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Color = par.(*Stroke).Color } else if init { fs.SetColor(colors.Black) } return } fs.Color.SetIFace(val, ctxt, key) }, "stroke-opacity": StyleFuncFloat(float32(1), func(obj *Stroke) *float32 { return &(obj.Opacity) }), "stroke-width": StyleFuncUnits(units.Px(1), func(obj *Stroke) *units.Value { return &(obj.Width) }), "stroke-min-width": StyleFuncUnits(units.Px(1), func(obj *Stroke) *units.Value { return &(obj.MinWidth) }), "stroke-dasharray": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Stroke) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Dashes = par.(*Stroke).Dashes } else if init { fs.Dashes = nil } return } switch vt := val.(type) { case string: fs.Dashes = ParseDashesString(vt) case []float64: mat32.CopyFloat64s(&fs.Dashes, vt) case *[]float64: mat32.CopyFloat64s(&fs.Dashes, *vt) } }, "stroke-linecap": StyleFuncEnum(LineCapButt, func(obj *Stroke) enums.EnumSetter { return &(obj.Cap) }), "stroke-linejoin": StyleFuncEnum(LineJoinMiter, func(obj *Stroke) enums.EnumSetter { return &(obj.Join) }), "stroke-miterlimit": StyleFuncFloat(float32(1), func(obj *Stroke) *float32 { return &(obj.MiterLimit) }), }
StyleStrokeFuncs are functions for styling the Stroke object
var StyleStyleFuncs = map[string]StyleFunc{ "display": func(obj any, key string, val any, par any, ctxt Context) { s := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { s.Display = par.(*Style).Display } else if init { s.Display = true } return } if laser.ToString(val) == "none" { s.Display = false } else { if bv, ok := laser.ToBool(val); ok { s.Display = bv } } }, "visible": StyleFuncBool(false, func(obj *Style) *bool { return &(obj.Visible) }), "inactive": StyleFuncBool(false, func(obj *Style) *bool { return &(obj.Inactive) }), "pointer-events": StyleFuncBool(false, func(obj *Style) *bool { return &(obj.PointerEvents) }), "color": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.Color = par.(*Style).Color } else if init { fs.Color = colors.Black } return } fs.Color = colors.LogFromAny(val, ctxt.ContextColor()) }, "background-color": func(obj any, key string, val any, par any, ctxt Context) { fs := obj.(*Style) if inh, init := StyleInhInit(val, par); inh || init { if inh { fs.BackgroundColor = par.(*Style).BackgroundColor } else if init { fs.BackgroundColor = ColorSpec{} } return } fs.BackgroundColor.SetIFace(val, ctxt, key) }, }
StyleStyleFuncs are functions for styling the Style object itself
var StyleTemplates map[string]*Style
StyleTemplates are cached styles used for styling large numbers of identical elements in views
var StyleTemplatesMu sync.RWMutex
StyleTemplatesMu is a mutex protecting updates to StyleTemplates
var StyleTextFuncs = map[string]StyleFunc{ "text-align": StyleFuncEnum(AlignLeft, func(obj *Text) enums.EnumSetter { return &(obj.Align) }), "text-vertical-align": StyleFuncEnum(AlignTop, func(obj *Text) enums.EnumSetter { return &(obj.AlignV) }), "text-anchor": StyleFuncEnum(AnchorStart, func(obj *Text) enums.EnumSetter { return &(obj.Anchor) }), "letter-spacing": StyleFuncUnits(units.Value{}, func(obj *Text) *units.Value { return &(obj.LetterSpacing) }), "word-spacing": StyleFuncUnits(units.Value{}, func(obj *Text) *units.Value { return &(obj.WordSpacing) }), "line-height": StyleFuncUnits(LineHeightNormal, func(obj *Text) *units.Value { return &(obj.LineHeight) }), "white-space": StyleFuncEnum(WhiteSpaceNormal, func(obj *Text) enums.EnumSetter { return &(obj.WhiteSpace) }), "unicode-bidi": StyleFuncEnum(BidiNormal, func(obj *Text) enums.EnumSetter { return &(obj.UnicodeBidi) }), "direction": StyleFuncEnum(LRTB, func(obj *Text) enums.EnumSetter { return &(obj.Direction) }), "writing-mode": StyleFuncEnum(LRTB, func(obj *Text) enums.EnumSetter { return &(obj.WritingMode) }), "glyph-orientation-vertical": StyleFuncFloat(float32(1), func(obj *Text) *float32 { return &(obj.OrientationVert) }), "glyph-orientation-horizontal": StyleFuncFloat(float32(1), func(obj *Text) *float32 { return &(obj.OrientationHoriz) }), "text-indent": StyleFuncUnits(units.Value{}, func(obj *Text) *units.Value { return &(obj.Indent) }), "para-spacing": StyleFuncUnits(units.Value{}, func(obj *Text) *units.Value { return &(obj.ParaSpacing) }), "tab-size": StyleFuncInt(int(4), func(obj *Text) *int { return &(obj.TabSize) }), }
StyleTextFuncs are functions for styling the Text object
Functions ¶
func CopyGradient ¶
CopyGradient copies a gradient, making new copies of the stops instead of re-using pointers
func FixFontMods ¶
FixFontMods ensures that standard font modifiers have a space in front of them, and that the default is not in the name -- used for regularizing font names.
func FixGradientStops ¶
FixGradientStops applies the CSS rules to regularize the gradient stops: https://www.w3.org/TR/css3-images/#color-stop-syntax
func FontNameFromMods ¶
func FontNameFromMods(basenm string, str FontStretch, wt FontWeights, sty FontStyles) string
FontNameFromMods generates the appropriate regularized file name based on base name and modifiers
func FontNameToMods ¶
func FontNameToMods(fn string) (basenm string, str FontStretch, wt FontWeights, sty FontStyles)
FontNameToMods parses the regularized font name and returns the appropriate base name and associated font mods.
func IsAlignEnd ¶
is this a generalized alignment to end of container?
func IsAlignMiddle ¶
is this a generalized alignment to middle of container?
func IsAlignStart ¶
is this a generalized alignment to start of container?
func MatToRasterx ¶
func ParseDashesString ¶
ParseDashesString gets a dash slice from given string
func RasterxToMat ¶
func SetGradientBounds ¶
SetGradientBounds sets bounds of the gradient
func SetStylePropsXML ¶
SetStylePropsXML sets style props from XML style string, which contains ';' separated name: value pairs
func StyleInhInit ¶
StyleInhInit detects the style values of "inherit" and "initial", setting the corresponding bool return values
func StylePropsXML ¶
StylePropsXML returns style props for XML style string, which contains ';' separated name: value pairs
func StyleSetError ¶
StyleSetError reports that cannot set property of given key with given value
Types ¶
type ActiveStyler ¶
type ActiveStyler interface { ActiveStyle() *Style // StyleRLock does a read-lock for reading the style StyleRLock() // StyleRUnlock unlocks the read-lock StyleRUnlock() }
ActiveStyler defines an interface for anything that can report its active style
type Align ¶
type Align int32 //enums:enum
Align has all different types of alignment -- only some are applicable to different contexts, but there is also so much overlap that it makes sense to have them all in one list -- some are not standard CSS and used by layout
const ( AlignLeft Align = iota AlignTop AlignCenter // middle = vertical version of center AlignMiddle AlignRight AlignBottom AlignBaseline // same as CSS space-between AlignJustify AlignSpaceAround AlignFlexStart AlignFlexEnd AlignTextTop AlignTextBottom // align to subscript AlignSub // align to superscript AlignSuper )
const AlignN Align = 15
AlignN is the highest valid value for type Align, plus one.
func AlignValues ¶
func AlignValues() []Align
AlignValues returns all possible values for the type Align.
func (Align) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Align) SetString ¶
SetString sets the Align value from its string representation, and returns an error if the string is invalid.
func (*Align) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type BaselineShifts ¶
type BaselineShifts int32 //enums:enum
BaselineShifts are for super / sub script
const ( ShiftBaseline BaselineShifts = iota ShiftSuper ShiftSub )
const BaselineShiftsN BaselineShifts = 3
BaselineShiftsN is the highest valid value for type BaselineShifts, plus one.
func BaselineShiftsValues ¶
func BaselineShiftsValues() []BaselineShifts
BaselineShiftsValues returns all possible values for the type BaselineShifts.
func (BaselineShifts) Desc ¶
func (i BaselineShifts) Desc() string
Desc returns the description of the BaselineShifts value.
func (BaselineShifts) Int64 ¶
func (i BaselineShifts) Int64() int64
Int64 returns the BaselineShifts value as an int64.
func (BaselineShifts) IsValid ¶
func (i BaselineShifts) IsValid() bool
IsValid returns whether the value is a valid option for type BaselineShifts.
func (BaselineShifts) MarshalText ¶
func (i BaselineShifts) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*BaselineShifts) SetInt64 ¶
func (i *BaselineShifts) SetInt64(in int64)
SetInt64 sets the BaselineShifts value from an int64.
func (*BaselineShifts) SetString ¶
func (i *BaselineShifts) SetString(s string) error
SetString sets the BaselineShifts value from its string representation, and returns an error if the string is invalid.
func (BaselineShifts) String ¶
func (i BaselineShifts) String() string
String returns the string representation of this BaselineShifts value.
func (*BaselineShifts) UnmarshalText ¶
func (i *BaselineShifts) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (BaselineShifts) Values ¶
func (i BaselineShifts) Values() []enums.Enum
Values returns all possible values for the type BaselineShifts.
type Border ¶
type Border struct { // prop: border-style = how to draw the border Style Sides[BorderStyles] `xml:"style" desc:"prop: border-style = how to draw the border"` // prop: border-width = width of the border Width SideValues `xml:"width" desc:"prop: border-width = width of the border"` // prop: border-radius = rounding of the corners Radius SideValues `xml:"radius" desc:"prop: border-radius = rounding of the corners"` // prop: border-color = color of the border Color SideColors `xml:"color" desc:"prop: border-color = color of the border"` }
Border contains style parameters for borders
type BorderStyles ¶
type BorderStyles int32 //enums:enum
BorderStyles determines how to draw the border
const ( BorderSolid BorderStyles = iota BorderDotted BorderDashed BorderDouble BorderGroove BorderRidge BorderInset BorderOutset BorderNone BorderHidden )
const BorderStylesN BorderStyles = 10
BorderStylesN is the highest valid value for type BorderStyles, plus one.
func BorderStylesValues ¶
func BorderStylesValues() []BorderStyles
BorderStylesValues returns all possible values for the type BorderStyles.
func (BorderStyles) Desc ¶
func (i BorderStyles) Desc() string
Desc returns the description of the BorderStyles value.
func (BorderStyles) Int64 ¶
func (i BorderStyles) Int64() int64
Int64 returns the BorderStyles value as an int64.
func (BorderStyles) IsValid ¶
func (i BorderStyles) IsValid() bool
IsValid returns whether the value is a valid option for type BorderStyles.
func (BorderStyles) MarshalText ¶
func (i BorderStyles) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*BorderStyles) SetInt64 ¶
func (i *BorderStyles) SetInt64(in int64)
SetInt64 sets the BorderStyles value from an int64.
func (*BorderStyles) SetString ¶
func (i *BorderStyles) SetString(s string) error
SetString sets the BorderStyles value from its string representation, and returns an error if the string is invalid.
func (BorderStyles) String ¶
func (i BorderStyles) String() string
String returns the string representation of this BorderStyles value.
func (*BorderStyles) UnmarshalText ¶
func (i *BorderStyles) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (BorderStyles) Values ¶
func (i BorderStyles) Values() []enums.Enum
Values returns all possible values for the type BorderStyles.
type ColorSchemeTypes ¶
type ColorSchemeTypes int32 //enums:enum
ColorSchemeTypes is an enum that contains the supported color scheme types
const ( // ColorSchemeLight is a light color scheme ColorSchemeLight ColorSchemeTypes = iota // ColorSchemeDark is a dark color scheme ColorSchemeDark )
const ColorSchemeTypesN ColorSchemeTypes = 2
ColorSchemeTypesN is the highest valid value for type ColorSchemeTypes, plus one.
func ColorSchemeTypesValues ¶
func ColorSchemeTypesValues() []ColorSchemeTypes
ColorSchemeTypesValues returns all possible values for the type ColorSchemeTypes.
func (ColorSchemeTypes) Desc ¶
func (i ColorSchemeTypes) Desc() string
Desc returns the description of the ColorSchemeTypes value.
func (ColorSchemeTypes) Int64 ¶
func (i ColorSchemeTypes) Int64() int64
Int64 returns the ColorSchemeTypes value as an int64.
func (ColorSchemeTypes) IsValid ¶
func (i ColorSchemeTypes) IsValid() bool
IsValid returns whether the value is a valid option for type ColorSchemeTypes.
func (ColorSchemeTypes) MarshalText ¶
func (i ColorSchemeTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*ColorSchemeTypes) SetInt64 ¶
func (i *ColorSchemeTypes) SetInt64(in int64)
SetInt64 sets the ColorSchemeTypes value from an int64.
func (*ColorSchemeTypes) SetString ¶
func (i *ColorSchemeTypes) SetString(s string) error
SetString sets the ColorSchemeTypes value from its string representation, and returns an error if the string is invalid.
func (ColorSchemeTypes) String ¶
func (i ColorSchemeTypes) String() string
String returns the string representation of this ColorSchemeTypes value.
func (*ColorSchemeTypes) UnmarshalText ¶
func (i *ColorSchemeTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ColorSchemeTypes) Values ¶
func (i ColorSchemeTypes) Values() []enums.Enum
Values returns all possible values for the type ColorSchemeTypes.
type ColorSources ¶
type ColorSources int32 //enums:enum
ColorSources determine how the color is generated -- used in FillStyle and StrokeStyle
const ( SolidColor ColorSources = iota LinearGradient RadialGradient )
const ColorSourcesN ColorSources = 3
ColorSourcesN is the highest valid value for type ColorSources, plus one.
func ColorSourcesValues ¶
func ColorSourcesValues() []ColorSources
ColorSourcesValues returns all possible values for the type ColorSources.
func (ColorSources) Desc ¶
func (i ColorSources) Desc() string
Desc returns the description of the ColorSources value.
func (ColorSources) Int64 ¶
func (i ColorSources) Int64() int64
Int64 returns the ColorSources value as an int64.
func (ColorSources) IsValid ¶
func (i ColorSources) IsValid() bool
IsValid returns whether the value is a valid option for type ColorSources.
func (ColorSources) MarshalText ¶
func (i ColorSources) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*ColorSources) SetInt64 ¶
func (i *ColorSources) SetInt64(in int64)
SetInt64 sets the ColorSources value from an int64.
func (*ColorSources) SetString ¶
func (i *ColorSources) SetString(s string) error
SetString sets the ColorSources value from its string representation, and returns an error if the string is invalid.
func (ColorSources) String ¶
func (i ColorSources) String() string
String returns the string representation of this ColorSources value.
func (*ColorSources) UnmarshalText ¶
func (i *ColorSources) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ColorSources) Values ¶
func (i ColorSources) Values() []enums.Enum
Values returns all possible values for the type ColorSources.
type ColorSpec ¶
type ColorSpec struct { // source of color (solid, gradient) Source ColorSources `desc:"source of color (solid, gradient)"` // color for solid color source Color color.RGBA `desc:"color for solid color source"` // gradient parameters for gradient color source Gradient *rasterx.Gradient `desc:"gradient parameters for gradient color source"` }
ColorSpec fully specifies the color for rendering -- used in FillStyle and StrokeStyle
func (*ColorSpec) ApplyXForm ¶
func (c *ColorSpec) ApplyXForm(xf mat32.Mat2)
ApplyXForm transforms the points for a UserSpaceOnUse gradient
func (*ColorSpec) ApplyXFormPt ¶
func (c *ColorSpec) ApplyXFormPt(xf mat32.Mat2, pt mat32.Vec2)
ApplyXFormPt transforms the points for a UserSpaceOnUse gradient relative to a given center point
func (*ColorSpec) ColorOrNil ¶
ColorOrNil returns the solid color if non-nil, or nil otherwise -- for consumers that handle nil colors
func (*ColorSpec) CopyFrom ¶
Copy copies a gradient, making new copies of the stops instead of re-using pointers
func (*ColorSpec) CopyStopsFrom ¶
CopyStopsFrom copies gradient stops from other color spec, if both have gradient stops
func (*ColorSpec) NewLinearGradient ¶
func (cs *ColorSpec) NewLinearGradient()
NewLinearGradient creates a new Linear gradient in spec, sets Source to LinearGradient.
func (*ColorSpec) NewRadialGradient ¶
func (cs *ColorSpec) NewRadialGradient()
NewRadialGradient creates a new Radial gradient in spec, sets Source to RadialGradient.
func (*ColorSpec) RenderColor ¶
RenderColor gets the color for rendering, applying opacity and bounds for gradients
func (*ColorSpec) SetColor ¶
SetColor sets a solid color from a standard image/color.Color
func (*ColorSpec) SetGradientPoints ¶
func (cs *ColorSpec) SetGradientPoints(bbox mat32.Box2)
SetGradientPoints sets UserSpaceOnUse points for gradient based on given bounding box
func (*ColorSpec) SetIFace ¶
SetIFace sets the color spec from given interface value, e.g., for map[string]any key is an optional property key for error -- always logs errors
func (*ColorSpec) SetShadowGradient ¶
SetShadowGradient sets a linear gradient starting at given color and going down to transparent based on given color and direction spec (defaults to "to down")
func (*ColorSpec) SetString ¶
SetString sets the color spec from a standard CSS-formatted string -- see https://www.w3schools.com/css/css3_gradients.asp -- see UnmarshalXML for XML-based version
func (*ColorSpec) UnmarshalXML ¶
UnmarshalXML parses the given XML-formatted string to set the color specification
type Context ¶
type Context interface { // ContextColor returns the current Color activated in the context. // Color has support for special color names that are relative to // this current color. ContextColor() color.RGBA // ContextColorSpecByURL returns a ColorSpec from given URL expression // used in color specifications: url(#name) is typical, where name // is the name of a node with a ColorSpec in it. ContextColorSpecByURL(url string) *ColorSpec }
Context provides external contextual information needed for styles
type Fill ¶
type Fill struct { // is fill active -- if property is none then false On bool `desc:"is fill active -- if property is none then false"` // prop: fill = fill color specification Color ColorSpec `xml:"fill" desc:"prop: fill = fill color specification"` // prop: fill-opacity = global alpha opacity / transparency factor Opacity float32 `xml:"fill-opacity" desc:"prop: fill-opacity = global alpha opacity / transparency factor"` // prop: fill-rule = rule for how to fill more complex shapes with crossing lines Rule FillRules `xml:"fill-rule" desc:"prop: fill-rule = rule for how to fill more complex shapes with crossing lines"` }
Fill contains all the properties for filling a region
func (*Fill) Defaults ¶
func (pf *Fill) Defaults()
Defaults initializes default values for paint fill
func (*Fill) SetColorSpec ¶
SetColorSpec sets full color spec from source
func (*Fill) SetStylePost ¶
SetStylePost does some updating after setting the style from user properties
type FillRules ¶
type FillRules int32 //enums:enum
const FillRulesN FillRules = 2
FillRulesN is the highest valid value for type FillRules, plus one.
func FillRulesValues ¶
func FillRulesValues() []FillRules
FillRulesValues returns all possible values for the type FillRules.
func (FillRules) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*FillRules) SetString ¶
SetString sets the FillRules value from its string representation, and returns an error if the string is invalid.
func (*FillRules) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Font ¶
type Font struct { // prop: opacity = alpha value to apply to all elements Opacity float32 `xml:"opacity" desc:"prop: opacity = alpha value to apply to all elements"` // prop: font-size (inherited) = size of font to render -- convert to points when getting font to use Size units.Value `` /* 136-byte string literal not displayed */ // prop: font-family = font family -- ordered list of comma-separated names from more general to more specific to use -- use split on , to parse Family string `` /* 181-byte string literal not displayed */ // prop: font-style (inherited) = style -- normal, italic, etc Style FontStyles `xml:"font-style" inherit:"true" desc:"prop: font-style (inherited) = style -- normal, italic, etc"` // prop: font-weight (inherited) = weight: normal, bold, etc Weight FontWeights `xml:"font-weight" inherit:"true" desc:"prop: font-weight (inherited) = weight: normal, bold, etc"` // prop: font-stretch = font stretch / condense options Stretch FontStretch `xml:"font-stretch" inherit:"true" desc:"prop: font-stretch = font stretch / condense options"` // prop: font-variant = normal or small caps Variant FontVariants `xml:"font-variant" inherit:"true" desc:"prop: font-variant = normal or small caps"` // prop: text-decoration = underline, line-through, etc -- not inherited Deco TextDecorations `xml:"text-decoration" desc:"prop: text-decoration = underline, line-through, etc -- not inherited"` // prop: baseline-shift = super / sub script -- not inherited Shift BaselineShifts `xml:"baseline-shift" desc:"prop: baseline-shift = super / sub script -- not inherited"` // [view: -] full font information including enhanced metrics and actual font codes for drawing text -- this is a pointer into FontLibrary of loaded fonts Face *FontFace `` /* 157-byte string literal not displayed */ // Rem size of font -- 12pt converted to same effective DPI as above measurements Rem float32 `desc:"Rem size of font -- 12pt converted to same effective DPI as above measurements"` }
Font contains all font styling information. Most of font information is inherited. Font does not include all information needed for rendering -- see FontRender for that.
func (*Font) InheritFields ¶
InheritFields from parent: Manual inheriting of values is much faster than automatic version!
func (*Font) SetDeco ¶
func (fs *Font) SetDeco(deco TextDecorations)
SetDeco sets decoration (underline, etc), which uses bitflag to allow multiple combinations
func (*Font) SetStylePost ¶
func (*Font) SetStyleProps ¶
SetStyleProps sets font style values based on given property map (name: value pairs), inheriting elements as appropriate from parent, and also having a default style for the "initial" setting.
func (*Font) SetUnitContext ¶
SetUnitContext sets the font-specific information in the given units.Context, based on the currently-loaded face.
func (*Font) StyleFromProps ¶
type FontFace ¶
type FontFace struct { // The full FaceName that the font is accessed by Name string `desc:"The full FaceName that the font is accessed by"` // The integer font size in raw dots Size int `desc:"The integer font size in raw dots"` // The system image.Font font rendering interface Face font.Face `desc:"The system image.Font font rendering interface"` // enhanced metric information for the font Metrics FontMetrics `desc:"enhanced metric information for the font"` }
FontFace is our enhanced Font Face structure which contains the enhanced computed metrics in addition to the font.Face face
func NewFontFace ¶
NewFontFace returns a new font face
func (*FontFace) ComputeMetrics ¶
func (fs *FontFace) ComputeMetrics()
ComputeMetrics computes the Height, Em, Ex, Ch and Rem metrics associated with current font and overall units context
type FontMetrics ¶
type FontMetrics struct { // reference 1.0 spacing line height of font in dots -- computed from font as ascent + descent + lineGap, where lineGap is specified by the font as the recommended line spacing Height float32 `` /* 180-byte string literal not displayed */ // Em size of font -- this is NOT actually the width of the letter M, but rather the specified point size of the font (in actual display dots, not points) -- it does NOT include the descender and will not fit the entire height of the font Em float32 `` /* 242-byte string literal not displayed */ // Ex size of font -- this is the actual height of the letter x in the font Ex float32 `desc:"Ex size of font -- this is the actual height of the letter x in the font"` // Ch size of font -- this is the actual width of the 0 glyph in the font Ch float32 `desc:"Ch size of font -- this is the actual width of the 0 glyph in the font"` }
FontMetrics are our enhanced dot-scale font metrics compared to what is available in the standard font.Metrics lib, including Ex and Ch being defined in terms of the actual letter x and 0
type FontRender ¶
type FontRender struct { Font // prop: color (inherited) = text color -- also defines the currentColor variable value Color color.RGBA `xml:"color" inherit:"true" desc:"prop: color (inherited) = text color -- also defines the currentColor variable value"` // prop: background-color = background color -- not inherited, transparent by default BackgroundColor ColorSpec `xml:"background-color" desc:"prop: background-color = background color -- not inherited, transparent by default"` }
FontRender contains all font styling information that is needed for SVG text rendering. It is passed to Paint and Style functions. It should typically not be used by end-user code -- see Font for that. It stores all values as pointers so that they correspond to the values of the style object it was derived from.
func (*FontRender) Defaults ¶
func (fr *FontRender) Defaults()
func (*FontRender) InheritFields ¶
func (fr *FontRender) InheritFields(par *FontRender)
InheritFields from parent
type FontStretch ¶
type FontStretch int32 //enums:enum
FontStretch are different stretch levels of font. These are less typically available on most platforms by default.
const ( FontStrNormal FontStretch = iota FontStrUltraCondensed FontStrExtraCondensed FontStrSemiCondensed FontStrSemiExpanded FontStrExtraExpanded FontStrUltraExpanded FontStrCondensed FontStrExpanded FontStrNarrower FontStrWider )
const FontStretchN FontStretch = 11
FontStretchN is the highest valid value for type FontStretch, plus one.
func FontStretchValues ¶
func FontStretchValues() []FontStretch
FontStretchValues returns all possible values for the type FontStretch.
func (FontStretch) Desc ¶
func (i FontStretch) Desc() string
Desc returns the description of the FontStretch value.
func (FontStretch) Int64 ¶
func (i FontStretch) Int64() int64
Int64 returns the FontStretch value as an int64.
func (FontStretch) IsValid ¶
func (i FontStretch) IsValid() bool
IsValid returns whether the value is a valid option for type FontStretch.
func (FontStretch) MarshalText ¶
func (i FontStretch) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*FontStretch) SetInt64 ¶
func (i *FontStretch) SetInt64(in int64)
SetInt64 sets the FontStretch value from an int64.
func (*FontStretch) SetString ¶
func (i *FontStretch) SetString(s string) error
SetString sets the FontStretch value from its string representation, and returns an error if the string is invalid.
func (FontStretch) String ¶
func (i FontStretch) String() string
String returns the string representation of this FontStretch value.
func (*FontStretch) UnmarshalText ¶
func (i *FontStretch) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (FontStretch) Values ¶
func (i FontStretch) Values() []enums.Enum
Values returns all possible values for the type FontStretch.
type FontStyles ¶
type FontStyles int32 //enums:enum
FontStyles styles of font: normal, italic, etc
const ( FontNormal FontStyles = iota FontItalic FontOblique )
const FontStylesN FontStyles = 3
FontStylesN is the highest valid value for type FontStyles, plus one.
func FontStylesValues ¶
func FontStylesValues() []FontStyles
FontStylesValues returns all possible values for the type FontStyles.
func (FontStyles) Desc ¶
func (i FontStyles) Desc() string
Desc returns the description of the FontStyles value.
func (FontStyles) Int64 ¶
func (i FontStyles) Int64() int64
Int64 returns the FontStyles value as an int64.
func (FontStyles) IsValid ¶
func (i FontStyles) IsValid() bool
IsValid returns whether the value is a valid option for type FontStyles.
func (FontStyles) MarshalText ¶
func (i FontStyles) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*FontStyles) SetInt64 ¶
func (i *FontStyles) SetInt64(in int64)
SetInt64 sets the FontStyles value from an int64.
func (*FontStyles) SetString ¶
func (i *FontStyles) SetString(s string) error
SetString sets the FontStyles value from its string representation, and returns an error if the string is invalid.
func (FontStyles) String ¶
func (i FontStyles) String() string
String returns the string representation of this FontStyles value.
func (*FontStyles) UnmarshalText ¶
func (i *FontStyles) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (FontStyles) Values ¶
func (i FontStyles) Values() []enums.Enum
Values returns all possible values for the type FontStyles.
type FontVariants ¶
type FontVariants int32 //enums:enum
FontVariants is just normal vs. small caps. todo: not currently supported
const ( FontVarNormal FontVariants = iota FontVarSmallCaps )
const FontVariantsN FontVariants = 2
FontVariantsN is the highest valid value for type FontVariants, plus one.
func FontVariantsValues ¶
func FontVariantsValues() []FontVariants
FontVariantsValues returns all possible values for the type FontVariants.
func (FontVariants) Desc ¶
func (i FontVariants) Desc() string
Desc returns the description of the FontVariants value.
func (FontVariants) Int64 ¶
func (i FontVariants) Int64() int64
Int64 returns the FontVariants value as an int64.
func (FontVariants) IsValid ¶
func (i FontVariants) IsValid() bool
IsValid returns whether the value is a valid option for type FontVariants.
func (FontVariants) MarshalText ¶
func (i FontVariants) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*FontVariants) SetInt64 ¶
func (i *FontVariants) SetInt64(in int64)
SetInt64 sets the FontVariants value from an int64.
func (*FontVariants) SetString ¶
func (i *FontVariants) SetString(s string) error
SetString sets the FontVariants value from its string representation, and returns an error if the string is invalid.
func (FontVariants) String ¶
func (i FontVariants) String() string
String returns the string representation of this FontVariants value.
func (*FontVariants) UnmarshalText ¶
func (i *FontVariants) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (FontVariants) Values ¶
func (i FontVariants) Values() []enums.Enum
Values returns all possible values for the type FontVariants.
type FontWeights ¶
type FontWeights int32 //enums:enum
FontWeights are the valid names for different weights of font, with both the numeric and standard names given. The regularized font names in the font library use the names, as those are typically found in the font files.
const ( WeightNormal FontWeights = iota Weight100 WeightThin // (Hairline) Weight200 WeightExtraLight // (UltraLight) Weight300 WeightLight Weight400 Weight500 WeightMedium Weight600 WeightSemiBold // (DemiBold) Weight700 WeightBold Weight800 WeightExtraBold // (UltraBold) Weight900 WeightBlack WeightBolder WeightLighter )
const FontWeightsN FontWeights = 20
FontWeightsN is the highest valid value for type FontWeights, plus one.
func FontWeightsValues ¶
func FontWeightsValues() []FontWeights
FontWeightsValues returns all possible values for the type FontWeights.
func (FontWeights) Desc ¶
func (i FontWeights) Desc() string
Desc returns the description of the FontWeights value.
func (FontWeights) Int64 ¶
func (i FontWeights) Int64() int64
Int64 returns the FontWeights value as an int64.
func (FontWeights) IsValid ¶
func (i FontWeights) IsValid() bool
IsValid returns whether the value is a valid option for type FontWeights.
func (FontWeights) MarshalText ¶
func (i FontWeights) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*FontWeights) SetInt64 ¶
func (i *FontWeights) SetInt64(in int64)
SetInt64 sets the FontWeights value from an int64.
func (*FontWeights) SetString ¶
func (i *FontWeights) SetString(s string) error
SetString sets the FontWeights value from its string representation, and returns an error if the string is invalid.
func (FontWeights) String ¶
func (i FontWeights) String() string
String returns the string representation of this FontWeights value.
func (*FontWeights) UnmarshalText ¶
func (i *FontWeights) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (FontWeights) Values ¶
func (i FontWeights) Values() []enums.Enum
Values returns all possible values for the type FontWeights.
type Geom2DInt ¶
Geom2DInt defines a geometry in 2D dots units (int) -- this is just a more convenient format than image.Rectangle for cases where the size and position are independently updated (e.g., Viewport)
type GradientPoints ¶
type GradientPoints int32 //enums:enum
GradientPoints defines points within the gradient
const ( GpX1 GradientPoints = iota GpY1 GpX2 GpY2 )
const GradientPointsN GradientPoints = 4
GradientPointsN is the highest valid value for type GradientPoints, plus one.
func GradientPointsValues ¶
func GradientPointsValues() []GradientPoints
GradientPointsValues returns all possible values for the type GradientPoints.
func (GradientPoints) Desc ¶
func (i GradientPoints) Desc() string
Desc returns the description of the GradientPoints value.
func (GradientPoints) Int64 ¶
func (i GradientPoints) Int64() int64
Int64 returns the GradientPoints value as an int64.
func (GradientPoints) IsValid ¶
func (i GradientPoints) IsValid() bool
IsValid returns whether the value is a valid option for type GradientPoints.
func (GradientPoints) MarshalText ¶
func (i GradientPoints) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*GradientPoints) SetInt64 ¶
func (i *GradientPoints) SetInt64(in int64)
SetInt64 sets the GradientPoints value from an int64.
func (*GradientPoints) SetString ¶
func (i *GradientPoints) SetString(s string) error
SetString sets the GradientPoints value from its string representation, and returns an error if the string is invalid.
func (GradientPoints) String ¶
func (i GradientPoints) String() string
String returns the string representation of this GradientPoints value.
func (*GradientPoints) UnmarshalText ¶
func (i *GradientPoints) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (GradientPoints) Values ¶
func (i GradientPoints) Values() []enums.Enum
Values returns all possible values for the type GradientPoints.
type LineCaps ¶
type LineCaps int32 //enums:enum
end-cap of a line: stroke-linecap property in SVG
const LineCapsN LineCaps = 5
LineCapsN is the highest valid value for type LineCaps, plus one.
func LineCapsValues ¶
func LineCapsValues() []LineCaps
LineCapsValues returns all possible values for the type LineCaps.
func (LineCaps) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*LineCaps) SetString ¶
SetString sets the LineCaps value from its string representation, and returns an error if the string is invalid.
func (*LineCaps) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type LineJoins ¶
type LineJoins int32 //enums:enum
the way in which lines are joined together: stroke-linejoin property in SVG
const LineJoinsN LineJoins = 6
LineJoinsN is the highest valid value for type LineJoins, plus one.
func LineJoinsValues ¶
func LineJoinsValues() []LineJoins
LineJoinsValues returns all possible values for the type LineJoins.
func (LineJoins) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*LineJoins) SetString ¶
SetString sets the LineJoins value from its string representation, and returns an error if the string is invalid.
func (*LineJoins) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Overflow ¶
type Overflow int32 //enums:enum
overflow type -- determines what happens when there is too much stuff in a layout
const ( // OverflowAuto automatically determines if scrollbars should be added to show // the overflow. Scrollbars are added only if the actual content size is greater // than the currently available size. Typically, an outer-most Layout will scale // up and add scrollbars to accommodate the Min needs of its child elements, // so if you want to have scrollbars show up on inner elements, they need to // have a style setting that restricts their Min size, but also allows them to // stretch so they use whatever space they are allocated. OverflowAuto Overflow = iota // OverflowScroll means add scrollbars when necessary, and is essentially // identical to Auto. However, only during Viewport PrefSize call, // the actual content size is used -- otherwise it behaves just like Auto. OverflowScroll // OverflowVisible makes the overflow visible -- this is generally unsafe // and not very feasible and will be ignored as long as possible. // Currently it falls back on Auto, but could go to Hidden if that works // better overall. OverflowVisible // OverflowHidden hides the overflow and doesn't present scrollbars (supported). OverflowHidden )
const OverflowN Overflow = 4
OverflowN is the highest valid value for type Overflow, plus one.
func OverflowValues ¶
func OverflowValues() []Overflow
OverflowValues returns all possible values for the type Overflow.
func (Overflow) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Overflow) SetString ¶
SetString sets the Overflow value from its string representation, and returns an error if the string is invalid.
func (*Overflow) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Paint ¶
type Paint struct { // prop: display:none -- node and everything below it are off, non-rendering Off bool `desc:"prop: display:none -- node and everything below it are off, non-rendering"` // todo big enum of how to display item -- controls layout etc Display bool `xml:"display" desc:"todo big enum of how to display item -- controls layout etc"` // stroke (line drawing) parameters StrokeStyle Stroke `desc:"stroke (line drawing) parameters"` // fill (region filling) parameters FillStyle Fill `desc:"fill (region filling) parameters"` // font also has global opacity setting, along with generic color, background-color settings, which can be copied into stroke / fill as needed FontStyle FontRender `` /* 146-byte string literal not displayed */ // font also has global opacity setting, along with generic color, background-color settings, which can be copied into stroke / fill as needed TextStyle Text `` /* 146-byte string literal not displayed */ // prop: vector-effect = various rendering special effects settings VecEff VectorEffects `xml:"vector-effect" desc:"prop: vector-effect = various rendering special effects settings"` // prop: transform = our additions to transform -- pushed to render state XForm mat32.Mat2 `xml:"transform" desc:"prop: transform = our additions to transform -- pushed to render state"` // units context -- parameters necessary for anchoring relative units UnContext units.Context `xml:"-" desc:"units context -- parameters necessary for anchoring relative units"` // have the styles already been set? StyleSet bool `desc:"have the styles already been set?"` // set to true if parent node has no props -- allows optimization of styling PropsNil bool `desc:"set to true if parent node has no props -- allows optimization of styling"` // contains filtered or unexported fields }
Paint provides the styling parameters for rendering
func (*Paint) CopyStyleFrom ¶
CopyStyleFrom copies styles from another paint
func (*Paint) HasNoStrokeOrFill ¶
does the current Paint not have either a stroke or fill? in which case, often we just skip it
func (*Paint) InheritFields ¶
InheritFields from parent: Manual inheriting of values is much faster than automatic version!
func (*Paint) SetStyleProps ¶
SetStyleProps sets paint values based on given property map (name: value pairs), inheriting elements as appropriate from parent, and also having a default style for the "initial" setting
func (*Paint) SetUnitContextExt ¶
SetUnitContextExt sets the unit context for external usage of paint outside of a Viewport, based on overall size of painting canvas. caches everything out in terms of raw pixel dots for rendering call at start of render.
func (*Paint) StyleFromProps ¶
StyleFromProps sets style field values based on map[string]any properties
func (*Paint) StyleToDots ¶
StyleToDots runs ToDots on unit values, to compile down to raw pixels
func (*Paint) ToDots ¶
func (pc *Paint) ToDots()
ToDots runs ToDots on unit values, to compile down to raw pixels
func (*Paint) ToDotsImpl ¶
ToDotsImpl runs ToDots on unit values, to compile down to raw pixels
type Prefer ¶
type Prefer interface { // PrefColor returns preference color of given name // std names are: font, background, shadow, border, control, icon, select, highlight, link // nil if not found PrefColor(name string) *color.RGBA // PrefFontFamily returns the default FontFamily PrefFontFamily() string }
Prefer defines the interface to preferences for style-relevant prefs
var ThePrefs Prefer
ThePrefs is the prefs object to use to get preferences.
type Prefs ¶
type Prefs struct { // font family name FontFamily string `desc:"font family name"` // default font / pen color Font color.RGBA `desc:"default font / pen color"` // default background color Background color.RGBA `desc:"default background color"` // color for shadows -- should generally be a darker shade of the background color Shadow color.RGBA `desc:"color for shadows -- should generally be a darker shade of the background color"` // default border color, for button, frame borders, etc Border color.RGBA `desc:"default border color, for button, frame borders, etc"` // default main color for controls: buttons, etc Control color.RGBA `desc:"default main color for controls: buttons, etc"` // color for icons or other solidly-colored, small elements Icon color.RGBA `desc:"color for icons or other solidly-colored, small elements"` // color for selected elements Select color.RGBA `desc:"color for selected elements"` // color for highlight background Highlight color.RGBA `desc:"color for highlight background"` // color for links in text etc Link color.RGBA `desc:"color for links in text etc"` }
Prefs provides a basic implementation of Prefer interface
func (*Prefs) PrefColor ¶
PrefColor returns preference color of given name (case insensitive) std names are: font, background, shadow, border, control, icon, select, highlight, link
func (*Prefs) PrefFontFamily ¶
PrefFontFamily returns the default FontFamily
type SetStringer ¶
SetStringer is a type that can be set from a string
type Shadow ¶
type Shadow struct { // prop: .h-offset = horizontal offset of shadow -- positive = right side, negative = left side HOffset units.Value `xml:".h-offset" desc:"prop: .h-offset = horizontal offset of shadow -- positive = right side, negative = left side"` // prop: .v-offset = vertical offset of shadow -- positive = below, negative = above VOffset units.Value `xml:".v-offset" desc:"prop: .v-offset = vertical offset of shadow -- positive = below, negative = above"` // prop: .blur = blur radius -- higher numbers = more blurry Blur units.Value `xml:".blur" desc:"prop: .blur = blur radius -- higher numbers = more blurry"` // prop: .spread = spread radius -- positive number increases size of shadow, negative decreases size Spread units.Value `xml:".spread" desc:"prop: .spread = spread radius -- positive number increases size of shadow, negative decreases size"` // prop: .color = color of the shadow Color color.RGBA `xml:".color" desc:"prop: .color = color of the shadow"` // prop: .inset = shadow is inset within box instead of outset outside of box Inset bool `xml:".inset" desc:"prop: .inset = shadow is inset within box instead of outset outside of box"` }
style parameters for shadows
func (*Shadow) BasePos ¶
func (s *Shadow) BasePos(startPos mat32.Vec2) mat32.Vec2
BasePos returns the position at which the base box shadow (the actual solid, unblurred box part) should be rendered if the shadow is on an element with the given starting position.
func (*Shadow) BaseSize ¶
func (s *Shadow) BaseSize(startSize mat32.Vec2) mat32.Vec2
BaseSize returns the total size the base box shadow (the actual solid, unblurred part) should be if the shadow is on an element with the given starting size.
func (*Shadow) Margin ¶
func (s *Shadow) Margin() SideFloats
Margin returns the effective margin created by the shadow on each side in terms of raw display dots. It should be added to margin for sizing considerations.
func (*Shadow) Pos ¶
func (s *Shadow) Pos(startPos mat32.Vec2) mat32.Vec2
Pos returns the position at which the blurred box shadow should start if the shadow is on an element with the given starting position.
type SideColors ¶
SideColors contains color values for each side/corner of a box
func NewSideColors ¶
func NewSideColors(vals ...color.RGBA) SideColors
NewSideColors is a helper that creates new side/corner colors and calls Set on them with the given values. It does not return any error values and just logs them.
func NewSideColorsTry ¶
func NewSideColorsTry(vals ...color.RGBA) (SideColors, error)
NewSideColorsTry is a helper that creates new side/corner colors and calls Set on them with the given values. It returns an error value if there is one.
func (SideColors) AllSame ¶
func (s SideColors) AllSame() bool
AllSame returns whether all of the sides/corners are the same
func (SideColors) IsZero ¶
func (s SideColors) IsZero() bool
IsZero returns whether all of the sides/corners are equal to zero
type SideFloats ¶
SideFloats contains float32 values for each side/corner of a box
func BoxShadowMargin ¶
func BoxShadowMargin(shadows []Shadow) SideFloats
BoxShadowMargin returns the maximum box shadow margin of the given box shadows, calculated through Shadow.Margin.
func NewSideFloats ¶
func NewSideFloats(vals ...float32) SideFloats
NewSideFloats is a helper that creates new side/corner floats and calls Set on them with the given values. It does not return any error values and just logs them.
func NewSideFloatsTry ¶
func NewSideFloatsTry(vals ...float32) (SideFloats, error)
NewSideFloatsTry is a helper that creates new side/corner floats and calls Set on them with the given values. It returns an error value if there is one.
func (SideFloats) Add ¶
func (sf SideFloats) Add(other SideFloats) SideFloats
Add adds the side floats to the other side floats and returns the result
func (SideFloats) AllSame ¶
func (s SideFloats) AllSame() bool
AllSame returns whether all of the sides/corners are the same
func (SideFloats) IsZero ¶
func (s SideFloats) IsZero() bool
IsZero returns whether all of the sides/corners are equal to zero
func (SideFloats) Max ¶
func (sf SideFloats) Max(other SideFloats) SideFloats
Max returns a new side floats containing the maximum values of the two side floats
func (SideFloats) Min ¶
func (sf SideFloats) Min(other SideFloats) SideFloats
Min returns a new side floats containing the minimum values of the two side floats
func (SideFloats) Pos ¶
func (sf SideFloats) Pos() mat32.Vec2
Pos returns the position offset casued by the side/corner values (Left, Top)
func (SideFloats) Size ¶
func (sf SideFloats) Size() mat32.Vec2
Size returns the toal size the side/corner values take up (Left + Right, Top + Bottom)
func (SideFloats) Sub ¶
func (sf SideFloats) Sub(other SideFloats) SideFloats
Sub subtracts the other side floats from the side floats and returns the result
func (SideFloats) ToValues ¶
func (sf SideFloats) ToValues() SideValues
ToValues returns the side floats a SideValues composed of units.UnitDot values
type SideValues ¶
SideValues contains units.Value values for each side/corner of a box
func NewSideValues ¶
func NewSideValues(vals ...units.Value) SideValues
NewSideValues is a helper that creates new side/corner values and calls Set on them with the given values. It does not return any error values and just logs them.
func NewSideValuesTry ¶
func NewSideValuesTry(vals ...units.Value) (SideValues, error)
NewSideValuesTry is a helper that creates new side/corner values and calls Set on them with the given values. It returns an error value if there is one.
func (SideValues) Dots ¶
func (sv SideValues) Dots() SideFloats
Dots returns the dot values of the sides/corners as a SideFloats. It does not compute them; see ToDots for that.
func (*SideValues) ToDots ¶
func (sv *SideValues) ToDots(uc *units.Context) SideFloats
ToDots converts the values for each of the sides/corners to raw display pixels (dots) and sets the Dots field for each of the values. It returns the dot values as a SideFloats.
type Sides ¶
type Sides[T any] struct { // top/top-left value Top T `xml:"top" desc:"top/top-left value"` // right/top-right value Right T `xml:"right" desc:"right/top-right value"` // bottom/bottom-right value Bottom T `xml:"bottom" desc:"bottom/bottom-right value"` // left/bottom-left value Left T `xml:"left" desc:"left/bottom-left value"` }
Sides contains values for each side or corner of a box. If Sides contains sides, the struct field names correspond directly to the side values (ie: Top = top side value). If Sides contains corners, the struct field names correspond to the corners as follows: Top = top left, Right = top right, Bottom = bottom right, Left = bottom left.
func NewSides ¶
NewSides is a helper that creates new sides/corners of the given type and calls Set on them with the given values. It does not return any error values and just logs them.
func NewSidesTry ¶
NewSidesTry is a helper that creates new sides/corners of the given type and calls Set on them with the given values. It returns an error value if there is one.
func (*Sides[T]) Set ¶
Set sets the values of the sides/corners from the given list of 0 to 4 values. If 0 values are provided, all sides/corners are set to the zero value of the type. If 1 value is provided, all sides/corners are set to that value. If 2 values are provided, the top/top-left and bottom/bottom-right are set to the first value and the right/top-right and left/bottom-left are set to the second value. If 3 values are provided, the top/top-left is set to the first value, the right/top-right and left/bottom-left are set to the second value, and the bottom/bottom-right is set to the third value. If 4 values are provided, the top/top-left is set to the first value, the right/top-right is set to the second value, the bottom/bottom-right is set to the third value, and the left/bottom-left is set to the fourth value. If more than 4 values are provided, the behavior is the same as with 4 values, but Set also prints and returns an error. This error is not critical and does not need to be handled, as the values are still set, but it can be if wished. This behavior is based on the CSS multi-side/corner setting syntax, like that with padding and border-radius (see https://www.w3schools.com/css/css_padding.asp and https://www.w3schools.com/cssref/css3_pr_border-radius.php)
func (*Sides[T]) SetAll ¶
func (s *Sides[T]) SetAll(val T)
SetAll sets the values for all of the sides/corners to the given value
func (*Sides[T]) SetHoriz ¶
func (s *Sides[T]) SetHoriz(val T)
SetHoriz sets the values for the sides/corners in the horizontal/diagonally ascending direction (right/top-right and left/bottom-left) to the given value
type SizePrefs ¶
type SizePrefs struct { // minimum size needed -- set to at least computed allocsize Need mat32.Vec2 `desc:"minimum size needed -- set to at least computed allocsize"` // preferred size -- start here for layout Pref mat32.Vec2 `desc:"preferred size -- start here for layout"` // maximum size -- will not be greater than this -- 0 = no constraint, neg = stretch Max mat32.Vec2 `desc:"maximum size -- will not be greater than this -- 0 = no constraint, neg = stretch"` }
SizePrefs represents size preferences
func (SizePrefs) CanStretchNeed ¶
return true if Pref > Need meaning can stretch more along given dimension
func (SizePrefs) HasMaxStretch ¶
return true if Max < 0 meaning can stretch infinitely along given dimension
type Stroke ¶
type Stroke struct { // is stroke active -- if property is none then false On bool `desc:"is stroke active -- if property is none then false"` // prop: stroke = stroke color specification Color ColorSpec `xml:"stroke" desc:"prop: stroke = stroke color specification"` // prop: stroke-opacity = global alpha opacity / transparency factor Opacity float32 `xml:"stroke-opacity" desc:"prop: stroke-opacity = global alpha opacity / transparency factor"` // prop: stroke-width = line width Width units.Value `xml:"stroke-width" desc:"prop: stroke-width = line width"` // prop: stroke-min-width = minimum line width used for rendering -- if width is > 0, then this is the smallest line width -- this value is NOT subject to transforms so is in absolute dot values, and is ignored if vector-effects non-scaling-stroke is used -- this is an extension of the SVG / CSS standard MinWidth units.Value `` /* 332-byte string literal not displayed */ // prop: stroke-dasharray = dash pattern, in terms of alternating on and off distances -- e.g., [4 4] = 4 pixels on, 4 pixels off. Currently only supporting raw pixel numbers, but in principle should support units. Dashes []float64 `` /* 242-byte string literal not displayed */ // prop: stroke-linecap = how to draw the end cap of lines Cap LineCaps `xml:"stroke-linecap" desc:"prop: stroke-linecap = how to draw the end cap of lines"` // prop: stroke-linejoin = how to join line segments Join LineJoins `xml:"stroke-linejoin" desc:"prop: stroke-linejoin = how to join line segments"` // [min: 1] prop: stroke-miterlimit = limit of how far to miter -- must be 1 or larger MiterLimit float32 `xml:"stroke-miterlimit" min:"1" desc:"prop: stroke-miterlimit = limit of how far to miter -- must be 1 or larger"` }
Stroke contains all the properties for painting a line
func (*Stroke) Defaults ¶
func (ps *Stroke) Defaults()
Defaults initializes default values for paint stroke
func (*Stroke) SetColorSpec ¶
SetColorSpec sets full color spec from source
func (*Stroke) SetStylePost ¶
SetStylePost does some updating after setting the style from user properties
type Style ¶
type Style struct { // if present, then this should use unique template name for cached style -- critical for large numbers of repeated widgets in e.g., sliceview, tableview, etc Template string `` /* 162-byte string literal not displayed */ // todo big enum of how to display item -- controls layout etc Display bool `xml:"display" desc:"todo big enum of how to display item -- controls layout etc"` // is the item visible or not Visible bool `xml:"visible" desc:"is the item visible or not"` // make a control inactive so it does not respond to input Inactive bool `xml:"inactive" desc:"make a control inactive so it does not respond to input"` // prop: z-index = ordering factor for rendering depth -- lower numbers rendered first -- sort children according to this factor ZIndex int `` /* 146-byte string literal not displayed */ // prop: horizontal-align specifies the horizontal alignment of widget elements within a *vertical* layout container (has no effect within horizontal layouts -- use space / stretch elements instead). For text layout, use text-align. This is not a standard css property. AlignH Align `` /* 297-byte string literal not displayed */ // prop: vertical-align specifies the vertical alignment of widget elements within a *horizontal* layout container (has no effect within vertical layouts -- use space / stretch elements instead). For text layout, use text-vertical-align. This is not a standard css property AlignV Align `` /* 300-byte string literal not displayed */ // prop: x = horizontal position -- often superseded by layout but otherwise used PosX units.Value `xml:"x" desc:"prop: x = horizontal position -- often superseded by layout but otherwise used"` // prop: y = vertical position -- often superseded by layout but otherwise used PosY units.Value `xml:"y" desc:"prop: y = vertical position -- often superseded by layout but otherwise used"` // prop: width = specified size of element -- 0 if not specified Width units.Value `xml:"width" desc:"prop: width = specified size of element -- 0 if not specified"` // prop: height = specified size of element -- 0 if not specified Height units.Value `xml:"height" desc:"prop: height = specified size of element -- 0 if not specified"` // prop: max-width = specified maximum size of element -- 0 means just use other values, negative means stretch MaxWidth units.Value `` /* 132-byte string literal not displayed */ // prop: max-height = specified maximum size of element -- 0 means just use other values, negative means stretch MaxHeight units.Value `` /* 133-byte string literal not displayed */ // prop: min-width = specified minimum size of element -- 0 if not specified MinWidth units.Value `xml:"min-width" desc:"prop: min-width = specified minimum size of element -- 0 if not specified"` // prop: min-height = specified minimum size of element -- 0 if not specified MinHeight units.Value `xml:"min-height" desc:"prop: min-height = specified minimum size of element -- 0 if not specified"` // prop: margin = outer-most transparent space around box element Margin SideValues `xml:"margin" desc:"prop: margin = outer-most transparent space around box element"` // prop: padding = transparent space around central content of box Padding SideValues `xml:"padding" desc:"prop: padding = transparent space around central content of box"` // prop: overflow = what to do with content that overflows -- default is Auto add of scrollbars as needed -- todo: can have separate -x -y values Overflow Overflow `` /* 164-byte string literal not displayed */ // prop: columns = number of columns to use in a grid layout -- used as a constraint in layout if individual elements do not specify their row, column positions Columns int `` /* 194-byte string literal not displayed */ // prop: row = specifies the row that this element should appear within a grid layout Row int `xml:"row" desc:"prop: row = specifies the row that this element should appear within a grid layout"` // prop: col = specifies the column that this element should appear within a grid layout Col int `xml:"col" desc:"prop: col = specifies the column that this element should appear within a grid layout"` // prop: row-span = specifies the number of sequential rows that this element should occupy within a grid layout (todo: not currently supported) RowSpan int `` /* 163-byte string literal not displayed */ // prop: col-span = specifies the number of sequential columns that this element should occupy within a grid layout ColSpan int `` /* 134-byte string literal not displayed */ // prop: scrollbar-width = width of a layout scrollbar ScrollBarWidth units.Value `xml:"scrollbar-width" desc:"prop: scrollbar-width = width of a layout scrollbar"` // prop: color (inherited) = text color -- also defines the currentColor variable value Color color.RGBA `xml:"color" inherit:"true" desc:"prop: color (inherited) = text color -- also defines the currentColor variable value"` // prop: background-color = background color -- not inherited, transparent by default BackgroundColor ColorSpec `xml:"background-color" desc:"prop: background-color = background color -- not inherited, transparent by default"` // border around the box element Border Border `xml:"border" desc:"border around the box element"` // prop: box-shadow = the box shadows to render around box (can have multiple) BoxShadow []Shadow `xml:"box-shadow" desc:"prop: box-shadow = the box shadows to render around box (can have multiple)"` // font parameters -- no xml prefix -- also has color, background-color Font Font `desc:"font parameters -- no xml prefix -- also has color, background-color"` // text parameters -- no xml prefix Text Text `desc:"text parameters -- no xml prefix"` // prop: outline = draw an outline around an element -- mostly same styles as border -- default to none Outline Border `xml:"outline" desc:"prop: outline = draw an outline around an element -- mostly same styles as border -- default to none"` // prop: pointer-events = does this element respond to pointer events -- default is true PointerEvents bool `xml:"pointer-events" desc:"prop: pointer-events = does this element respond to pointer events -- default is true"` // units context -- parameters necessary for anchoring relative units UnContext units.Context `xml:"-" desc:"units context -- parameters necessary for anchoring relative units"` // has this style been set from object values yet? IsSet bool `desc:"has this style been set from object values yet?"` // set to true if parent node has no props -- allows optimization of styling PropsNil bool `desc:"set to true if parent node has no props -- allows optimization of styling"` // contains filtered or unexported fields }
Style has all the CSS-based style elements -- used for widget-type objects
var StyleDefault Style
StyleDefault is default style can be used when property specifies "default"
func (*Style) AddBoxShadow ¶
AddBoxShadow adds the given box shadows to the style
func (*Style) BoxShadowMargin ¶
func (s *Style) BoxShadowMargin() SideFloats
BoxShadowMargin returns the maximum box shadow margin of the style, calculated through Shadow.Margin
func (*Style) BoxShadowPosSize ¶
func (s *Style) BoxShadowPosSize(startPos, startSize mat32.Vec2) (pos mat32.Vec2, sz mat32.Vec2)
BoxShadowStartPos returns the position and size of the area in which all of the box shadows are rendered, using Shadow.Pos and Shadow.Size. It should be used as the bounds to clear to prevent growing shadows.
func (*Style) BoxShadowToDots ¶
BoxShadowToDots runs ToDots on all box shadow unit values to compile down to raw pixels
func (*Style) BoxSpace ¶
func (s *Style) BoxSpace() SideFloats
BoxSpace returns extra space around the central content in the box model, in dots -- todo: must complicate this if we want different spacing on different sides box outside-in: margin | border | padding | content
func (*Style) CopyUnitContext ¶
CopyUnitContext copies unit context from another, update with our font info, and then cache everything out in terms of raw pixel dots for rendering -- call at start of render
func (*Style) EffMargin ¶
func (s *Style) EffMargin() SideFloats
EffMargin returns the effective margin of the element holding the style, using the maximum of the actual margin and the box shadow margin.
func (*Style) FontRender ¶
func (s *Style) FontRender() *FontRender
FontRender returns the font-rendering-related styles of the style object as a FontRender
func (*Style) FromTemplate ¶
FromTemplate checks if there is a template for this style, returning false for hasTemplate if not (in which case usual styling should proceed). If there is a template, and it has already been saved, the style is copied from the existing template. If there is a template name set but no existing template has yet been saved, then saveTemplate = true and the SaveTemplate call should be made on this style after it has gone through the usual styling process.
func (*Style) HasBoxShadow ¶
HasBoxShadow returns whether the style has any box shadows
func (*Style) InheritFields ¶
InheritFields from parent: Manual inheriting of values is much faster than automatic version!
func (*Style) LayoutDefaults ¶
func (s *Style) LayoutDefaults()
func (*Style) LayoutToDots ¶
ToDots runs ToDots on unit values, to compile down to raw pixels
func (*Style) SaveTemplate ¶
func (s *Style) SaveTemplate()
SaveTemplate should only be called for styles that have template but none has yet been saved, as determined by FromTemplate call.
func (*Style) SetFixedHeight ¶
SetFixedHeight sets all height style options (Height, MinHeight, and MaxHeight) to the given fixed height unit value.
func (*Style) SetFixedWidth ¶
SetFixedWidth sets all width style options (Width, MinWidth, and MaxWidth) to the given fixed width unit value.
func (*Style) SetMinPrefHeight ¶
SetMinPrefHeight sets minimum and preferred height; will get at least this amount; max unspecified.
func (*Style) SetMinPrefWidth ¶
SetMinPrefWidth sets minimum and preferred width; will get at least this amount; max unspecified.
func (*Style) SetStretchMax ¶
func (s *Style) SetStretchMax()
SetStretchMax sets stretchy max width and height (-1); can grow to take up avail room.
func (*Style) SetStretchMaxHeight ¶
func (s *Style) SetStretchMaxHeight()
SetStretchMaxHeight sets stretchy max height (-1); can grow to take up avail room.
func (*Style) SetStretchMaxWidth ¶
func (s *Style) SetStretchMaxWidth()
SetStretchMaxWidth sets stretchy max width (-1); can grow to take up avail room.
func (*Style) StyleFromProps ¶
StyleFromProps sets style field values based on map[string]any properties
func (*Style) StyleToDots ¶
StyleToDots runs ToDots on unit values, to compile down to raw pixels
func (*Style) ToDots ¶
func (s *Style) ToDots()
ToDots caches all style elements in terms of raw pixel dots for rendering.
func (*Style) ToDotsImpl ¶
ToDotsImpl runs ToDots on unit values, to compile down to raw pixels
type StyleFunc ¶
func StyleFuncBool ¶
StyleFuncBool returns a style function for a bool value
func StyleFuncEnum ¶
StyleFuncEnum returns a style function for any enum value
func StyleFuncFloat ¶
StyleFuncFloat returns a style function for any numerical value
func StyleFuncInt ¶
StyleFuncInt returns a style function for any numerical value
type Text ¶
type Text struct { // prop: text-align (inherited) = how to align text, horizontally. This *only* applies to the text within its containing element, and is typically relevant only for multi-line text: for single-line text, if element does not have a specified size that is different from the text size, then this has *no effect*. Align Align `` /* 346-byte string literal not displayed */ // prop: text-vertical-align (inherited) = vertical alignment of text. This *only* applies to the text within its containing element -- if that element does not have a specified size that is different from the text size, then this has *no effect*. AlignV Align `` /* 292-byte string literal not displayed */ // prop: text-anchor (inherited) = for svg rendering only: determines the alignment relative to text position coordinate: for RTL start is right, not left, and start is top for TB Anchor TextAnchors `` /* 216-byte string literal not displayed */ // prop: letter-spacing = spacing between characters and lines LetterSpacing units.Value `xml:"letter-spacing" desc:"prop: letter-spacing = spacing between characters and lines"` // prop: word-spacing (inherited) = extra space to add between words WordSpacing units.Value `xml:"word-spacing" inherit:"true" desc:"prop: word-spacing (inherited) = extra space to add between words"` // prop: line-height (inherited) = specified height of a line of text; text is centered within the overall lineheight; the standard way to specify line height is in terms of em LineHeight units.Value `` /* 213-byte string literal not displayed */ // prop: white-space (*not* inherited) = specifies how white space is processed, and how lines are wrapped WhiteSpace WhiteSpaces `` /* 128-byte string literal not displayed */ // prop: unicode-bidi (inherited) = determines how to treat unicode bidirectional information UnicodeBidi UnicodeBidi `` /* 131-byte string literal not displayed */ // prop: direction (inherited) = direction of text -- only applicable for unicode-bidi = bidi-override or embed -- applies to all text elements Direction TextDirections `` /* 178-byte string literal not displayed */ // prop: writing-mode (inherited) = overall writing mode -- only for text elements, not tspan WritingMode TextDirections `` /* 131-byte string literal not displayed */ // prop: glyph-orientation-vertical (inherited) = for TBRL writing mode (only), determines orientation of alphabetic characters -- 90 is default (rotated) -- 0 means keep upright OrientationVert float32 `` /* 230-byte string literal not displayed */ // prop: glyph-orientation-horizontal (inherited) = for horizontal LR/RL writing mode (only), determines orientation of all characters -- 0 is default (upright) OrientationHoriz float32 `` /* 214-byte string literal not displayed */ // prop: text-indent (inherited) = how much to indent the first line in a paragraph Indent units.Value `xml:"text-indent" inherit:"true" desc:"prop: text-indent (inherited) = how much to indent the first line in a paragraph"` // prop: para-spacing (inherited) = extra spacing between paragraphs -- copied from Style.Margin per CSS spec if that is non-zero, else can be set directly with para-spacing ParaSpacing units.Value `` /* 211-byte string literal not displayed */ // prop: tab-size (inherited) = tab size, in number of characters TabSize int `xml:"tab-size" inherit:"true" desc:"prop: tab-size (inherited) = tab size, in number of characters"` }
Text is used for layout-level (widget, html-style) text styling -- FontStyle contains all the lower-level text rendering info used in SVG -- most of these are inherited
func (*Text) AlignFactors ¶
AlignFactors gets basic text alignment factors
func (*Text) EffLineHeight ¶
EffLineHeight returns the effective line height for the given font height, handling the LineHeightNormal special case.
func (*Text) HasPre ¶
HasPre returns true if current white space option preserves existing whitespace (or at least requires that parser in case of PreLine, which is intermediate)
func (*Text) HasWordWrap ¶
HasWordWrap returns true if current white space option supports word wrap
func (*Text) InheritFields ¶
InheritFields from parent: Manual inheriting of values is much faster than automatic version!
func (*Text) SetStylePost ¶
type TextAnchors ¶
type TextAnchors int32 //enums:enum
TextAnchors are for direction of text writing, used in direction and writing-mode styles
const ( AnchorStart TextAnchors = iota AnchorMiddle AnchorEnd )
const TextAnchorsN TextAnchors = 3
TextAnchorsN is the highest valid value for type TextAnchors, plus one.
func TextAnchorsValues ¶
func TextAnchorsValues() []TextAnchors
TextAnchorsValues returns all possible values for the type TextAnchors.
func (TextAnchors) Desc ¶
func (i TextAnchors) Desc() string
Desc returns the description of the TextAnchors value.
func (TextAnchors) Int64 ¶
func (i TextAnchors) Int64() int64
Int64 returns the TextAnchors value as an int64.
func (TextAnchors) IsValid ¶
func (i TextAnchors) IsValid() bool
IsValid returns whether the value is a valid option for type TextAnchors.
func (TextAnchors) MarshalText ¶
func (i TextAnchors) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*TextAnchors) SetInt64 ¶
func (i *TextAnchors) SetInt64(in int64)
SetInt64 sets the TextAnchors value from an int64.
func (*TextAnchors) SetString ¶
func (i *TextAnchors) SetString(s string) error
SetString sets the TextAnchors value from its string representation, and returns an error if the string is invalid.
func (TextAnchors) String ¶
func (i TextAnchors) String() string
String returns the string representation of this TextAnchors value.
func (*TextAnchors) UnmarshalText ¶
func (i *TextAnchors) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (TextAnchors) Values ¶
func (i TextAnchors) Values() []enums.Enum
Values returns all possible values for the type TextAnchors.
type TextDecorations ¶
type TextDecorations int64 //enums:bitflag
TextDecorations are underline, line-through, etc -- operates as bit flags -- also used for additional layout hints for RuneRender
const ( DecoNone TextDecorations = iota DecoUnderline DecoOverline DecoLineThrough // Blink is not currently supported (and probably a bad idea generally ;) DecoBlink // DottedUnderline is used for abbr tag -- otherwise not a standard text-decoration option afaik DecoDottedUnderline // DecoParaStart at start of a SpanRender indicates that it should be // styled as the start of a new paragraph and not just the start of a new // line DecoParaStart // DecoSuper indicates super-scripted text DecoSuper // DecoSub indicates sub-scripted text DecoSub // DecoBackgroundColor indicates that a bg color has been set -- for use in optimizing rendering DecoBackgroundColor )
const TextDecorationsN TextDecorations = 10
TextDecorationsN is the highest valid value for type TextDecorations, plus one.
func TextDecorationsValues ¶
func TextDecorationsValues() []TextDecorations
TextDecorationsValues returns all possible values for the type TextDecorations.
func (TextDecorations) BitIndexString ¶
func (i TextDecorations) BitIndexString() string
BitIndexString returns the string representation of this TextDecorations value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (TextDecorations) Desc ¶
func (i TextDecorations) Desc() string
Desc returns the description of the TextDecorations value.
func (TextDecorations) HasFlag ¶
func (i TextDecorations) HasFlag(f enums.BitFlag) bool
HasFlag returns whether these bit flags have the given bit flag set.
func (TextDecorations) Int64 ¶
func (i TextDecorations) Int64() int64
Int64 returns the TextDecorations value as an int64.
func (TextDecorations) IsValid ¶
func (i TextDecorations) IsValid() bool
IsValid returns whether the value is a valid option for type TextDecorations.
func (TextDecorations) MarshalText ¶
func (i TextDecorations) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*TextDecorations) SetFlag ¶
func (i *TextDecorations) SetFlag(on bool, f ...enums.BitFlag)
SetFlag sets the value of the given flags in these flags to the given value.
func (*TextDecorations) SetInt64 ¶
func (i *TextDecorations) SetInt64(in int64)
SetInt64 sets the TextDecorations value from an int64.
func (*TextDecorations) SetString ¶
func (i *TextDecorations) SetString(s string) error
SetString sets the TextDecorations value from its string representation, and returns an error if the string is invalid.
func (*TextDecorations) SetStringOr ¶
func (i *TextDecorations) SetStringOr(s string) error
SetStringOr sets the TextDecorations value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (TextDecorations) String ¶
func (i TextDecorations) String() string
String returns the string representation of this TextDecorations value.
func (*TextDecorations) UnmarshalText ¶
func (i *TextDecorations) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (TextDecorations) Values ¶
func (i TextDecorations) Values() []enums.Enum
Values returns all possible values for the type TextDecorations.
type TextDirections ¶
type TextDirections int32 //enums:enum
TextDirections are for direction of text writing, used in direction and writing-mode styles
const ( LRTB TextDirections = iota RLTB TBRL LR RL TB LTR RTL )
const TextDirectionsN TextDirections = 8
TextDirectionsN is the highest valid value for type TextDirections, plus one.
func TextDirectionsValues ¶
func TextDirectionsValues() []TextDirections
TextDirectionsValues returns all possible values for the type TextDirections.
func (TextDirections) Desc ¶
func (i TextDirections) Desc() string
Desc returns the description of the TextDirections value.
func (TextDirections) Int64 ¶
func (i TextDirections) Int64() int64
Int64 returns the TextDirections value as an int64.
func (TextDirections) IsValid ¶
func (i TextDirections) IsValid() bool
IsValid returns whether the value is a valid option for type TextDirections.
func (TextDirections) MarshalText ¶
func (i TextDirections) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*TextDirections) SetInt64 ¶
func (i *TextDirections) SetInt64(in int64)
SetInt64 sets the TextDirections value from an int64.
func (*TextDirections) SetString ¶
func (i *TextDirections) SetString(s string) error
SetString sets the TextDirections value from its string representation, and returns an error if the string is invalid.
func (TextDirections) String ¶
func (i TextDirections) String() string
String returns the string representation of this TextDirections value.
func (*TextDirections) UnmarshalText ¶
func (i *TextDirections) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (TextDirections) Values ¶
func (i TextDirections) Values() []enums.Enum
Values returns all possible values for the type TextDirections.
type UnicodeBidi ¶
type UnicodeBidi int32 //enums:enum
https://godoc.org/golang.org/x/text/unicode/bidi UnicodeBidi determines how
const ( BidiNormal UnicodeBidi = iota BidiEmbed BidiBidiOverride )
const UnicodeBidiN UnicodeBidi = 3
UnicodeBidiN is the highest valid value for type UnicodeBidi, plus one.
func UnicodeBidiValues ¶
func UnicodeBidiValues() []UnicodeBidi
UnicodeBidiValues returns all possible values for the type UnicodeBidi.
func (UnicodeBidi) Desc ¶
func (i UnicodeBidi) Desc() string
Desc returns the description of the UnicodeBidi value.
func (UnicodeBidi) Int64 ¶
func (i UnicodeBidi) Int64() int64
Int64 returns the UnicodeBidi value as an int64.
func (UnicodeBidi) IsValid ¶
func (i UnicodeBidi) IsValid() bool
IsValid returns whether the value is a valid option for type UnicodeBidi.
func (UnicodeBidi) MarshalText ¶
func (i UnicodeBidi) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*UnicodeBidi) SetInt64 ¶
func (i *UnicodeBidi) SetInt64(in int64)
SetInt64 sets the UnicodeBidi value from an int64.
func (*UnicodeBidi) SetString ¶
func (i *UnicodeBidi) SetString(s string) error
SetString sets the UnicodeBidi value from its string representation, and returns an error if the string is invalid.
func (UnicodeBidi) String ¶
func (i UnicodeBidi) String() string
String returns the string representation of this UnicodeBidi value.
func (*UnicodeBidi) UnmarshalText ¶
func (i *UnicodeBidi) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (UnicodeBidi) Values ¶
func (i UnicodeBidi) Values() []enums.Enum
Values returns all possible values for the type UnicodeBidi.
type VectorEffects ¶
type VectorEffects int32 //enums:enum
VectorEffects contains special effects for rendering
const ( VecEffNone VectorEffects = iota // VecEffNonScalingStroke means that the stroke width is not affected by // transform properties VecEffNonScalingStroke )
const VectorEffectsN VectorEffects = 2
VectorEffectsN is the highest valid value for type VectorEffects, plus one.
func VectorEffectsValues ¶
func VectorEffectsValues() []VectorEffects
VectorEffectsValues returns all possible values for the type VectorEffects.
func (VectorEffects) Desc ¶
func (i VectorEffects) Desc() string
Desc returns the description of the VectorEffects value.
func (VectorEffects) Int64 ¶
func (i VectorEffects) Int64() int64
Int64 returns the VectorEffects value as an int64.
func (VectorEffects) IsValid ¶
func (i VectorEffects) IsValid() bool
IsValid returns whether the value is a valid option for type VectorEffects.
func (VectorEffects) MarshalText ¶
func (i VectorEffects) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*VectorEffects) SetInt64 ¶
func (i *VectorEffects) SetInt64(in int64)
SetInt64 sets the VectorEffects value from an int64.
func (*VectorEffects) SetString ¶
func (i *VectorEffects) SetString(s string) error
SetString sets the VectorEffects value from its string representation, and returns an error if the string is invalid.
func (VectorEffects) String ¶
func (i VectorEffects) String() string
String returns the string representation of this VectorEffects value.
func (*VectorEffects) UnmarshalText ¶
func (i *VectorEffects) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (VectorEffects) Values ¶
func (i VectorEffects) Values() []enums.Enum
Values returns all possible values for the type VectorEffects.
type WhiteSpaces ¶
type WhiteSpaces int32 //enums:enum
WhiteSpaces determine how white space is processed
const ( // WhiteSpaceNormal means that all white space is collapsed to a single // space, and text wraps when necessary WhiteSpaceNormal WhiteSpaces = iota // WhiteSpaceNowrap means that sequences of whitespace will collapse into // a single whitespace. Text will never wrap to the next line. The text // continues on the same line until a <br> tag is encountered WhiteSpaceNowrap // WhiteSpacePre means that whitespace is preserved by the browser. Text // will only wrap on line breaks. Acts like the <pre> tag in HTML. This // invokes a different hand-written parser because the default golang // parser automatically throws away whitespace WhiteSpacePre // WhiteSpacePreLine means that sequences of whitespace will collapse // into a single whitespace. Text will wrap when necessary, and on line // breaks WhiteSpacePreLine // WhiteSpacePreWrap means that whitespace is preserved by the // browser. Text will wrap when necessary, and on line breaks WhiteSpacePreWrap )
const WhiteSpacesN WhiteSpaces = 5
WhiteSpacesN is the highest valid value for type WhiteSpaces, plus one.
func WhiteSpacesValues ¶
func WhiteSpacesValues() []WhiteSpaces
WhiteSpacesValues returns all possible values for the type WhiteSpaces.
func (WhiteSpaces) Desc ¶
func (i WhiteSpaces) Desc() string
Desc returns the description of the WhiteSpaces value.
func (WhiteSpaces) Int64 ¶
func (i WhiteSpaces) Int64() int64
Int64 returns the WhiteSpaces value as an int64.
func (WhiteSpaces) IsValid ¶
func (i WhiteSpaces) IsValid() bool
IsValid returns whether the value is a valid option for type WhiteSpaces.
func (WhiteSpaces) MarshalText ¶
func (i WhiteSpaces) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*WhiteSpaces) SetInt64 ¶
func (i *WhiteSpaces) SetInt64(in int64)
SetInt64 sets the WhiteSpaces value from an int64.
func (*WhiteSpaces) SetString ¶
func (i *WhiteSpaces) SetString(s string) error
SetString sets the WhiteSpaces value from its string representation, and returns an error if the string is invalid.
func (WhiteSpaces) String ¶
func (i WhiteSpaces) String() string
String returns the string representation of this WhiteSpaces value.
func (*WhiteSpaces) UnmarshalText ¶
func (i *WhiteSpaces) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (WhiteSpaces) Values ¶
func (i WhiteSpaces) Values() []enums.Enum
Values returns all possible values for the type WhiteSpaces.