Line data Source code
1 : """ 2 : Abstract face attributes. 3 : 4 : Face attributes like [`VAttr`](@ref) are declared a a subtype. 5 : """ 6 : abstract type AbstractFAttr <: ManagedAttributes{FHnd}; end 7 : 8 : """ 9 : Face attributes consisting of managed attributes `P` plus cached state. 10 : """ 11 : mutable struct FAttr{P} <: AbstractFAttr 12 : const attrs::P 13 : n_used::Int 14 124 : FAttr{P}(attrs::P, n = 0) where {P} = new(attrs, n) 15 : end 16 : 17 60 : _newfattr(fa::P) where {P} = FAttr{P}(fa) 18 : 19 : """ 20 : fa2 = similar(fa::FAttr) 21 : 22 : Create same attribute list as `va` but empty: without entries. 23 : """ 24 164 : Base.similar(fa::FAttr) = 25 : _newfattr(createattributes(attrspecs(attrs(fa)); htyp=FHnd)) 26 : 27 : const FaceAttributesSpecs = (ManagedAttributesSpecs..., 28 : :_link => specifyattr(HHnd, enabled=true, x0=NoH)) 29 : 30 4 : createfattr(list...) = 31 : _newfattr(createattributes((FaceAttributesSpecs..., list...); htyp=FHnd)) 32 : 33 1 : createfattr(list::Tuple) = createfattr(list...) 34 : 35 : """ 36 : createfattr(key => value, ...) 37 : createfattr((key => value, ...)) 38 : 39 : Create face attribute list from `key => value` pairs, where `key` is a `Symbol` and 40 : `value` either a type or the result from `specifyattr`. 41 : 42 : Example: 43 : 44 : fa = createfattr(:n => SVector{3, Float64}) 45 : 46 : See also [`similar`](@ref) 47 : """ createfattr 48 : 49 : """ 50 : fc = clone(Fa::FAttr) 51 : 52 : Deep copy of attribute list but don't copy disabled attributes. 53 : """ 54 4 : clone(fa::FAttr{P}) where {P} = FAttr{P}(clone(fa.attrs), fa.n_used)