Documentation ¶
Index ¶
- Variables
- func Draw(comp Component) error
- func FinishComponent(comp Component) error
- func NewCustom(id string, name string, parent Component) *custom
- type AbstractComponent
- type AccessCollector
- type AliasValue
- func (v *AliasValue) AddDependent(d Dependent)
- func (v *AliasValue) GetValue() interface{}
- func (v *AliasValue) MakeDirty(stack []Dependent)
- func (v *AliasValue) RemoveDependent(d Dependent)
- func (v *AliasValue) SetCode(code Code)
- func (v *AliasValue) SetValue(newValue interface{}) error
- func (v *AliasValue) Update(context Component) (bool, error)
- type AnchorLine
- type AnchorLineValue
- func (v *AnchorLineValue) AddDependent(d Dependent)
- func (v *AnchorLineValue) AssignTo(comp Component, lineType AnchorLine)
- func (v *AnchorLineValue) Float64() float64
- func (v *AnchorLineValue) GetValue() interface{}
- func (v *AnchorLineValue) IsAbsolute() bool
- func (v *AnchorLineValue) MakeDirty(stack []Dependent)
- func (v *AnchorLineValue) Offset() float64
- func (v *AnchorLineValue) RemoveDependent(d Dependent)
- func (v *AnchorLineValue) SetAbsolute(value float64)
- func (v *AnchorLineValue) SetCode(code Code)
- func (v *AnchorLineValue) SetOffset(offset float64)
- func (v *AnchorLineValue) SetValue(newValue interface{}) error
- func (v *AnchorLineValue) Update(context Component) (bool, error)
- type AnchorsValue
- func (a *AnchorsValue) AddDependent(Dependent)
- func (v *AnchorsValue) CalcBottomMargin() float64
- func (v *AnchorsValue) CalcLeftMargin() float64
- func (v *AnchorsValue) CalcRightMargin() float64
- func (v *AnchorsValue) CalcTopMargin() float64
- func (a *AnchorsValue) GetValue() interface{}
- func (a *AnchorsValue) Property(key string) (interface{}, bool)
- func (a *AnchorsValue) RemoveDependent(Dependent)
- func (v *AnchorsValue) ResolveVariable(name string) (interface{}, bool)
- func (a *AnchorsValue) SetCode(Code)
- func (a *AnchorsValue) SetProperty(key string, value interface{}) error
- func (a *AnchorsValue) SetPropertyCode(key string, code Code) bool
- func (a *AnchorsValue) SetValue(interface{}) error
- func (a *AnchorsValue) Update(Component) (bool, error)
- func (v *AnchorsValue) UpdateExpressions(context Component) (int, ErrorGroup)
- type AnyValue
- type AsyncFunction
- type BoolValue
- func (v *BoolValue) AddDependent(d Dependent)
- func (v *BoolValue) Bool() bool
- func (v *BoolValue) GetValue() interface{}
- func (v *BoolValue) RemoveDependent(d Dependent)
- func (v *BoolValue) SetBoolValue(newValue bool)
- func (v *BoolValue) SetCode(code Code)
- func (v *BoolValue) SetValue(newValue interface{}) error
- func (v *BoolValue) Update(context Component) (bool, error)
- type Code
- type ColorValue
- func (v *ColorValue) AddDependent(d Dependent)
- func (v *ColorValue) Color() color.Color
- func (v *ColorValue) GetValue() interface{}
- func (v *ColorValue) RGBAColor() color.RGBA
- func (v *ColorValue) RemoveDependent(d Dependent)
- func (v *ColorValue) SetCode(code Code)
- func (v *ColorValue) SetColor(newValue color.Color)
- func (v *ColorValue) SetValue(newValue interface{}) error
- func (v *ColorValue) Update(context Component) (bool, error)
- type Component
- type ComponentContainer
- type ComponentDefListValue
- func (v *ComponentDefListValue) AddDependent(d Dependent)
- func (v *ComponentDefListValue) ComponentDefinitions() []*ComponentDefinition
- func (v *ComponentDefListValue) GetValue() interface{}
- func (v *ComponentDefListValue) RemoveDependent(d Dependent)
- func (v *ComponentDefListValue) SetCode(code Code)
- func (v *ComponentDefListValue) SetComponentDefinitions(components []*ComponentDefinition)
- func (v *ComponentDefListValue) SetValue(newValue interface{}) error
- func (v *ComponentDefListValue) Update(context Component) (bool, error)
- type ComponentDefValue
- func (v *ComponentDefValue) AddDependent(d Dependent)
- func (v *ComponentDefValue) ComponentDefinition() *ComponentDefinition
- func (v *ComponentDefValue) Context() *FileContext
- func (v *ComponentDefValue) GetValue() interface{}
- func (v *ComponentDefValue) RemoveDependent(d Dependent)
- func (v *ComponentDefValue) SetCode(code Code)
- func (v *ComponentDefValue) SetComponentDefinition(component *ComponentDefinition, context *FileContext)
- func (v *ComponentDefValue) SetValue(newValue interface{}) error
- func (v *ComponentDefValue) Update(context Component) (bool, error)
- type ComponentDefinition
- type ComponentDefinitionInContext
- type ComponentDefinitionListInContext
- type ComponentRefValue
- func (v *ComponentRefValue) AddDependent(d Dependent)
- func (v *ComponentRefValue) Component() Component
- func (v *ComponentRefValue) GetValue() interface{}
- func (v *ComponentRefValue) RemoveDependent(d Dependent)
- func (v *ComponentRefValue) SetCode(code Code)
- func (v *ComponentRefValue) SetComponent(comp Component)
- func (v *ComponentRefValue) SetValue(newValue interface{}) error
- func (v *ComponentRefValue) Update(context Component) (bool, error)
- type Dependent
- type DrawingContext
- type Enumeration
- type ErrorGroup
- type Evaluater
- type EventAdapter
- type EventAttribute
- func (a *EventAttribute[EventType]) AddListener(l Listener[EventType])
- func (a *EventAttribute[EventType]) AddListenerFunction(f *AsyncFunction)
- func (a *EventAttribute[EventType]) CreateListener(code Code) Evaluater
- func (a *EventAttribute[EventType]) Fire(e *EventType)
- func (a *EventAttribute[EventType]) MaybeFire(v any) error
- func (a *EventAttribute[EventType]) RemoveListener(l Listener[EventType])
- type EventDefinition
- type EventSource
- type ExecutionEnvironment
- type Expression
- type ExpressionError
- type FileContext
- func (ctx *FileContext) Get(name string) (AbstractComponent, bool)
- func (ctx *FileContext) GetComponentByID(id string) (Component, bool)
- func (ctx *FileContext) RegisterComponent(id string, comp Component)
- func (ctx *FileContext) ResolveVariable(name string) (interface{}, bool)
- func (ctx *FileContext) UnregisterComponent(id string, comp Component)
- type FloatValue
- func (v *FloatValue) AddDependent(d Dependent)
- func (v *FloatValue) Float64() float64
- func (v *FloatValue) GetValue() interface{}
- func (v *FloatValue) RemoveDependent(d Dependent)
- func (v *FloatValue) SetCode(code Code)
- func (v *FloatValue) SetFloatValue(newValue float64)
- func (v *FloatValue) SetValue(newValue interface{}) error
- func (v *FloatValue) Update(context Component) (bool, error)
- type FocusableComponent
- type Function
- type FunctionDependency
- type FunctionValue
- func (v *FunctionValue) AddDependent(Dependent)
- func (v *FunctionValue) GetValue() interface{}
- func (v *FunctionValue) RemoveDependent(Dependent)
- func (v *FunctionValue) SetCode(Code)
- func (v *FunctionValue) SetValue(newValue interface{}) error
- func (v *FunctionValue) Update(context Component) (bool, error)
- type GlobalContext
- type GroupValue
- func (v *GroupValue) AddDependent(d Dependent)
- func (v *GroupValue) Get(key string) (Value, bool)
- func (v *GroupValue) GetValue() interface{}
- func (v *GroupValue) MustGet(key string) Value
- func (v *GroupValue) RemoveDependent(d Dependent)
- func (v *GroupValue) SetCode(code Code)
- func (v *GroupValue) SetCodeOf(key string, code Code) error
- func (v *GroupValue) SetValue(newValue interface{}) error
- func (v *GroupValue) SetValueOf(name string, newValue interface{}) error
- func (v *GroupValue) Update(context Component) (bool, error)
- type IntValue
- func (v *IntValue) AddDependent(d Dependent)
- func (v *IntValue) GetValue() interface{}
- func (v *IntValue) Int() int
- func (v *IntValue) RemoveDependent(d Dependent)
- func (v *IntValue) SetCode(code Code)
- func (v *IntValue) SetIntValue(newValue int)
- func (v *IntValue) SetValue(newValue interface{}) error
- func (v *IntValue) Update(context Component) (bool, error)
- type JSListener
- type Layout
- func (l *Layout) AckPositionChange()
- func (l *Layout) AckSizeChange()
- func (l *Layout) AckTargetSizeChange()
- func (v *Layout) AddDependent(d Dependent)
- func (l *Layout) GetHeight() (float64, bool)
- func (l *Layout) GetPreferredX() (float64, bool)
- func (l *Layout) GetPreferredY() (float64, bool)
- func (l *Layout) GetTargetHeight() (float64, bool)
- func (l *Layout) GetTargetWidth() (float64, bool)
- func (l *Layout) GetWidth() (float64, bool)
- func (l *Layout) GetX() (float64, bool)
- func (l *Layout) GetY() (float64, bool)
- func (l *Layout) PositionChanged() bool
- func (v *Layout) RemoveDependent(d Dependent)
- func (l *Layout) SetPosition(x, y *float64)
- func (l *Layout) SetPreferredPosition(x, y *float64)
- func (l *Layout) SetSize(width, height *float64)
- func (l *Layout) SetTargetSize(width, height *float64)
- func (l *Layout) SizeChanged() bool
- func (l *Layout) TargetSizeChanged() bool
- type LayoutList
- type ListValue
- func (v *ListValue) AddDependent(d Dependent)
- func (v *ListValue[ElementType]) GetValue() interface{}
- func (v *ListValue) RemoveDependent(d Dependent)
- func (v *ListValue[ElementType]) SetCode(code Code)
- func (v *ListValue[ElementType]) SetSlice(slice []ElementType)
- func (v *ListValue[ElementType]) SetValue(value interface{}) error
- func (v *ListValue[ElementType]) Slice() []ElementType
- func (v *ListValue[ElementType]) Update(context Component) (bool, error)
- type Listenable
- type Listener
- type ListenerCallback
- type MaybeSetable
- type Method
- type OptionalValue
- func (v *OptionalValue) AddDependent(d Dependent)
- func (v *OptionalValue[T]) GetValue() interface{}
- func (v *OptionalValue[T]) IsSet() bool
- func (v *OptionalValue[T]) MakeDirty(stack []Dependent)
- func (v *OptionalValue) RemoveDependent(d Dependent)
- func (v *OptionalValue[T]) SetCode(code Code)
- func (v *OptionalValue[T]) SetValue(newValue interface{}) error
- func (v *OptionalValue[T]) Update(context Component) (bool, error)
- func (v *OptionalValue[T]) Value() T
- type Position
- type PositionRange
- type PropertyDefinition
- type PropertyError
- type Rect
- func (r Rect) Bottom() float64
- func (r Rect) CenterX() float64
- func (r Rect) CenterY() float64
- func (r Rect) CenteredIn(o Rect) Rect
- func (r Rect) Contains(X, Y float64) bool
- func (r Rect) Height() float64
- func (r Rect) Left() float64
- func (r Rect) MovedX(x float64) Rect
- func (r Rect) MovedY(y float64) Rect
- func (r Rect) Right() float64
- func (r Rect) ToCanvas() canvas.Rect
- func (r Rect) Top() float64
- func (r Rect) Width() float64
- type RedeclarationError
- type Root
- func (r *Root) AddChild(child Component)
- func (r *Root) AddChildAfter(afterThis, addThis Component)
- func (r *Root) AddChildAtButKeepParent(child Component, index int)
- func (r *Root) AddChildButKeepParent(child Component)
- func (r *Root) AddListenerFunction(f Evaluater)
- func (r *Root) ApplyLayout(*Layout)
- func (r *Root) As(target *Component) bool
- func (r *Root) Bounds() Rect
- func (r *Root) Children() []Component
- func (r *Root) Context() *FileContext
- func (r *Root) DefineEnum(enum Enumeration) bool
- func (r *Root) DefineMethod(method Method) bool
- func (r *Root) DefineProperty(propDef PropertyDefinition, fileCtx *FileContext) error
- func (r *Root) Draw(ctx DrawingContext, area Rect) error
- func (r *Root) DrawChildren(ctx DrawingContext, area Rect) error
- func (r *Root) Event(name string) (Listenable, bool)
- func (r *Root) Finish() error
- func (r *Root) FinishInContext(context Component) error
- func (r *Root) ID() string
- func (r *Root) InstantiateInScope(comp *ComponentDefinition) (Component, error)
- func (r *Root) MustProperty(key string) Value
- func (r *Root) Parent() Component
- func (r *Root) Property(key string) (Value, bool)
- func (r *Root) RemoveChild(child Component)
- func (r *Root) ResolveVariable(key string) (interface{}, bool)
- func (r *Root) RootC() *Root
- func (r *Root) SetParent(parent Component)
- func (r *Root) SetProperty(key string, newValue interface{}) error
- func (r *Root) SetPropertyCode(key string, code Code) error
- func (r *Root) String() string
- func (r *Root) UpdateExpressions(context Component) (int, ErrorGroup)
- func (r *Root) UpdatePropertiesInContext(context Component) (int, ErrorGroup)
- type Set
- type StringValue
- func (v *StringValue) AddDependent(d Dependent)
- func (v *StringValue) GetValue() interface{}
- func (v *StringValue) Position() (*PositionRange, bool)
- func (v *StringValue) RemoveDependent(d Dependent)
- func (v *StringValue) SetCode(code Code)
- func (v *StringValue) SetStringValue(newValue string)
- func (v *StringValue) SetValue(newValue interface{}) error
- func (v *StringValue) String() string
- func (v *StringValue) Update(context Component) (bool, error)
- type UnknownPropertyError
- type UnknownTypeError
- type Value
Constants ¶
This section is empty.
Variables ¶
var InstantiateComponent func(*ComponentDefinition, *FileContext) (Component, error)
This will be set by the parser package at initialization. It is ugly but we can't use circular dependencies. Right now the alternative would be to pass a type from the parser package to every vit component specifically for this purpose and that's not really what I want to do either.
Functions ¶
func FinishComponent ¶
Types ¶
type AbstractComponent ¶
type AbstractComponent interface { script.VariableSource Instantiate(string, *GlobalContext) (Component, error) Name() string }
type AccessCollector ¶
type AccessCollector struct {
// contains filtered or unexported fields
}
func NewAccessCollector ¶
func NewAccessCollector(fileCtx *FileContext, context script.VariableSource) *AccessCollector
func (*AccessCollector) GetReadValues ¶
func (c *AccessCollector) GetReadValues() []Value
func (*AccessCollector) GetWrittenValues ¶
func (c *AccessCollector) GetWrittenValues() []Value
func (*AccessCollector) ResolveVariable ¶
func (c *AccessCollector) ResolveVariable(key string) (interface{}, bool)
func (*AccessCollector) SubContext ¶
func (c *AccessCollector) SubContext(context script.VariableSource) *AccessCollector
type AliasValue ¶
type AliasValue struct {
// contains filtered or unexported fields
}
Alias value points to a different value, potentially of another component
func NewAliasValueFromCode ¶
func NewAliasValueFromCode(code Code) *AliasValue
func (*AliasValue) AddDependent ¶
func (v *AliasValue) AddDependent(d Dependent)
func (*AliasValue) GetValue ¶
func (v *AliasValue) GetValue() interface{}
func (*AliasValue) MakeDirty ¶
func (v *AliasValue) MakeDirty(stack []Dependent)
func (*AliasValue) RemoveDependent ¶
func (v *AliasValue) RemoveDependent(d Dependent)
func (*AliasValue) SetCode ¶
func (v *AliasValue) SetCode(code Code)
func (*AliasValue) SetValue ¶
func (v *AliasValue) SetValue(newValue interface{}) error
type AnchorLine ¶
type AnchorLine byte
const ( AnchorsNone AnchorLine = iota AnchorLeft AnchorRight AnchorTop AnchorBottom AnchorHorizontalCenter AnchorVerticalCenter )
func (AnchorLine) PropertyName ¶
func (l AnchorLine) PropertyName() string
type AnchorLineValue ¶
type AnchorLineValue struct {
// contains filtered or unexported fields
}
func NewAnchorLineValue ¶
func NewAnchorLineValue() *AnchorLineValue
func (*AnchorLineValue) AddDependent ¶
func (v *AnchorLineValue) AddDependent(d Dependent)
func (*AnchorLineValue) AssignTo ¶
func (v *AnchorLineValue) AssignTo(comp Component, lineType AnchorLine)
func (*AnchorLineValue) Float64 ¶
func (v *AnchorLineValue) Float64() float64
func (*AnchorLineValue) GetValue ¶
func (v *AnchorLineValue) GetValue() interface{}
func (*AnchorLineValue) IsAbsolute ¶
func (v *AnchorLineValue) IsAbsolute() bool
func (*AnchorLineValue) MakeDirty ¶
func (v *AnchorLineValue) MakeDirty(stack []Dependent)
func (*AnchorLineValue) Offset ¶
func (v *AnchorLineValue) Offset() float64
func (*AnchorLineValue) RemoveDependent ¶
func (v *AnchorLineValue) RemoveDependent(d Dependent)
func (*AnchorLineValue) SetAbsolute ¶
func (v *AnchorLineValue) SetAbsolute(value float64)
func (*AnchorLineValue) SetCode ¶
func (v *AnchorLineValue) SetCode(code Code)
func (*AnchorLineValue) SetOffset ¶
func (v *AnchorLineValue) SetOffset(offset float64)
func (*AnchorLineValue) SetValue ¶
func (v *AnchorLineValue) SetValue(newValue interface{}) error
type AnchorsValue ¶
type AnchorsValue struct { Expression AlignWhenCentered BoolValue BaselineOffset OptionalValue[*FloatValue] Baseline OptionalValue[*FloatValue] Bottom OptionalValue[*FloatValue] BottomMargin OptionalValue[*FloatValue] CenterIn ComponentRefValue Fill ComponentRefValue HorizontalCenter OptionalValue[*FloatValue] HorizontalCenterOffset OptionalValue[*FloatValue] Left OptionalValue[*FloatValue] LeftMargin OptionalValue[*FloatValue] Margins OptionalValue[*FloatValue] Right OptionalValue[*FloatValue] RightMargin OptionalValue[*FloatValue] Top OptionalValue[*FloatValue] TopMargin OptionalValue[*FloatValue] VerticalCenter OptionalValue[*FloatValue] VerticalCenterOffset OptionalValue[*FloatValue] }
func NewAnchors ¶
func NewAnchors() *AnchorsValue
func (*AnchorsValue) AddDependent ¶
func (a *AnchorsValue) AddDependent(Dependent)
func (*AnchorsValue) CalcBottomMargin ¶
func (v *AnchorsValue) CalcBottomMargin() float64
func (*AnchorsValue) CalcLeftMargin ¶
func (v *AnchorsValue) CalcLeftMargin() float64
func (*AnchorsValue) CalcRightMargin ¶
func (v *AnchorsValue) CalcRightMargin() float64
func (*AnchorsValue) CalcTopMargin ¶
func (v *AnchorsValue) CalcTopMargin() float64
func (*AnchorsValue) GetValue ¶
func (a *AnchorsValue) GetValue() interface{}
func (*AnchorsValue) Property ¶
func (a *AnchorsValue) Property(key string) (interface{}, bool)
func (*AnchorsValue) RemoveDependent ¶
func (a *AnchorsValue) RemoveDependent(Dependent)
func (*AnchorsValue) ResolveVariable ¶
func (v *AnchorsValue) ResolveVariable(name string) (interface{}, bool)
func (*AnchorsValue) SetCode ¶
func (a *AnchorsValue) SetCode(Code)
func (*AnchorsValue) SetProperty ¶
func (a *AnchorsValue) SetProperty(key string, value interface{}) error
func (*AnchorsValue) SetPropertyCode ¶
func (a *AnchorsValue) SetPropertyCode(key string, code Code) bool
func (*AnchorsValue) SetValue ¶
func (a *AnchorsValue) SetValue(interface{}) error
func (*AnchorsValue) UpdateExpressions ¶
func (v *AnchorsValue) UpdateExpressions(context Component) (int, ErrorGroup)
type AnyValue ¶
type AnyValue struct {
// contains filtered or unexported fields
}
func NewAnyValue ¶
func NewAnyValue(value interface{}) *AnyValue
func NewAnyValueFromCode ¶
func NewEmptyAnyValue ¶
func NewEmptyAnyValue() *AnyValue
func (*AnyValue) AddDependent ¶
func (v *AnyValue) AddDependent(d Dependent)
func (*AnyValue) RemoveDependent ¶
func (v *AnyValue) RemoveDependent(d Dependent)
type AsyncFunction ¶
type AsyncFunction struct { Function // contains filtered or unexported fields }
func NewAsyncFunction ¶
func NewAsyncFunction(code Code) *AsyncFunction
func (*AsyncFunction) Evaluate ¶
func (f *AsyncFunction) Evaluate(context Component) (interface{}, error)
func (*AsyncFunction) Notify ¶
func (f *AsyncFunction) Notify(args ...interface{})
func (*AsyncFunction) ShouldEvaluate ¶
func (f *AsyncFunction) ShouldEvaluate() bool
type BoolValue ¶
type BoolValue struct {
// contains filtered or unexported fields
}
func NewBoolValue ¶
func NewBoolValueFromCode ¶
func NewEmptyBoolValue ¶
func NewEmptyBoolValue() *BoolValue
func (*BoolValue) AddDependent ¶
func (v *BoolValue) AddDependent(d Dependent)
func (*BoolValue) RemoveDependent ¶
func (v *BoolValue) RemoveDependent(d Dependent)
func (*BoolValue) SetBoolValue ¶
type Code ¶
type Code struct { FileCtx *FileContext Code string Position *PositionRange }
Code is a struct of values that are required to create an expression
type ColorValue ¶
type ColorValue struct {
// contains filtered or unexported fields
}
func NewColor ¶
func NewColor(c color.Color, position *PositionRange) *ColorValue
func NewColorValueFromCode ¶
func NewColorValueFromCode(code Code) *ColorValue
func NewEmptyColorValue ¶
func NewEmptyColorValue() *ColorValue
func (*ColorValue) AddDependent ¶
func (v *ColorValue) AddDependent(d Dependent)
func (*ColorValue) Color ¶
func (v *ColorValue) Color() color.Color
func (*ColorValue) GetValue ¶
func (v *ColorValue) GetValue() interface{}
func (*ColorValue) RGBAColor ¶
func (v *ColorValue) RGBAColor() color.RGBA
func (*ColorValue) RemoveDependent ¶
func (v *ColorValue) RemoveDependent(d Dependent)
func (*ColorValue) SetCode ¶
func (v *ColorValue) SetCode(code Code)
func (*ColorValue) SetColor ¶
func (v *ColorValue) SetColor(newValue color.Color)
func (*ColorValue) SetValue ¶
func (v *ColorValue) SetValue(newValue interface{}) error
type Component ¶
type Component interface { DefineProperty(PropertyDefinition, *FileContext) error // Creates a new property. On failure it returns either a RedeclarationError or UnknownTypeError. DefineEnum(Enumeration) bool DefineMethod(Method) bool Property(name string) (Value, bool) // returns the property with the given name, and a boolean indicating whether the property exists MustProperty(name string) Value // same as Property but panics if the property doesn't exist SetProperty(name string, value interface{}) error // sets the property with the given name to the given value SetPropertyCode(name string, code Code) error // sets the property with the given name to the given expression Event(name string) (Listenable, bool) // returns the event with the given name, and a boolean indicating whether the event exists ResolveVariable(name string) (interface{}, bool) // searches the scope for a variable with the given name. Returns either an expression or a component. The boolean indicates wether the variable was found. AddChild(Component) // Adds the given component as a child and also sets their parent to this component AddChildAfter(Component, Component) Children() []Component // Returns all children of this component SetParent(Component) // Sets the parent of this component to the given component ID() string // Returns the id of this component String() string // Returns a short string representation of this component UpdateExpressions(context Component) (int, ErrorGroup) // Recursively reevaluate all expressions that got dirty. Returns the number of reevaluated expression (includes potential failed ones) As(*Component) bool // Returns true if this component is of the same type as the given parameter. It also changes the parameter to point to this component. ApplyLayout(*Layout) Draw(DrawingContext, Rect) error Bounds() Rect RootC() *Root // returns the root of this component Finish() error // Finishes the component instantiation. Should only be called by components that embed this one. }
Component describes a generic vit component
type ComponentContainer ¶
type ComponentContainer struct { Global map[string]AbstractComponent // globally defined components Local map[string]AbstractComponent // components specific to the current document }
ComponentContainer holds a list of abstract components
func NewComponentContainer ¶
func NewComponentContainer() ComponentContainer
func (ComponentContainer) Get ¶
func (c ComponentContainer) Get(names string) (AbstractComponent, bool)
func (ComponentContainer) JustGlobal ¶
func (c ComponentContainer) JustGlobal() ComponentContainer
Returns a new ComponentContainer carrying over the global components from this one.
func (ComponentContainer) Set ¶
func (c ComponentContainer) Set(name string, comp AbstractComponent)
func (ComponentContainer) ToGlobal ¶
func (c ComponentContainer) ToGlobal() ComponentContainer
Returns a new ComponentContainer using this local components as global ones.
type ComponentDefListValue ¶
type ComponentDefListValue struct {
// contains filtered or unexported fields
}
func NewComponentDefListValue ¶
func NewComponentDefListValue(components []*ComponentDefinition, position *PositionRange) *ComponentDefListValue
func NewEmptyComponentDefListValue ¶
func NewEmptyComponentDefListValue() *ComponentDefListValue
func (*ComponentDefListValue) AddDependent ¶
func (v *ComponentDefListValue) AddDependent(d Dependent)
func (*ComponentDefListValue) ComponentDefinitions ¶
func (v *ComponentDefListValue) ComponentDefinitions() []*ComponentDefinition
func (*ComponentDefListValue) GetValue ¶
func (v *ComponentDefListValue) GetValue() interface{}
func (*ComponentDefListValue) RemoveDependent ¶
func (v *ComponentDefListValue) RemoveDependent(d Dependent)
func (*ComponentDefListValue) SetCode ¶
func (v *ComponentDefListValue) SetCode(code Code)
func (*ComponentDefListValue) SetComponentDefinitions ¶
func (v *ComponentDefListValue) SetComponentDefinitions(components []*ComponentDefinition)
func (*ComponentDefListValue) SetValue ¶
func (v *ComponentDefListValue) SetValue(newValue interface{}) error
type ComponentDefValue ¶
type ComponentDefValue struct {
// contains filtered or unexported fields
}
func NewComponentDefValue ¶
func NewComponentDefValue(component *ComponentDefinition, context *FileContext) *ComponentDefValue
func NewEmptyComponentDefValue ¶
func NewEmptyComponentDefValue() *ComponentDefValue
func (*ComponentDefValue) AddDependent ¶
func (v *ComponentDefValue) AddDependent(d Dependent)
func (*ComponentDefValue) ComponentDefinition ¶
func (v *ComponentDefValue) ComponentDefinition() *ComponentDefinition
func (*ComponentDefValue) Context ¶
func (v *ComponentDefValue) Context() *FileContext
func (*ComponentDefValue) GetValue ¶
func (v *ComponentDefValue) GetValue() interface{}
func (*ComponentDefValue) RemoveDependent ¶
func (v *ComponentDefValue) RemoveDependent(d Dependent)
func (*ComponentDefValue) SetCode ¶
func (v *ComponentDefValue) SetCode(code Code)
func (*ComponentDefValue) SetComponentDefinition ¶
func (v *ComponentDefValue) SetComponentDefinition(component *ComponentDefinition, context *FileContext)
func (*ComponentDefValue) SetValue ¶
func (v *ComponentDefValue) SetValue(newValue interface{}) error
type ComponentDefinition ¶
type ComponentDefinition struct { Pos PositionRange BaseName string // name of the instantiated base component ID string // custom id of the component Properties []PropertyDefinition // all explicitly defined or declared properties Children []*ComponentDefinition // child components Enumerations []Enumeration // all explicitly defined enumerations Events []EventDefinition Methods []Method }
ComponentDefinition contains everything about a component that is defined in a vit file
func (*ComponentDefinition) GetEnum ¶
func (d *ComponentDefinition) GetEnum(name string) (*Enumeration, bool)
func (*ComponentDefinition) IdentifierIsKnown ¶
func (d *ComponentDefinition) IdentifierIsKnown(identifier []string) bool
IdentifierIsKnown returns true of the given identifier has already been defined
func (*ComponentDefinition) String ¶
func (d *ComponentDefinition) String() string
String returns a human readable string representation of the component definition
type ComponentDefinitionInContext ¶
type ComponentDefinitionInContext struct { *ComponentDefinition Context *FileContext }
type ComponentDefinitionListInContext ¶
type ComponentDefinitionListInContext struct { Components []*ComponentDefinition Context *FileContext }
type ComponentRefValue ¶
type ComponentRefValue struct {
// contains filtered or unexported fields
}
func NewComponentRefValue ¶
func NewComponentRefValue(comp Component) *ComponentRefValue
func NewComponentRefValueFromCode ¶
func NewComponentRefValueFromCode(code Code) *ComponentRefValue
func NewEmptyComponentRefValue ¶
func NewEmptyComponentRefValue() *ComponentRefValue
func (*ComponentRefValue) AddDependent ¶
func (v *ComponentRefValue) AddDependent(d Dependent)
func (*ComponentRefValue) Component ¶
func (v *ComponentRefValue) Component() Component
func (*ComponentRefValue) GetValue ¶
func (v *ComponentRefValue) GetValue() interface{}
func (*ComponentRefValue) RemoveDependent ¶
func (v *ComponentRefValue) RemoveDependent(d Dependent)
func (*ComponentRefValue) SetCode ¶
func (v *ComponentRefValue) SetCode(code Code)
func (*ComponentRefValue) SetComponent ¶
func (v *ComponentRefValue) SetComponent(comp Component)
func (*ComponentRefValue) SetValue ¶
func (v *ComponentRefValue) SetValue(newValue interface{}) error
type DrawingContext ¶
type Enumeration ¶
type Enumeration struct { Name string Embedded bool Values map[string]int Position *PositionRange }
func (Enumeration) ResolveVariable ¶
func (e Enumeration) ResolveVariable(name string) (interface{}, bool)
type ErrorGroup ¶
type ErrorGroup struct {
Errors []error
}
ErrorGroup contains a list of multiple error and may be used whenever multiple errors may occur without the need to fail immediately. To check if an error actually occurred use the method 'Failed'.
func (*ErrorGroup) Add ¶
func (e *ErrorGroup) Add(err error)
Add the error to the list. If err is nil it won't be added.
func (*ErrorGroup) AddGroup ¶
func (e *ErrorGroup) AddGroup(group ErrorGroup)
AddGroup adds all errors of another group to this one. It doesn't matter if the other group is empty or not.
func (ErrorGroup) Error ¶
func (e ErrorGroup) Error() string
Error implements the error interface. It does not actually return any of the errors itself, but just a short information about the amount of errors.
func (*ErrorGroup) Failed ¶
func (e *ErrorGroup) Failed() bool
Failed returns true if the group contains at least one error.
func (ErrorGroup) Is ¶
func (e ErrorGroup) Is(target error) bool
type Evaluater ¶
type Evaluater interface { ShouldEvaluate() bool // Returns true if the structure needs to be reevaluated. (For example because a dependency has changed.) Evaluate(Component) (interface{}, error) // Evaluates the structure and returns the result and an optional error. }
Evaluaters are structures that can be evaluated inside of a component context.
type EventAdapter ¶
type EventAdapter struct {
// contains filtered or unexported fields
}
func (EventAdapter) AddEventListener ¶
func (a EventAdapter) AddEventListener(f *Method)
func (EventAdapter) Fire ¶
func (a EventAdapter) Fire(event interface{})
type EventAttribute ¶
type EventAttribute[EventType any] struct { // contains filtered or unexported fields }
an EventAttribute that is defined on a component.
func NewEventAttribute ¶
func NewEventAttribute[EventType any]() *EventAttribute[EventType]
func (*EventAttribute[EventType]) AddListener ¶
func (a *EventAttribute[EventType]) AddListener(l Listener[EventType])
func (*EventAttribute[EventType]) AddListenerFunction ¶
func (a *EventAttribute[EventType]) AddListenerFunction(f *AsyncFunction)
func (*EventAttribute[EventType]) CreateListener ¶
func (a *EventAttribute[EventType]) CreateListener(code Code) Evaluater
func (*EventAttribute[EventType]) Fire ¶
func (a *EventAttribute[EventType]) Fire(e *EventType)
func (*EventAttribute[EventType]) MaybeFire ¶
func (a *EventAttribute[EventType]) MaybeFire(v any) error
MaybeFire tries to convert the value to the correct EventType and if that's possible fires the event. The event type has to implement the MaybeSetable interface. If the value can't be converted the event will not be fired and an error will be returned.
func (*EventAttribute[EventType]) RemoveListener ¶
func (a *EventAttribute[EventType]) RemoveListener(l Listener[EventType])
type EventDefinition ¶
type EventDefinition struct { Name string Parameters []PropertyDefinition Position *PositionRange }
EventDefinition from a vit file
type EventSource ¶
type EventSource interface { Listenable MaybeFire(any) error // Tries to fire an event using the passed value. Returns an error if the value can't be converted to the correct event type. }
EventSource provides a universal interface for EventAttributes without the generic event type.
type ExecutionEnvironment ¶
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
Expression contains JavaScript code that can be executed to get a value
func NewExpression ¶
func NewExpression(code Code) *Expression
func (*Expression) Err ¶
func (e *Expression) Err() error
func (*Expression) Evaluate ¶
func (e *Expression) Evaluate(context Component) (interface{}, error)
func (*Expression) IsConstant ¶
func (e *Expression) IsConstant() bool
func (*Expression) MakeDirty ¶
func (e *Expression) MakeDirty(stack []Dependent)
func (*Expression) ShouldEvaluate ¶
func (e *Expression) ShouldEvaluate() bool
ShouldEvaluate returns true if this expression should be reevaluated because any dependencies have changed
type ExpressionError ¶
type ExpressionError struct { Code string Position *PositionRange // contains filtered or unexported fields }
func NewExpressionError ¶
func NewExpressionError(code string, pos *PositionRange, wrappedErr error) ExpressionError
func (ExpressionError) Error ¶
func (e ExpressionError) Error() string
func (ExpressionError) Is ¶
func (e ExpressionError) Is(target error) bool
func (ExpressionError) Unwrap ¶
func (e ExpressionError) Unwrap() error
type FileContext ¶
type FileContext struct { Global *GlobalContext // global context KnownComponents ComponentContainer // Components that are known inside the file IDs map[string]Component // mapping from id's to components in the file }
FileContext holds information about a file. It also contains a reference to the global context and can be used to access things like component definitions.
func NewFileContext ¶
func NewFileContext(global *GlobalContext) *FileContext
func (*FileContext) Get ¶
func (ctx *FileContext) Get(name string) (AbstractComponent, bool)
Get returns the component with the given name. The returned boolean indicates whether the component was found.
func (*FileContext) GetComponentByID ¶
func (ctx *FileContext) GetComponentByID(id string) (Component, bool)
func (*FileContext) RegisterComponent ¶
func (ctx *FileContext) RegisterComponent(id string, comp Component)
func (*FileContext) ResolveVariable ¶
func (ctx *FileContext) ResolveVariable(name string) (interface{}, bool)
ResolveVariable returns defined components with the given name, existing components with the given id or globally defined values.
func (*FileContext) UnregisterComponent ¶
func (ctx *FileContext) UnregisterComponent(id string, comp Component)
type FloatValue ¶
type FloatValue struct {
// contains filtered or unexported fields
}
func NewEmptyFloatValue ¶
func NewEmptyFloatValue() *FloatValue
func NewFloatValue ¶
func NewFloatValue(value float64) *FloatValue
func NewFloatValueFromCode ¶
func NewFloatValueFromCode(code Code) *FloatValue
func (*FloatValue) AddDependent ¶
func (v *FloatValue) AddDependent(d Dependent)
func (*FloatValue) Float64 ¶
func (v *FloatValue) Float64() float64
func (*FloatValue) GetValue ¶
func (v *FloatValue) GetValue() interface{}
func (*FloatValue) RemoveDependent ¶
func (v *FloatValue) RemoveDependent(d Dependent)
func (*FloatValue) SetCode ¶
func (v *FloatValue) SetCode(code Code)
func (*FloatValue) SetFloatValue ¶
func (v *FloatValue) SetFloatValue(newValue float64)
func (*FloatValue) SetValue ¶
func (v *FloatValue) SetValue(newValue interface{}) error
type FocusableComponent ¶
type FocusableComponent interface { Focus() Blur() }
type Function ¶
type Function struct { Position *PositionRange // contains filtered or unexported fields }
func NewFunction ¶
type FunctionDependency ¶
type FunctionDependency struct {
Callback *func()
}
FunctionDependency is an adapter that implements the Dependent interface and simply calls the callback function when the dependency changes.
func FuncDep ¶
func FuncDep(cb func()) FunctionDependency
func (FunctionDependency) MakeDirty ¶
func (d FunctionDependency) MakeDirty([]Dependent)
type FunctionValue ¶
type FunctionValue struct {
// contains filtered or unexported fields
}
FunctionValue represents a function that is defined in go. JavaScript can only call it and not set or depend on it. Can be set from Go through the SetValue method.
func MustNewFunctionValue ¶
func MustNewFunctionValue(value interface{}) *FunctionValue
MustNewFunctionValue returns a new function value containing the given function. If the parameter is not a function it panics.
func NewEmptyFunctionValue ¶
func NewEmptyFunctionValue() *FunctionValue
NewEmptyFunctionValue returns a new function value that doesn't contain a function.
func NewFunctionValue ¶
func NewFunctionValue(value interface{}) (*FunctionValue, error)
NewFunctionValue returns a new function value containing the given function. If the parameter is not a function it returns with a TypeError.
func (*FunctionValue) AddDependent ¶
func (v *FunctionValue) AddDependent(Dependent)
func (*FunctionValue) GetValue ¶
func (v *FunctionValue) GetValue() interface{}
func (*FunctionValue) RemoveDependent ¶
func (v *FunctionValue) RemoveDependent(Dependent)
func (*FunctionValue) SetCode ¶
func (v *FunctionValue) SetCode(Code)
func (*FunctionValue) SetValue ¶
func (v *FunctionValue) SetValue(newValue interface{}) error
type GlobalContext ¶
type GlobalContext struct { KnownComponents ComponentContainer // globally known components Variables map[string]Value Environment ExecutionEnvironment }
GlobalContext holds information about a vitrum instance
func (*GlobalContext) Get ¶
func (c *GlobalContext) Get(name string) (AbstractComponent, bool)
func (*GlobalContext) ResolveVariable ¶
func (c *GlobalContext) ResolveVariable(name string) (interface{}, bool)
func (*GlobalContext) SetVariable ¶
func (c *GlobalContext) SetVariable(name string, value interface{}) error
type GroupValue ¶
type GroupValue struct {
// contains filtered or unexported fields
}
func NewEmptyGroupValue ¶
func NewEmptyGroupValue(schema map[string]Value) *GroupValue
func NewGroupValueFromCode ¶
func NewGroupValueFromCode(schema map[string]Value, code Code) *GroupValue
func (*GroupValue) AddDependent ¶
func (v *GroupValue) AddDependent(d Dependent)
func (*GroupValue) GetValue ¶
func (v *GroupValue) GetValue() interface{}
func (*GroupValue) MustGet ¶
func (v *GroupValue) MustGet(key string) Value
func (*GroupValue) RemoveDependent ¶
func (v *GroupValue) RemoveDependent(d Dependent)
func (*GroupValue) SetCode ¶
func (v *GroupValue) SetCode(code Code)
func (*GroupValue) SetValue ¶
func (v *GroupValue) SetValue(newValue interface{}) error
func (*GroupValue) SetValueOf ¶
func (v *GroupValue) SetValueOf(name string, newValue interface{}) error
type IntValue ¶
type IntValue struct {
// contains filtered or unexported fields
}
func NewEmptyIntValue ¶
func NewEmptyIntValue() *IntValue
func NewIntValue ¶
func NewIntValueFromCode ¶
func (*IntValue) AddDependent ¶
func (v *IntValue) AddDependent(d Dependent)
func (*IntValue) RemoveDependent ¶
func (v *IntValue) RemoveDependent(d Dependent)
func (*IntValue) SetIntValue ¶
type JSListener ¶
type JSListener[EventType any] struct { *AsyncFunction }
func NewJSListener ¶
func NewJSListener[EventType any](code Code) *JSListener[EventType]
func (*JSListener[EventType]) Notify ¶
func (l *JSListener[EventType]) Notify(event *EventType)
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
func (*Layout) AckPositionChange ¶
func (l *Layout) AckPositionChange()
func (*Layout) AckSizeChange ¶
func (l *Layout) AckSizeChange()
func (*Layout) AckTargetSizeChange ¶
func (l *Layout) AckTargetSizeChange()
func (*Layout) AddDependent ¶
func (v *Layout) AddDependent(d Dependent)
func (*Layout) GetPreferredX ¶
func (*Layout) GetPreferredY ¶
func (*Layout) GetTargetHeight ¶
func (*Layout) GetTargetWidth ¶
func (*Layout) PositionChanged ¶
func (*Layout) RemoveDependent ¶
func (v *Layout) RemoveDependent(d Dependent)
func (*Layout) SetPosition ¶
func (*Layout) SetPreferredPosition ¶
func (*Layout) SetTargetSize ¶
func (*Layout) SizeChanged ¶
func (*Layout) TargetSizeChanged ¶
type LayoutList ¶
func (LayoutList) AddDependent ¶
func (l LayoutList) AddDependent(c Component, layout *Layout)
func (LayoutList) DidChange ¶
func (l LayoutList) DidChange() bool
DidChange returns true if one of the contained layouts had it's target size changed. It adds compatibility with other Value types.
type ListValue ¶
type ListValue[ElementType Value] struct { // contains filtered or unexported fields }
func NewEmptyListValue ¶
func NewListValue ¶
func NewListValueFromCode ¶
func (*ListValue) AddDependent ¶
func (v *ListValue) AddDependent(d Dependent)
func (*ListValue) RemoveDependent ¶
func (v *ListValue) RemoveDependent(d Dependent)
func (*ListValue[ElementType]) SetSlice ¶
func (v *ListValue[ElementType]) SetSlice(slice []ElementType)
type Listenable ¶
type Listenable interface { // Creates a new listener for the event using the code. The listener is registered with this event and is returned in the form of an Evaluater. CreateListener(Code) Evaluater // Adds an async function as a listener AddListenerFunction(*AsyncFunction) }
Listenable provides a universal interface for all events that can be listened for, no matter the EventType.
type Listener ¶
type Listener[EventType any] interface { Notify(*EventType) // Notify the listener that the event has been triggered. }
Listener provides an interface specific to an EventType.
type ListenerCallback ¶
type ListenerCallback[EventType any] struct { // contains filtered or unexported fields }
ListenerCallback is an adapter that implements the Dependent interface and simply calls the callback function when the dependency changes.
func ListenerCB ¶
func ListenerCB[EventType any](cb func(*EventType)) ListenerCallback[EventType]
func (ListenerCallback[EventType]) Notify ¶
func (d ListenerCallback[EventType]) Notify(e *EventType)
type MaybeSetable ¶
type MaybeSetable interface {
MaybeSet(any) error // Tries to set the implementing struct based on the passed value. Returns an error if the value is not valid.
}
Can be implemented by Events to enable vitrum to automatically create an event from a javascript value.
type Method ¶
type Method struct { Name string AsyncFunction }
func (Method) CopyInContext ¶
func (m Method) CopyInContext(fileCtx *FileContext) Method
type OptionalValue ¶
type OptionalValue[T Value] struct { // contains filtered or unexported fields }
func NewOptionalValue ¶
func NewOptionalValue[T Value](v T) *OptionalValue[T]
func (*OptionalValue) AddDependent ¶
func (v *OptionalValue) AddDependent(d Dependent)
func (*OptionalValue[T]) GetValue ¶
func (v *OptionalValue[T]) GetValue() interface{}
func (*OptionalValue[T]) IsSet ¶
func (v *OptionalValue[T]) IsSet() bool
func (*OptionalValue[T]) MakeDirty ¶
func (v *OptionalValue[T]) MakeDirty(stack []Dependent)
func (*OptionalValue) RemoveDependent ¶
func (v *OptionalValue) RemoveDependent(d Dependent)
func (*OptionalValue[T]) SetCode ¶
func (v *OptionalValue[T]) SetCode(code Code)
func (*OptionalValue[T]) SetValue ¶
func (v *OptionalValue[T]) SetValue(newValue interface{}) error
func (*OptionalValue[T]) Update ¶
func (v *OptionalValue[T]) Update(context Component) (bool, error)
func (*OptionalValue[T]) Value ¶
func (v *OptionalValue[T]) Value() T
returns the actual value weather it is set or not. This should only be used for reading. The wrapped value must not be written to directly through this.
type Position ¶
type Position struct { FilePath vpath.Path Line int // line inside the file starting at 1 Column int // column inside the line starting at 1 (this is pointing to the rune, not the byte) }
position describes a specific position in a file
type PositionRange ¶
type PositionRange struct { FilePath vpath.Path // start points to the first rune of the range StartLine int // line inside the file starting at 1 StartColumn int // column inside the line starting at 1 (this is pointing to the rune, not the byte) // end points to the last rune of the range EndLine int // line inside the file starting at 1 EndColumn int // column inside the line starting at 1 (this is pointing to the rune, not the byte) }
positionRange describes a range of runes in a file
func CombineRanges ¶
func CombineRanges(a, b PositionRange) PositionRange
func NewRangeFromPosition ¶
func NewRangeFromPosition(pos Position) PositionRange
newRangeFromStartToEnd returns a range that starts and ends at the same position.
func NewRangeFromStartToEnd ¶
func NewRangeFromStartToEnd(start Position, end Position) PositionRange
newRangeFromStartToEnd returns a range from the start position to the end position. The filePath is taken from the start position.
func (PositionRange) End ¶
func (p PositionRange) End() Position
End returns the position of the last rune
func (PositionRange) Report ¶
func (p PositionRange) Report() string
func (*PositionRange) SetEnd ¶
func (p *PositionRange) SetEnd(pos Position)
func (PositionRange) Start ¶
func (p PositionRange) Start() Position
Start returns the position of the first rune
func (PositionRange) StartColumnShifted ¶
func (p PositionRange) StartColumnShifted(amount int) PositionRange
StartColumnShifted returns a new position range whose start has been shifted by the given amount. If the end is on the same line it's column is shifted as well.
func (PositionRange) String ¶
func (p PositionRange) String() string
String returns a human readable description of the range between two position
type PropertyDefinition ¶
type PropertyDefinition struct { Pos PositionRange // position of the property declaration ValuePos *PositionRange // Position of the property value Identifier []string // Identifier of this property. This will usually be only one value but can contain multiple parts for example with 'Anchors.fill' Expression string // Expression string that defines the property. Can be empty. Components []*ComponentDefinition // Only set if this properties type is a component or list of components. VitType string // data type of the property in vit terms, not go ListDimensions int // If this property is a list this indicated the Number of dimensions it has. 0 means that it's not a list at all. ReadOnly bool // Readonly properties are statically defined on the component itself and cannot be changed directly. They will however be recalculated if one of the expressions dependencies should change. Static bool // Static properties are defined on the component itself. They will only be evaluated once when the component is loaded and are constant from that point on. StaticValue interface{} // The evaluated value of a static property. Tags map[string]string // optional tags of the property }
PropertyDefinition contains everything about a defined or declared PropertyDefinition
func (PropertyDefinition) HasTag ¶
func (p PropertyDefinition) HasTag(tag string, moreTags ...string) bool
HasTag returns true if the property has *one or more* of the given tags set and false otherwise.
func (PropertyDefinition) IsNewDefinition ¶
func (p PropertyDefinition) IsNewDefinition() bool
IsNewDefinition returns true if this defines a new property instead of just assigning a value to an existing one.
func (PropertyDefinition) Position ¶
func (p PropertyDefinition) Position() PositionRange
func (PropertyDefinition) String ¶
func (p PropertyDefinition) String() string
String returns a human readable string representation of the property
type PropertyError ¶
type PropertyError struct {
// contains filtered or unexported fields
}
func NewPropertyError ¶
func NewPropertyError(componentName string, propertyName string, componentID string, err error) PropertyError
func (PropertyError) Error ¶
func (e PropertyError) Error() string
func (PropertyError) Is ¶
func (e PropertyError) Is(target error) bool
func (PropertyError) Unwrap ¶
func (e PropertyError) Unwrap() error
type Rect ¶
type Rect struct {
X1, Y1, X2, Y2 float64
}
func (Rect) CenteredIn ¶
CenteredIn returns a copy of the rectangle centered in the passed rectangle
func (Rect) MovedX ¶
MovedX returns a copy of the rectangle moved by the given amount on the x-axis.
type RedeclarationError ¶
type RedeclarationError struct { PropertyName string PreviousDefinition PositionRange }
func (RedeclarationError) Error ¶
func (e RedeclarationError) Error() string
func (RedeclarationError) Is ¶
func (e RedeclarationError) Is(target error) bool
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root is the base component all other components embed. It provides some basic functionality.
func NewRoot ¶
func NewRoot(id string, context *FileContext) Root
func (*Root) AddChild ¶
AddChild; THIS NEEDS TO BE REIMPLEMENTED BY THE EMBEDDING STRUCTS TO SET THE CORRECT PARENT TYPE INSTEAD OF ROOT TODO: remove this method here, to force reimplementation?
func (*Root) AddChildAfter ¶
func (*Root) AddChildAtButKeepParent ¶
func (*Root) AddChildButKeepParent ¶
AddChildButKeepParent adds the given component as a child but doesn't change the child's parent. SHOULD ONLY BE CALLED FROM OTHER COMPONENTS THAT EMBED THIS ROOT.
func (*Root) AddListenerFunction ¶
func (*Root) ApplyLayout ¶
func (*Root) Context ¶
func (r *Root) Context() *FileContext
func (*Root) DefineEnum ¶
func (r *Root) DefineEnum(enum Enumeration) bool
func (*Root) DefineMethod ¶
func (*Root) DefineProperty ¶
func (r *Root) DefineProperty(propDef PropertyDefinition, fileCtx *FileContext) error
DefineProperty creates a new property on the component. TODO: currently properties can be redefined. Make a decision on that behaviour and update the documentation accordingly (including the Component interface).
func (*Root) DrawChildren ¶
func (r *Root) DrawChildren(ctx DrawingContext, area Rect) error
func (*Root) Finish ¶
Finish put's the final touches on an instantiated component. It is guaranteed that all other surrounding components are instantiated just not necessarily finished. This needs to be reimplemented by each component.
func (*Root) FinishInContext ¶
FinishInContext put's the final touches on an instantiated component. It is guaranteed that all other surrounding components are instantiated just not necessarily finished. SHOULD ONLY BE CALLED FROM OTHER COMPONENTS THAT EMBED THIS ROOT.
func (*Root) InstantiateInScope ¶
func (r *Root) InstantiateInScope(comp *ComponentDefinition) (Component, error)
InstantiateInScope will instantiate the given component in the scope of this root component.
func (*Root) MustProperty ¶
func (*Root) RemoveChild ¶
func (*Root) ResolveVariable ¶
ResolveVariable; THIS NEEDS TO BE REIMPLEMENTED BY THE EMBEDDING STRUCTS TO RETURN THE CORRECT TYPE IF THE ID OF THIS COMPONENT IS REQUESTED
func (*Root) SetProperty ¶
func (*Root) UpdateExpressions ¶
func (r *Root) UpdateExpressions(context Component) (int, ErrorGroup)
func (*Root) UpdatePropertiesInContext ¶
func (r *Root) UpdatePropertiesInContext(context Component) (int, ErrorGroup)
UpdatePropertiesInContext updates all properties with the given component as a context. SHOULD ONLY BE CALLED FROM OTHER COMPONENTS THAT EMBED THIS ROOT.
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[T comparable]() Set[T]
type StringValue ¶
type StringValue struct {
// contains filtered or unexported fields
}
func NewEmptyStringValue ¶
func NewEmptyStringValue() *StringValue
func NewStringValue ¶
func NewStringValue(value string) *StringValue
func NewStringValueFromCode ¶
func NewStringValueFromCode(code Code) *StringValue
func (*StringValue) AddDependent ¶
func (v *StringValue) AddDependent(d Dependent)
func (*StringValue) GetValue ¶
func (v *StringValue) GetValue() interface{}
func (*StringValue) Position ¶
func (v *StringValue) Position() (*PositionRange, bool)
Position returns the PositionRange that this value was defined at. The boolean indicates wether a position is set.
func (*StringValue) RemoveDependent ¶
func (v *StringValue) RemoveDependent(d Dependent)
func (*StringValue) SetCode ¶
func (v *StringValue) SetCode(code Code)
func (*StringValue) SetStringValue ¶
func (v *StringValue) SetStringValue(newValue string)
func (*StringValue) SetValue ¶
func (v *StringValue) SetValue(newValue interface{}) error
func (*StringValue) String ¶
func (v *StringValue) String() string
type UnknownPropertyError ¶
type UnknownPropertyError struct{}
func (UnknownPropertyError) Error ¶
func (e UnknownPropertyError) Error() string
func (UnknownPropertyError) Is ¶
func (e UnknownPropertyError) Is(target error) bool
type UnknownTypeError ¶
type UnknownTypeError struct {
TypeName string
}
func (UnknownTypeError) Error ¶
func (e UnknownTypeError) Error() string
func (UnknownTypeError) Is ¶
func (e UnknownTypeError) Is(target error) bool
type Value ¶
type Value interface { GetValue() interface{} // returns the current value in it's natural type AddDependent(Dependent) // adds a dependent that should be notified about changes to this value RemoveDependent(Dependent) // removes a dependent SetValue(interface{}) error // changes this value to a new one. Might return an error if the type is incorrect SetCode(Code) // changes this value to the result of an expression Update(context Component) (bool, error) }