Documentation
¶
Overview ¶
Package styles contains the style structures for the Cogent Core GUI framework.
These are all based on the CSS standard: https://www.w3schools.com/cssref/default.asp
Package styles provides style objects containing style properties used for GUI widgets and other rendering contexts.
Index ¶
- Variables
- func AlignFactor(al Aligns) float32
- func AlignPos(align Aligns, inner, outer float32) float32
- func BoxShadowMargin(shadows []Shadow) sides.Floats
- func ClampMax(v, mx float32) float32
- func ClampMaxVector(v, mx math32.Vector2) math32.Vector2
- func ClampMin(v, mn float32) float32
- func ClampMinVector(v, mn math32.Vector2) math32.Vector2
- func ObjectSizeFromFit(fit ObjectFits, obj, box math32.Vector2) math32.Vector2
- func SetClampMax(v *float32, mx float32)
- func SetClampMaxVector(v *math32.Vector2, mx math32.Vector2)
- func SetClampMin(v *float32, mn float32)
- func SetClampMinVector(v *math32.Vector2, mn math32.Vector2)
- func SubProperties(prp map[string]any, selector string) (map[string]any, bool)
- func ToCSS(s *Style, idName, htmlName string) string
- type AlignSet
- type Aligns
- func (i Aligns) Desc() string
- func (i Aligns) Int64() int64
- func (i Aligns) MarshalText() ([]byte, error)
- func (i *Aligns) SetInt64(in int64)
- func (i *Aligns) SetString(s string) error
- func (i Aligns) String() string
- func (i *Aligns) UnmarshalText(text []byte) error
- func (i Aligns) Values() []enums.Enum
- type Border
- type BorderStyles
- func (i BorderStyles) Desc() string
- func (i BorderStyles) Int64() int64
- 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 Directions
- func (i Directions) Desc() string
- func (d Directions) Dim() math32.Dims
- func (i Directions) Int64() int64
- func (i Directions) MarshalText() ([]byte, error)
- func (d Directions) Other() Directions
- func (i *Directions) SetInt64(in int64)
- func (i *Directions) SetString(s string) error
- func (i Directions) String() string
- func (i *Directions) UnmarshalText(text []byte) error
- func (i Directions) Values() []enums.Enum
- type Displays
- func (i Displays) Desc() string
- func (i Displays) Int64() int64
- func (i Displays) MarshalText() ([]byte, error)
- func (i *Displays) SetInt64(in int64)
- func (i *Displays) SetString(s string) error
- func (i Displays) String() string
- func (i *Displays) UnmarshalText(text []byte) error
- func (i Displays) Values() []enums.Enum
- type Fill
- type Font
- func (fs *Font) Defaults()
- func (fs *Font) FontHeight() float32
- func (s *Font) FromProperties(parent *Font, properties map[string]any, ctxt colors.Context)
- func (s *Font) FromProperty(parent *Font, key string, val any, cc colors.Context)
- func (fs *Font) InheritFields(parent *Font)
- func (fs *Font) SetDecoration(deco ...rich.Decorations) *Font
- func (fs *Font) SetRich(sty *rich.Style)
- func (fs *Font) SetUnitContext(uc *units.Context)
- func (fs *Font) ToDots(uc *units.Context)
- type ObjectFits
- func (i ObjectFits) Desc() string
- func (i ObjectFits) Int64() int64
- func (i ObjectFits) MarshalText() ([]byte, error)
- func (i *ObjectFits) SetInt64(in int64)
- func (i *ObjectFits) SetString(s string) error
- func (i ObjectFits) String() string
- func (i *ObjectFits) UnmarshalText(text []byte) error
- func (i ObjectFits) Values() []enums.Enum
- type Overflows
- func (i Overflows) Desc() string
- func (i Overflows) Int64() int64
- func (i Overflows) MarshalText() ([]byte, error)
- func (i *Overflows) SetInt64(in int64)
- func (i *Overflows) SetString(s string) error
- func (i Overflows) String() string
- func (i *Overflows) UnmarshalText(text []byte) error
- func (i Overflows) Values() []enums.Enum
- type Paint
- func (pc *Paint) CopyStyleFrom(cp *Paint)
- func (pc *Paint) Defaults()
- func (pc *Paint) FromStyle(st *Style)
- func (pc *Paint) GetProperties(properties map[string]any)
- func (pc *Paint) InheritFields(parent *Paint)
- func (pc *Paint) SetProperties(parent *Paint, properties map[string]any, ctxt colors.Context)
- func (pc *Paint) SetUnitContextExt(size image.Point)
- func (pc *Paint) ToDots()
- func (pc *Paint) ToDotsImpl(uc *units.Context)
- type Path
- func (pc *Path) CopyStyleFrom(cp *Path)
- func (pc *Path) Defaults()
- func (pc *Path) FromStyle(st *Style)
- func (pc *Path) GetProperties(properties map[string]any)
- func (pc *Path) HasFill() bool
- func (pc *Path) HasStroke() bool
- func (pc *Path) SetProperties(parent *Path, properties map[string]any, ctxt colors.Context)
- func (pc *Path) ToDotsImpl(uc *units.Context)
- type Shadow
- func (s *Shadow) BasePos(startPos math32.Vector2) math32.Vector2
- func (s *Shadow) BaseSize(startSize math32.Vector2) math32.Vector2
- func (s *Shadow) HasShadow() bool
- func (s *Shadow) Margin() sides.Floats
- func (s *Shadow) Pos(startPos math32.Vector2) math32.Vector2
- func (s *Shadow) Size(startSize math32.Vector2) math32.Vector2
- func (s *Shadow) ToDots(uc *units.Context)
- type Stroke
- type Style
- func (s *Style) AbilityIs(able abilities.Abilities) bool
- func (s *Style) AddBoxShadow(shadow ...Shadow)
- func (s *Style) BoxShadowMargin() sides.Floats
- func (s *Style) BoxShadowToDots(uc *units.Context)
- func (s *Style) BoxSpace() sides.Floats
- func (s *Style) CenterAll()
- func (s *Style) ComputeActualBackground(pabg image.Image)
- func (s *Style) ComputeActualBackgroundFor(bg, pabg image.Image) image.Image
- func (s *Style) Defaults()
- func (s *Style) FromProperty(parent *Style, key string, val any, cc colors.Context)
- func (s *Style) HasBoxShadow() bool
- func (s *Style) InheritFields(parent *Style)
- func (s *Style) Is(st states.States) bool
- func (s *Style) IsFlexWrap() bool
- func (s *Style) IsReadOnly() bool
- func (s *Style) LayoutDefaults()
- func (s *Style) LayoutToDots(uc *units.Context)
- func (s *Style) LineHeightDots() float32
- func (s *Style) MaxBoxShadowMargin() sides.Floats
- func (s *Style) NewRichText() (sty *rich.Style, tsty *text.Style)
- func (s *Style) ResizeImage(img image.Image, box math32.Vector2) image.Image
- func (s *Style) SetAbilities(on bool, able ...abilities.Abilities)
- func (s *Style) SetEnabled(on bool) *Style
- func (s *Style) SetNonSelectable()
- func (s *Style) SetReadOnly(ro bool)
- func (s *Style) SetRichText(sty *rich.Style, tsty *text.Style)
- func (s *Style) SetState(on bool, state ...states.States) *Style
- func (s *Style) SetTextWrap(wrap bool)
- func (s *Style) ToDots()
- func (s *Style) ToDotsImpl(uc *units.Context)
- func (s *Style) TotalMargin() sides.Floats
- type Text
- func (ts *Text) Defaults()
- func (s *Text) FromProperties(parent *Text, properties map[string]any, ctxt colors.Context)
- func (s *Text) FromProperty(parent *Text, key string, val any, cc colors.Context)
- func (ts *Text) InheritFields(parent *Text)
- func (ts *Text) SetText(tsty *text.Style)
- func (ts *Text) ToDots(uc *units.Context)
- type VirtualKeyboards
- func (i VirtualKeyboards) Desc() string
- func (i VirtualKeyboards) Int64() int64
- func (i VirtualKeyboards) MarshalText() ([]byte, error)
- func (i *VirtualKeyboards) SetInt64(in int64)
- func (i *VirtualKeyboards) SetString(s string) error
- func (i VirtualKeyboards) String() string
- func (i *VirtualKeyboards) UnmarshalText(text []byte) error
- func (i VirtualKeyboards) Values() []enums.Enum
- type XY
Constants ¶
This section is empty.
Variables ¶
var ( // BorderRadiusExtraSmall indicates to use extra small // 4dp rounded corners BorderRadiusExtraSmall = sides.NewValues(units.Dp(4)) // BorderRadiusExtraSmallTop indicates to use extra small // 4dp rounded corners on the top of the element and no // border radius on the bottom of the element BorderRadiusExtraSmallTop = sides.NewValues(units.Dp(4), units.Dp(4), units.Zero(), units.Zero()) // BorderRadiusSmall indicates to use small // 8dp rounded corners BorderRadiusSmall = sides.NewValues(units.Dp(8)) // BorderRadiusMedium indicates to use medium // 12dp rounded corners BorderRadiusMedium = sides.NewValues(units.Dp(12)) // BorderRadiusLarge indicates to use large // 16dp rounded corners BorderRadiusLarge = sides.NewValues(units.Dp(16)) // BorderRadiusLargeEnd indicates to use large // 16dp rounded corners on the end (right side) // of the element and no border radius elsewhere BorderRadiusLargeEnd = sides.NewValues(units.Zero(), units.Dp(16), units.Dp(16), units.Zero()) // BorderRadiusLargeTop indicates to use large // 16dp rounded corners on the top of the element // and no border radius on the bottom of the element BorderRadiusLargeTop = sides.NewValues(units.Dp(16), units.Dp(16), units.Zero(), units.Zero()) // BorderRadiusExtraLarge indicates to use extra large // 28dp rounded corners BorderRadiusExtraLarge = sides.NewValues(units.Dp(28)) // BorderRadiusExtraLargeTop indicates to use extra large // 28dp rounded corners on the top of the element // and no border radius on the bottom of the element BorderRadiusExtraLargeTop = sides.NewValues(units.Dp(28), units.Dp(28), units.Zero(), units.Zero()) // 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 = sides.NewValues(units.Dp(1_000_000_000)) )
Pre-configured border radius values, based on https://m3.material.io/styles/shape/shape-scale-tokens
var DefaultScrollbarWidth = units.Dp(10)
DefaultScrollbarWidth is the default [Style.ScrollbarWidth].
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
Functions ¶
func AlignFactor ¶
func AlignPos ¶
AlignPos returns the position offset based on Align.X,Y settings for given inner-sized box within given outer-sized container box.
func BoxShadowMargin ¶
BoxShadowMargin returns the maximum effective box shadow margin of the given box shadows, calculated through Shadow.Margin.
func ClampMaxVector ¶ added in v0.0.10
ClampMaxVector returns given Vector2 values, not greater than given max _only if_ max > 0
func ClampMinVector ¶ added in v0.0.10
ClampMinVector returns given Vector2 values, not less than given min _only if_ min > 0
func ObjectSizeFromFit ¶ added in v0.0.3
func ObjectSizeFromFit(fit ObjectFits, obj, box math32.Vector2) math32.Vector2
ObjectSizeFromFit returns the target object size based on the given ObjectFits setting, original object size, and target box size for the object to fit into.
func SetClampMax ¶
SetClampMax ensures the given value is not greater than given max _only if_ max > 0
func SetClampMaxVector ¶ added in v0.0.10
SetClampMaxVector ensures the given Vector2 values are not greater than given max _only if_ max > 0
func SetClampMin ¶
SetClampMin ensures the given value is not less than given min _only if_ min > 0
func SetClampMinVector ¶ added in v0.0.10
SetClampMinVector ensures the given Vector2 values are not less than given min _only if_ min > 0
func SubProperties ¶ added in v0.0.10
SubProperties returns a sub-property map from given prop map for a given styling selector (property name) -- e.g., :normal :active :hover etc -- returns false if not found
Types ¶
type AlignSet ¶
type AlignSet struct { // Content specifies the distribution of the entire collection of items within // any larger amount of space allocated to the container. By contrast, Items // and Self specify distribution within the individual element's allocated space. Content Aligns // Items specifies the distribution within the individual element's allocated space, // as a default for all items within a collection. Items Aligns // Self specifies the distribution within the individual element's allocated space, // for this specific item. Auto defaults to containers Items setting. Self Aligns }
AlignSet specifies the 3 levels of Justify or Align: Content, Items, and Self
type Aligns ¶
type Aligns int32 //enums:enum -transform kebab
Aligns has all different types of alignment and justification.
const ( // Auto means the item uses the container's AlignItems value Auto Aligns = iota // Align items to the start (top, left) of layout Start // Align items to the end (bottom, right) of layout End // Align items centered Center // Align to text baselines Baseline // First and last are flush, equal space between remaining items SpaceBetween // First and last have 1/2 space at edges, full space between remaining items SpaceAround // Equal space at start, end, and between all items SpaceEvenly )
const AlignsN Aligns = 8
AlignsN is the highest valid value for type Aligns, plus one.
func AlignsValues ¶
func AlignsValues() []Aligns
AlignsValues returns all possible values for the type Aligns.
func (Aligns) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Aligns) SetString ¶
SetString sets the Aligns value from its string representation, and returns an error if the string is invalid.
func (*Aligns) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Border ¶
type Border struct { // Style specifies how to draw the border Style sides.Sides[BorderStyles] // Width specifies the width of the border Width sides.Values `display:"inline"` // Radius specifies the radius (rounding) of the corners Radius sides.Values `display:"inline"` // Offset specifies how much, if any, the border is offset // from its element. It is only applicable in the standard // box model, which is used by [paint.Painter.DrawStdBox] and // all standard GUI elements. Offset sides.Values `display:"inline"` // Color specifies the color of the border Color sides.Sides[image.Image] `display:"inline"` }
Border contains style parameters for borders
type BorderStyles ¶
type BorderStyles int32 //enums:enum -trim-prefix Border -transform kebab
BorderStyles determines how to draw the border
const ( // BorderSolid indicates to render a solid border. BorderSolid BorderStyles = iota // BorderDotted indicates to render a dotted border. BorderDotted // BorderDashed indicates to render a dashed border. BorderDashed // BorderDouble is not currently supported. BorderDouble // BorderGroove is not currently supported. BorderGroove // BorderRidge is not currently supported. BorderRidge // BorderInset is not currently supported. BorderInset // BorderOutset is not currently supported. BorderOutset // BorderNone indicates to render no border. BorderNone )
const BorderStylesN BorderStyles = 9
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) 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 Directions ¶
type Directions int32 //enums:enum -transform kebab
Direction specifies the way in which elements are laid out, or the dimension on which an element is longer / travels in.
const ( // Row indicates that elements are laid out in a row // or that an element is longer / travels in the x dimension. Row Directions = iota // Column indicates that elements are laid out in a column // or that an element is longer / travels in the y dimension. Column )
const DirectionsN Directions = 2
DirectionsN is the highest valid value for type Directions, plus one.
func DirectionsValues ¶
func DirectionsValues() []Directions
DirectionsValues returns all possible values for the type Directions.
func (Directions) Desc ¶
func (i Directions) Desc() string
Desc returns the description of the Directions value.
func (Directions) Dim ¶
func (d Directions) Dim() math32.Dims
Dim returns the corresponding dimension for the direction.
func (Directions) Int64 ¶
func (i Directions) Int64() int64
Int64 returns the Directions value as an int64.
func (Directions) MarshalText ¶
func (i Directions) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (Directions) Other ¶
func (d Directions) Other() Directions
Other returns the opposite (other) direction.
func (*Directions) SetInt64 ¶
func (i *Directions) SetInt64(in int64)
SetInt64 sets the Directions value from an int64.
func (*Directions) SetString ¶
func (i *Directions) SetString(s string) error
SetString sets the Directions value from its string representation, and returns an error if the string is invalid.
func (Directions) String ¶
func (i Directions) String() string
String returns the string representation of this Directions value.
func (*Directions) UnmarshalText ¶
func (i *Directions) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (Directions) Values ¶
func (i Directions) Values() []enums.Enum
Values returns all possible values for the type Directions.
type Displays ¶
type Displays int32 //enums:enum -trim-prefix Display -transform kebab
Displays determines how items are displayed.
const ( // Flex is the default layout model, based on a simplified version of the // CSS flex layout: uses MainAxis to specify the direction, Wrap for // wrapping of elements, and Min, Max, and Grow values on elements to // determine sizing. Flex Displays = iota // Stacked is a stack of elements, with one on top that is visible Stacked // Grid is the X, Y grid layout, with Columns specifying the number // of elements in the X axis. Grid // Custom means that no automatic layout will be applied to elements, // which can then be managed via custom code by setting the [Style.Pos] position. Custom // None means the item is not displayed: sets the Invisible state DisplayNone )
const DisplaysN Displays = 5
DisplaysN is the highest valid value for type Displays, plus one.
func DisplaysValues ¶
func DisplaysValues() []Displays
DisplaysValues returns all possible values for the type Displays.
func (Displays) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Displays) SetString ¶
SetString sets the Displays value from its string representation, and returns an error if the string is invalid.
func (*Displays) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Fill ¶
type Fill struct { // Color to use in filling; filling is off if nil. Color image.Image // Fill alpha opacity / transparency factor between 0 and 1. // This applies in addition to any alpha specified in the Color. Opacity float32 // Rule for how to fill more complex shapes with crossing lines. Rule ppath.FillRules }
Fill contains all the properties for filling a region.
type Font ¶
type Font struct { // Size of font to render (inherited). // Converted to points when getting font to use. Size units.Value // Family indicates the generic family of typeface to use, where the // specific named values to use for each are provided in the [Settings], // or [CustomFont] for [Custom]. Family rich.Family // CustomFont specifies the Custom font name for Family = Custom. CustomFont rich.FontName // Slant allows italic or oblique faces to be selected. Slant rich.Slants // Weights are the degree of blackness or stroke thickness of a font. // This value ranges from 100.0 to 900.0, with 400.0 as normal. Weight rich.Weights // Stretch is the width of a font as an approximate fraction of the normal width. // Widths range from 0.5 to 2.0 inclusive, with 1.0 as the normal width. Stretch rich.Stretch // Decorations are underline, line-through, etc, as bit flags // that must be set using [Decorations.SetFlag]. Decoration rich.Decorations }
Font contains all font styling information. Most of font information is inherited.
func (*Font) FontHeight ¶ added in v0.3.11
FontHeight returns the font height in dots (actual pixels). Only valid after ToDots has been called, as final step of styling.
func (*Font) FromProperties ¶ added in v0.3.11
FromProperties sets style field values based on the given property list.
func (*Font) FromProperty ¶ added in v0.3.11
FromProperty sets style field values based on the given property key and value.
func (*Font) SetDecoration ¶ added in v0.0.5
func (fs *Font) SetDecoration(deco ...rich.Decorations) *Font
SetDecoration sets text decoration (underline, etc), which uses bitflags to allow multiple combinations.
func (*Font) SetUnitContext ¶
SetUnitContext sets the font-specific information in the given units.Context, based on the given styles. Just uses standardized fractions of the font size for the other less common units such as ex, ch.
type ObjectFits ¶
type ObjectFits int32 //enums:enum -trim-prefix Fit -transform kebab
ObjectFits are the different ways in which a replaced element (image, video, etc) can be fit into its containing box.
const ( // FitFill indicates that the replaced object will fill // the element's entire content box, stretching if necessary. FitFill ObjectFits = iota // FitContain indicates that the replaced object will resize // as large as possible while fully fitting within the element's // content box and maintaining its aspect ratio. Therefore, // it may not fill the entire element. FitContain // FitCover indicates that the replaced object will fill // the element's entire content box, clipping if necessary. FitCover // FitNone indicates that the replaced object will not resize. FitNone // FitScaleDown indicates that the replaced object will size // as if [FitNone] or [FitContain] was specified, using // whichever will result in a smaller final size. FitScaleDown )
const ObjectFitsN ObjectFits = 5
ObjectFitsN is the highest valid value for type ObjectFits, plus one.
func ObjectFitsValues ¶
func ObjectFitsValues() []ObjectFits
ObjectFitsValues returns all possible values for the type ObjectFits.
func (ObjectFits) Desc ¶
func (i ObjectFits) Desc() string
Desc returns the description of the ObjectFits value.
func (ObjectFits) Int64 ¶
func (i ObjectFits) Int64() int64
Int64 returns the ObjectFits value as an int64.
func (ObjectFits) MarshalText ¶
func (i ObjectFits) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*ObjectFits) SetInt64 ¶
func (i *ObjectFits) SetInt64(in int64)
SetInt64 sets the ObjectFits value from an int64.
func (*ObjectFits) SetString ¶
func (i *ObjectFits) SetString(s string) error
SetString sets the ObjectFits value from its string representation, and returns an error if the string is invalid.
func (ObjectFits) String ¶
func (i ObjectFits) String() string
String returns the string representation of this ObjectFits value.
func (*ObjectFits) UnmarshalText ¶
func (i *ObjectFits) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ObjectFits) Values ¶
func (i ObjectFits) Values() []enums.Enum
Values returns all possible values for the type ObjectFits.
type Overflows ¶
type Overflows int32 //enums:enum -trim-prefix Overflow -transform kebab
overflow type -- determines what happens when there is too much stuff in a layout
const ( // OverflowVisible makes the overflow visible, meaning that the size // of the container is always at least the Min size of its contents. // No scrollbars are shown. OverflowVisible Overflows = iota // OverflowHidden hides the overflow and doesn't present scrollbars. OverflowHidden // 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. OverflowAuto // OverflowScroll means that scrollbars are always visible, // and is otherwise identical to Auto. However, only during Viewport PrefSize call, // the actual content size is used -- otherwise it behaves just like Auto. OverflowScroll )
const OverflowsN Overflows = 4
OverflowsN is the highest valid value for type Overflows, plus one.
func OverflowsValues ¶
func OverflowsValues() []Overflows
OverflowsValues returns all possible values for the type Overflows.
func (Overflows) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Overflows) SetString ¶
SetString sets the Overflows value from its string representation, and returns an error if the string is invalid.
func (*Overflows) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Paint ¶
type Paint struct { Path // Font selects font properties. Font rich.Style // Text has the text styling settings. Text text.Style // ClipPath is a clipping path for this item. ClipPath ppath.Path // Mask is a rendered image of the mask for this item. Mask image.Image }
Paint provides the styling parameters for SVG-style rendering, including the Path stroke and fill properties, and font and text properties.
func NewPaintWithContext ¶ added in v0.3.11
NewPaintWithContext returns a new Paint style with units.Context initialized from given. Pass the Styles context for example.
func (*Paint) CopyStyleFrom ¶
CopyStyleFrom copies styles from another paint
func (*Paint) GetProperties ¶ added in v0.3.11
GetProperties gets properties values from current style settings, for any non-default settings, setting name-value pairs in given map, which must be non-nil.
func (*Paint) InheritFields ¶
InheritFields from parent
func (*Paint) SetProperties ¶ added in v0.3.11
SetProperties 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 Core Scene context, 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) 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 Path ¶ added in v0.3.11
type Path struct { // Off indicates that node and everything below it are off, non-rendering. // This is auto-updated based on other settings. Off bool // Display is the user-settable flag that determines if this item // should be displayed. Display bool // Stroke (line drawing) parameters. Stroke Stroke // Fill (region filling) parameters. Fill Fill // Opacity is a global transparency alpha factor that applies to stroke and fill. Opacity float32 // Transform has our additions to the transform stack. Transform math32.Matrix2 // VectorEffect has various rendering special effects settings. VectorEffect ppath.VectorEffects // UnitContext has parameters necessary for determining unit sizes. UnitContext units.Context `display:"-"` // StyleSet indicates if the styles already been set. StyleSet bool `display:"-"` PropertiesNil bool `display:"-"` // contains filtered or unexported fields }
Path provides the styling parameters for path-level rendering: Stroke and Fill.
func (*Path) CopyStyleFrom ¶ added in v0.3.11
CopyStyleFrom copies styles from another paint
func (*Path) GetProperties ¶ added in v0.3.11
GetProperties gets properties values from current style settings, for any non-default settings, setting name-value pairs in given map, which must be non-nil.
func (*Path) SetProperties ¶ added in v0.3.11
SetProperties sets path 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 (*Path) ToDotsImpl ¶ added in v0.3.11
ToDotsImpl runs ToDots on unit values, to compile down to raw pixels
type Shadow ¶
type Shadow struct { // OffsetX is th horizontal offset of the shadow. // Positive moves it right, negative moves it left. OffsetX units.Value // OffsetY is the vertical offset of the shadow. // Positive moves it down, negative moves it up. OffsetY units.Value // Blur specifies the blur radius of the shadow. // Higher numbers make it more blurry. Blur units.Value // Spread specifies the spread radius of the shadow. // Positive numbers increase the size of the shadow, // and negative numbers decrease the size. Spread units.Value // Color specifies the color of the shadow. Color image.Image // Inset specifies whether the shadow is inset within the // box instead of outset outside of the box. // TODO: implement. Inset bool }
style parameters for shadows
func BoxShadow0 ¶
func BoxShadow0() []Shadow
BoxShadow0 returns the shadows to be used on Elevation 0 elements. There are no shadows part of BoxShadow0, so applying it is purely semantic.
func BoxShadow1 ¶
func BoxShadow1() []Shadow
BoxShadow1 contains the shadows to be used on Elevation 1 elements.
func BoxShadow2 ¶
func BoxShadow2() []Shadow
BoxShadow2 returns the shadows to be used on Elevation 2 elements.
func BoxShadow3 ¶
func BoxShadow3() []Shadow
BoxShadow3 returns the shadows to be used on Elevation 3 elements.
func BoxShadow4 ¶
func BoxShadow4() []Shadow
BoxShadow4 returns the shadows to be used on Elevation 4 elements.
func BoxShadow5 ¶
func BoxShadow5() []Shadow
BoxShadow5 returns the shadows to be used on Elevation 5 elements.
func (*Shadow) BasePos ¶
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 ¶
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 ¶
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 ¶
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 Stroke ¶
type Stroke struct { // stroke color image specification; stroking is off if nil Color image.Image // global alpha opacity / transparency factor between 0 and 1 Opacity float32 // line width Width units.Value // MinWidth is the 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 // Dashes are the dashes of the stroke. Each pair of values specifies // the amount to paint and then the amount to skip. Dashes []float32 // DashOffset is the starting offset for the dashes. DashOffset float32 // Cap specifies how to draw the end cap of stroked lines. Cap ppath.Caps // Join specifies how to join line segments. Join ppath.Joins // MiterLimit is the limit of how far to miter: must be 1 or larger. MiterLimit float32 `min:"1"` }
Stroke contains all the properties for painting a line.
func (*Stroke) ApplyBorderStyle ¶
func (ss *Stroke) ApplyBorderStyle(bs BorderStyles)
ApplyBorderStyle applies the given border style to the stroke style.
type Style ¶
type Style struct { // State holds style-relevant state flags, for convenient styling access, // given that styles typically depend on element states. State states.States // Abilities specifies the abilities of this element, which determine // which kinds of states the element can express. // This is used by the system/events system. Putting this info next // to the State info makes it easy to configure and manage. Abilities abilities.Abilities // the cursor to switch to upon hovering over the element (inherited) Cursor cursors.Cursor // Padding is the transparent space around central content of box, // which is _included_ in the size of the standard box rendering. Padding sides.Values `display:"inline"` // Margin is the outer-most transparent space around box element, // which is _excluded_ from standard box rendering. Margin sides.Values `display:"inline"` // Display controls how items are displayed, in terms of layout Display Displays // Direction specifies the way in which elements are laid out, or // the dimension on which an element is longer / travels in. Direction Directions // Wrap causes elements to wrap around in the CrossAxis dimension // to fit within sizing constraints. Wrap bool // Justify specifies the distribution of elements along the main axis, // i.e., the same as Direction, for Flex Display. For Grid, the main axis is // given by the writing direction (e.g., Row-wise for latin based languages). Justify AlignSet `display:"inline"` // Align specifies the cross-axis alignment of elements, orthogonal to the // main Direction axis. For Grid, the cross-axis is orthogonal to the // writing direction (e.g., Column-wise for latin based languages). Align AlignSet `display:"inline"` // Min is the minimum size of the actual content, exclusive of additional space // from padding, border, margin; 0 = default is sum of Min for all content // (which _includes_ space for all sub-elements). // This is equivalent to the Basis for the CSS flex styling model. Min units.XY `display:"inline"` // Max is the maximum size of the actual content, exclusive of additional space // from padding, border, margin; 0 = default provides no Max size constraint Max units.XY `display:"inline"` // Grow is the proportional amount that the element can grow (stretch) // if there is more space available. 0 = default = no growth. // Extra available space is allocated as: Grow / sum (all Grow). // Important: grow elements absorb available space and thus are not // subject to alignment (Center, End). Grow math32.Vector2 // GrowWrap is a special case for Text elements where it grows initially // in the horizontal axis to allow for longer, word wrapped text to fill // the available space, but then it does not grow thereafter, so that alignment // operations still work (Grow elements do not align because they absorb all // available space). Do NOT set this for non-Text elements. GrowWrap bool // RenderBox determines whether to render the standard box model for the element. // This is typically necessary for most elements and helps prevent text, border, // and box shadow from rendering over themselves. Therefore, it should be kept at // its default value of true in most circumstances, but it can be set to false // when the element is fully managed by something that is guaranteed to render the // appropriate background color and/or border for the element. RenderBox bool // FillMargin determines is whether to fill the margin with // the surrounding background color before rendering the element itself. // This is typically necessary to prevent text, border, and box shadow from // rendering over themselves. Therefore, it should be kept at its default value // of true in most circumstances, but it can be set to false when the element // is fully managed by something that is guaranteed to render the // appropriate background color for the element. It is irrelevant if RenderBox // is false. FillMargin bool // Overflow determines how to handle overflowing content in a layout. // Default is OverflowVisible. Set to OverflowAuto to enable scrollbars. Overflow XY[Overflows] // For layouts, extra space added between elements in the layout. Gap units.XY `display:"inline"` // For grid layouts, the number of columns to use. // If > 0, number of rows is computed as N elements / Columns. // Used as a constraint in layout if individual elements // do not specify their row, column positions Columns int // If this object is a replaced object (image, video, etc) // or has a background image, ObjectFit specifies the way // in which the replaced object should be fit into the element. ObjectFit ObjectFits // If this object is a replaced object (image, video, etc) // or has a background image, ObjectPosition specifies the // X,Y position of the object within the space allocated for // the object (see ObjectFit). ObjectPosition units.XY // Border is a rendered border around the element. Border Border // MaxBorder is the largest border that will ever be rendered // around the element, the size of which is used for computing // the effective margin to allocate for the element. MaxBorder Border // BoxShadow is the box shadows to render around box (can have multiple) BoxShadow []Shadow // MaxBoxShadow contains the largest shadows that will ever be rendered // around the element, the size of which are used for computing the // effective margin to allocate for the element. MaxBoxShadow []Shadow // Color specifies the text / content color, and it is inherited. Color image.Image // Background specifies the background of the element. It is not inherited, // and it is nil (transparent) by default. Background image.Image // alpha value between 0 and 1 to apply to the foreground and background // of this element and all of its children. Opacity float32 // StateLayer, if above zero, indicates to create a state layer over // the element with this much opacity (on a scale of 0-1) and the // color Color (or StateColor if it defined). It is automatically // set based on State, but can be overridden in stylers. StateLayer float32 // StateColor, if not nil, is the color to use for the StateLayer // instead of Color. If you want to disable state layers // for an element, do not use this; instead, set StateLayer to 0. StateColor image.Image // ActualBackground is the computed actual background rendered for the element, // taking into account its Background, Opacity, StateLayer, and parent // ActualBackground. It is automatically computed and should not be set manually. ActualBackground image.Image // VirtualKeyboard is the virtual keyboard to display, if any, // on mobile platforms when this element is focused. It is not // used if the element is read only. VirtualKeyboard VirtualKeyboards // Pos is used for the position of the widget if the parent frame // has [Style.Display] = [Custom]. Pos units.XY `display:"inline"` // ordering factor for rendering depth -- lower numbers rendered first. // Sort children according to this factor ZIndex int // specifies the row that this element should appear within a grid layout Row int // specifies the column that this element should appear within a grid layout Col int // specifies the number of sequential rows that this element should occupy // within a grid layout (todo: not currently supported) RowSpan int // specifies the number of sequential columns that this element should occupy // within a grid layout ColSpan int // ScrollbarWidth is the width of layout scrollbars. It defaults // to [DefaultScrollbarWidth], and it is inherited. ScrollbarWidth units.Value // Font styling parameters applicable to individual spans of text. Font Font // Text styling parameters applicable to a paragraph of text. Text Text // unit context: parameters necessary for anchoring relative units UnitContext units.Context }
Style contains all of the style properties used for GUI widgets.
var StyleDefault Style
StyleDefault is default style can be used when property specifies "default"
func (*Style) AbilityIs ¶
AbilityIs returns whether the given abilities.Abilities flag is set
func (*Style) AddBoxShadow ¶
AddBoxShadow adds the given box shadows to the style
func (*Style) BoxShadowMargin ¶
BoxShadowMargin returns the effective box shadow margin of the style, calculated through Shadow.Margin
func (*Style) BoxShadowToDots ¶
BoxShadowToDots runs ToDots on all box shadow unit values to compile down to raw pixels
func (*Style) BoxSpace ¶
BoxSpace returns the extra space around the central content in the box model in dots. It rounds all of the sides first.
func (*Style) CenterAll ¶ added in v0.1.1
func (s *Style) CenterAll()
CenterAll sets all of the alignment properties to Center such that all children are fully centered.
func (*Style) ComputeActualBackground ¶
ComputeActualBackground sets [Style.ActualBackground] based on the given parent actual background and the properties of the style object.
func (*Style) ComputeActualBackgroundFor ¶
ComputeActualBackgroundFor returns the actual background for the given background based on the given parent actual background and the properties of the style object.
func (*Style) FromProperty ¶ added in v0.3.11
FromProperty sets style field values based on the given property key and value
func (*Style) HasBoxShadow ¶
HasBoxShadow returns whether the style has any box shadows
func (*Style) InheritFields ¶
InheritFields from parent
func (*Style) Is ¶
Is returns whether the given states.States flag is set
func (*Style) IsFlexWrap ¶
IsFlexWrap returns whether the style is both [Style.Wrap] and Flex.
func (*Style) IsReadOnly ¶ added in v0.3.2
IsReadOnly returns whether this style object is flagged as either states.ReadOnly or states.Disabled.
func (*Style) LayoutDefaults ¶
func (s *Style) LayoutDefaults()
func (*Style) LayoutToDots ¶
ToDots runs ToDots on unit values, to compile down to raw pixels
func (*Style) LineHeightDots ¶ added in v0.3.11
LineHeightDots returns the effective line height in dots (actual pixels) as FontHeight * LineHeight
func (*Style) MaxBoxShadowMargin ¶
MaxBoxShadowMargin returns the maximum effective box shadow margin of the style, calculated through Shadow.Margin
func (*Style) NewRichText ¶ added in v0.3.11
NewRichText sets the rich.Style and text.Style properties from the style props.
func (*Style) ResizeImage ¶
ResizeImage resizes the given image according to [Style.ObjectFit] in an object of the given box size.
func (*Style) SetAbilities ¶
SetAbilities sets the given states.State flags to the given value
func (*Style) SetEnabled ¶
SetEnabled sets the Disabled State flag according to given bool
func (*Style) SetNonSelectable ¶
func (s *Style) SetNonSelectable()
SetNonSelectable turns off the Selectable and DoubleClickable abilities and sets the Cursor to None.
func (*Style) SetReadOnly ¶ added in v0.1.1
SetReadOnly sets the states.ReadOnly flag to the given value.
func (*Style) SetRichText ¶ added in v0.3.11
SetRichText sets the rich.Style and text.Style properties from the style props.
func (*Style) SetState ¶
SetState sets the given states.States flags to the given value
func (*Style) SetTextWrap ¶
SetTextWrap sets the Text.WhiteSpace and GrowWrap properties in a coordinated manner. If wrap == true, then WhiteSpaceNormal and GrowWrap = true; else WhiteSpaceNowrap and GrowWrap = false, which are typically the two desired stylings.
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
func (*Style) TotalMargin ¶
TotalMargin returns the total effective margin of the element holding the style, using the sum of the actual margin, the max border width, and the max box shadow effective margin. If the values for the max border width / box shadow are unset, the current values are used instead, which allows for the omission of the max properties when the values do not change.
type Text ¶
type Text struct { // Align specifies how to align text along the default direction (inherited). // This *only* applies to the text within its containing element, // and is relevant only for multi-line text. Align text.Aligns // AlignV specifies "vertical" (orthogonal to default direction) // alignment of text (inherited). // 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 text.Aligns // LineHeight is a multiplier on the default font size for spacing between lines. // If there are larger font elements within a line, they will be accommodated, with // the same amount of total spacing added above that maximum size as if it was all // the same height. The default of 1.3 represents standard "single spaced" text. LineHeight float32 `default:"1.3"` // WhiteSpace (not inherited) specifies how white space is processed, // and how lines are wrapped. If set to WhiteSpaceNormal (default) lines are wrapped. // See info about interactions with Grow.X setting for this and the NoWrap case. WhiteSpace text.WhiteSpaces // Direction specifies the default text direction, which can be overridden if the // unicode text is typically written in a different direction. Direction rich.Directions // TabSize specifies the tab size, in number of characters (inherited). TabSize int // SelectColor is the color to use for the background region of selected text (inherited). SelectColor image.Image // HighlightColor is the color to use for the background region of highlighted text (inherited). HighlightColor image.Image }
Text has styles for text layout styling. Most of these are inherited
func (*Text) FromProperties ¶ added in v0.3.11
FromProperties sets style field values based on the given property list.
func (*Text) FromProperty ¶ added in v0.3.11
FromProperty sets style field values based on the given property key and value.
type VirtualKeyboards ¶ added in v0.0.6
type VirtualKeyboards int32 //enums:enum -trim-prefix Keyboard -transform kebab
VirtualKeyboards are all of the supported virtual keyboard types to display on mobile platforms.
const ( // KeyboardNone indicates to display no virtual keyboard. KeyboardNone VirtualKeyboards = iota // KeyboardSingleLine indicates to display a virtual keyboard // with a default input style and a "Done" return key. KeyboardSingleLine // KeyboardMultiLine indicates to display a virtual keyboard // with a default input style and a "Return" return key. KeyboardMultiLine // KeyboardNumber indicates to display a virtual keyboard // for inputting a number. KeyboardNumber // KeyboardPassword indicates to display a virtual keyboard // for inputting a password. KeyboardPassword // KeyboardEmail indicates to display a virtual keyboard // for inputting an email address. KeyboardEmail // KeyboardPhone indicates to display a virtual keyboard // for inputting a phone number. KeyboardPhone // KeyboardURL indicates to display a virtual keyboard for // inputting a URL / URI / web address. KeyboardURL )
const VirtualKeyboardsN VirtualKeyboards = 8
VirtualKeyboardsN is the highest valid value for type VirtualKeyboards, plus one.
func VirtualKeyboardsValues ¶ added in v0.0.6
func VirtualKeyboardsValues() []VirtualKeyboards
VirtualKeyboardsValues returns all possible values for the type VirtualKeyboards.
func (VirtualKeyboards) Desc ¶ added in v0.0.6
func (i VirtualKeyboards) Desc() string
Desc returns the description of the VirtualKeyboards value.
func (VirtualKeyboards) Int64 ¶ added in v0.0.6
func (i VirtualKeyboards) Int64() int64
Int64 returns the VirtualKeyboards value as an int64.
func (VirtualKeyboards) MarshalText ¶ added in v0.0.6
func (i VirtualKeyboards) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*VirtualKeyboards) SetInt64 ¶ added in v0.0.6
func (i *VirtualKeyboards) SetInt64(in int64)
SetInt64 sets the VirtualKeyboards value from an int64.
func (*VirtualKeyboards) SetString ¶ added in v0.0.6
func (i *VirtualKeyboards) SetString(s string) error
SetString sets the VirtualKeyboards value from its string representation, and returns an error if the string is invalid.
func (VirtualKeyboards) String ¶ added in v0.0.6
func (i VirtualKeyboards) String() string
String returns the string representation of this VirtualKeyboards value.
func (*VirtualKeyboards) UnmarshalText ¶ added in v0.0.6
func (i *VirtualKeyboards) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (VirtualKeyboards) Values ¶ added in v0.0.6
func (i VirtualKeyboards) Values() []enums.Enum
Values returns all possible values for the type VirtualKeyboards.
type XY ¶
type XY[T any] struct { // X is the horizontal axis value X T // Y is the vertical axis value Y T }
XY represents X,Y values
func (*XY[T]) Set ¶
func (xy *XY[T]) Set(v ...T)
Set sets the X, Y values according to the given values. no values: set to 0. 1 value: set both to that value. 2 values, set X, Y to the two values respectively.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package sides provides flexible representation of box sides or corners, with either a single value for all, or different values for subsets.
|
Package sides provides flexible representation of box sides or corners, with either a single value for all, or different values for subsets. |
Package styleprops provides infrastructure for property-list-based setting of style values, where a property list is a map[string]any collection of key, value pairs.
|
Package styleprops provides infrastructure for property-list-based setting of style values, where a property list is a map[string]any collection of key, value pairs. |
Package Units supports full range of CSS-style length units (em, px, dp, etc)
|
Package Units supports full range of CSS-style length units (em, px, dp, etc) |