pub struct DirectProperty<TOwner: ObjectType, T: PropertyValue> { /* private fields */ }Expand description
A direct property: a property whose value is stored in a field of its owner and accessed through a getter and an optional setter.
Implementations§
Source§impl<TOwner: ObjectType, T: PropertyValue> DirectProperty<TOwner, T>
impl<TOwner: ObjectType, T: PropertyValue> DirectProperty<TOwner, T>
Sourcepub fn setter(&self) -> Option<fn(&TOwner, T)>
pub fn setter(&self) -> Option<fn(&TOwner, T)>
The setter function, if the property is writable.
Sourcepub fn add_owner<TNewOwner: ObjectType>(
&'static self,
getter: fn(&TNewOwner) -> T,
setter: Option<fn(&TNewOwner, T)>,
metadata: Option<DirectPropertyMetadata<T>>,
) -> &'static DirectProperty<TNewOwner, T>
pub fn add_owner<TNewOwner: ObjectType>( &'static self, getter: fn(&TNewOwner) -> T, setter: Option<fn(&TNewOwner, T)>, metadata: Option<DirectPropertyMetadata<T>>, ) -> &'static DirectProperty<TNewOwner, T>
Registers the direct property on another class, with accessors for that class. The new property shares the identity of this one.
Methods from Deref<Target = DirectPropertyBase<T>>§
Sourcepub fn as_property(&'static self) -> &'static FerroProperty
pub fn as_property(&'static self) -> &'static FerroProperty
The untyped base of the property.
Sourcepub fn owner(&self) -> &'static TypeInfo
pub fn owner(&self) -> &'static TypeInfo
The class that registered this instance of the property.
Sourcepub fn get_unset_value(&self, type_: &'static TypeInfo) -> T
pub fn get_unset_value(&self, type_: &'static TypeInfo) -> T
Gets the unset value for the property on the specified type.
Sourcepub fn get_unset_value_for(&self, owner: &FerroObject) -> T
pub fn get_unset_value_for(&self, owner: &FerroObject) -> T
Gets the unset value for the property on the type of owner.
Sourcepub fn get_metadata(
&self,
type_: &'static TypeInfo,
) -> Rc<DirectPropertyMetadata<T>>
pub fn get_metadata( &self, type_: &'static TypeInfo, ) -> Rc<DirectPropertyMetadata<T>>
Gets the property metadata for the specified type.
Sourcepub fn get_metadata_for(
&self,
owner: &FerroObject,
) -> Rc<DirectPropertyMetadata<T>>
pub fn get_metadata_for( &self, owner: &FerroObject, ) -> Rc<DirectPropertyMetadata<T>>
Gets the property metadata for the type of owner.
Sourcepub fn override_metadata<TOwner: ObjectType>(
&self,
metadata: DirectPropertyMetadata<T>,
)
pub fn override_metadata<TOwner: ObjectType>( &self, metadata: DirectPropertyMetadata<T>, )
Overrides the metadata for the property on class TOwner.
Sourcepub fn override_metadata_for(
&self,
type_: &'static TypeInfo,
metadata: DirectPropertyMetadata<T>,
)
pub fn override_metadata_for( &self, type_: &'static TypeInfo, metadata: DirectPropertyMetadata<T>, )
Overrides the metadata for the property on the specified type.
Sourcepub fn unregister(&self, type_: &'static TypeInfo)
pub fn unregister(&self, type_: &'static TypeInfo)
Removes the metadata registered for the specified type.
Methods from Deref<Target = FerroProperty>§
Sourcepub fn as_property_info(&'static self) -> Rc<dyn IPropertyInfo>
pub fn as_property_info(&'static self) -> Rc<dyn IPropertyInfo>
The property as a shared property description
(Rc<dyn IPropertyInfo>), for the places that take a registered
property through the property description contract.
IPropertyInfo::as_ferro_property gives the property back.
Sourcepub fn bind(&'static self) -> IndexerDescriptor
pub fn bind(&'static self) -> IndexerDescriptor
Gets a description of a binding to the property, for the binding
indexer of FerroObject. This is the ! operator of a property:
!Border.BackgroundProperty is Border::background_property().bind(),
and the two-way forms !!Property and ~Property are
!Property.bind().
Sourcepub fn host_type(&self) -> Option<&'static TypeInfo>
pub fn host_type(&self) -> Option<&'static TypeInfo>
The class an attached property is declared for: the THost of its
registration, the type of the objects its accessors (GetX/SetX)
take. None for properties that are not attached.
Sourcepub fn property_type(&self) -> TypeId
pub fn property_type(&self) -> TypeId
The type of the property’s value.
Sourcepub fn property_type_name(&self) -> &'static str
pub fn property_type_name(&self) -> &'static str
The Rust type name of the property’s value type.
Sourcepub fn owner_type(&self) -> &'static TypeInfo
pub fn owner_type(&self) -> &'static TypeInfo
The class that registered the property.
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Whether this is an attached property.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Whether this is a readonly property.
Sourcepub fn assign_binding(&self) -> bool
pub fn assign_binding(&self) -> bool
Whether a binding given for this property in markup is assigned to the property as its value rather than bound to it (the “assign binding” attribute of the managed property). The property’s value type is then a binding type. A fact about the definition: it is the same for every owner and is not part of the metadata.
Sourcepub fn set_assign_binding(&self, value: bool)
pub fn set_assign_binding(&self, value: bool)
Marks the property as one that bindings are assigned to. Part of the
definition of the property: call it where the property is registered
(styled and attached properties state it through
StyledPropertyOptions::assign_binding).
Sourcepub fn id(&self) -> u32
pub fn id(&self) -> u32
An integer ID that uniquely identifies the property; shared by all
owners added with add_owner.
Sourcepub fn changed(&'static self) -> &'static PropertyChangedObservable
pub fn changed(&'static self) -> &'static PropertyChangedObservable
Notifications of changes to this property on any object.
The handlers are invoked after the object’s own change handling.
Sourcepub fn get_metadata(&self, type_: &'static TypeInfo) -> FerroPropertyMetadata
pub fn get_metadata(&self, type_: &'static TypeInfo) -> FerroPropertyMetadata
Gets the base metadata of the property on the specified type.
Sourcepub fn get_metadata_for(&self, owner: &FerroObject) -> FerroPropertyMetadata
pub fn get_metadata_for(&self, owner: &FerroObject) -> FerroPropertyMetadata
Gets the base metadata of the property on the type of owner.
Sourcepub fn unregister(&self, type_: &'static TypeInfo)
pub fn unregister(&self, type_: &'static TypeInfo)
Removes the metadata registered for the property on the specified type.
Sourcepub fn is_valid_value(&self, value: &dyn Any) -> bool
pub fn is_valid_value(&self, value: &dyn Any) -> bool
Checks whether value is valid for the property: of the property’s
value type and accepted by its validation callback.
Sourcepub fn as_styled<T: PropertyValue>(
&'static self,
) -> Option<&'static StyledProperty<T>>
pub fn as_styled<T: PropertyValue>( &'static self, ) -> Option<&'static StyledProperty<T>>
The property as a styled (or attached) property with value type T:
the typed view needed to read, set and bind it without boxing.
None for direct properties and when T is not the property’s value
type.
Trait Implementations§
Source§impl<TOwner: ObjectType, T: PropertyValue> Deref for DirectProperty<TOwner, T>
impl<TOwner: ObjectType, T: PropertyValue> Deref for DirectProperty<TOwner, T>
Source§type Target = DirectPropertyBase<T>
type Target = DirectPropertyBase<T>
Source§fn deref(&self) -> &DirectPropertyBase<T>
fn deref(&self) -> &DirectPropertyBase<T>
impl<TOwner: ObjectType, T: PropertyValue> Registrable for DirectProperty<TOwner, T>
Source§impl<TOwner: ObjectType, T: PropertyValue> TypedProperty for DirectProperty<TOwner, T>
impl<TOwner: ObjectType, T: PropertyValue> TypedProperty for DirectProperty<TOwner, T>
Auto Trait Implementations§
impl<TOwner, T> !Freeze for DirectProperty<TOwner, T>
impl<TOwner, T> !RefUnwindSafe for DirectProperty<TOwner, T>
impl<TOwner, T> !Send for DirectProperty<TOwner, T>
impl<TOwner, T> !Sync for DirectProperty<TOwner, T>
impl<TOwner, T> !UnwindSafe for DirectProperty<TOwner, T>
impl<TOwner, T> Unpin for DirectProperty<TOwner, T>
impl<TOwner, T> UnsafeUnpin for DirectProperty<TOwner, T>where
DirectPropertyBase<T>: UnsafeUnpin,
fn(&TOwner) -> T: UnsafeUnpin,
Option<fn(&TOwner, T)>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more