FerroObject
struct · ferroui-base · v0.5.0
struct FerroObject
An object with FerroProperty support: the root of the class hierarchy.
Members
TYPEconstructdispatchercheck_accessverify_accessnewto_refto_weakget_typeisdowncast_refon_property_changedinheritance_parentset_inheritance_parentlocal_write_versionlocal_assignment_versionclear_valueget_valuewith_valueget_base_valueis_animatingis_sethas_local_value_bindingset_valueset_value_with_priorityset_current_valuebind_bindingbind_binding_with_anchorbind_binding_with_priorityindexerbind_indexerbindbind_valuebind_untypedcoerce_valueget_direct_valueset_direct_valueclear_direct_valuebind_directbind_direct_valuebind_direct_untypedset_and_raiseset_and_raise_cellget_value_untypedset_value_untypedset_current_value_untypedclear_value_untypedbind_property_untypedproperty_changedadd_property_changed_handlerremove_property_changed_handlerproperty_changed_subscriber_countraise_property_changedraise_direct_property_changed
TYPE
const TYPE: &'static TypeInfo
The runtime type of this class.
construct
fn construct() -> FerroObject
Creates the class data. Use from the construct function of a derived
class; the object becomes usable once passed to
instantiate.
dispatcher
fn dispatcher(self: &Self) -> &Arc<Dispatcher>
Returns the Dispatcher that this object is associated with: the
dispatcher of the thread that owns the object.
check_access
fn check_access(self: &Self) -> bool
Returns whether the calling thread is the thread that owns this object.
verify_access
fn verify_access(self: &Self)
Checks that the calling thread is the thread that owns this object.
Panics
Panics when it is not.
new
fn new() -> Ref<FerroObject>
Creates a plain object.
to_ref
fn to_ref(self: &Self) -> Ref<FerroObject>
A strong reference to this object.
to_weak
fn to_weak(self: &Self) -> WeakRef<FerroObject>
A weak reference to this object.
get_type
fn get_type(self: &Self) -> &'static TypeInfo
The runtime type of the object.
is
fn is<T: ObjectType>(self: &Self) -> bool
Whether the object is of class T or a class derived from it.
downcast_ref
fn downcast_ref<T: ObjectType>(self: &Self) -> Option<&T>
Returns the object viewed as class T if it is one.
on_property_changed
fn on_property_changed(self: &Self, change: &FerroPropertyChangedEventArgs<'_>)
Invokes the on_property_changed virtual member.
inheritance_parent
fn inheritance_parent(self: &Self) -> Option<Ref<FerroObject>>
The parent object that inherited property values are inherited from.
set_inheritance_parent
fn set_inheritance_parent(self: &Self, value: impl Into<Nullable<FerroObject>>)
Sets the parent object that inherited property values are inherited from.
local_write_version
fn local_write_version(self: &Self, property: &FerroProperty) -> u64
Starts tracking explicit local/current writes to this property and returns its version. Equal-value writes count; style evaluation does not. Tracking lives with this object and is available only in development builds.
local_assignment_version
fn local_assignment_version(self: &Self, property: &FerroProperty) -> u64
Tracks explicit local assignments and binding-slot changes. Unlike
local_write_version, SetCurrentValue (for example two-way user input)
does not transfer assignment ownership.
clear_value
fn clear_value<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>)
Clears a property's local value.
get_value
fn get_value<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>) -> T
Gets a property value.
with_value
fn with_value<T: PropertyValue, R>(self: &Self, property: &'static StyledProperty<T>, read: impl FnOnce(&T) -> R) -> R
Reads a styled property's current value without cloning it. The callback may read other properties, but must not change this property's effective value while it is borrowed. Returning a reference to the value is not permitted by the callback's lifetime.
get_base_value
fn get_base_value<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>) -> Option<T>
Gets a property's base value: the value excluding animated values.
Returns None if the value comes from inheritance or the default.
is_animating
fn is_animating(self: &Self, property: &FerroProperty) -> bool
Checks whether a property is animating.
is_set
fn is_set(self: &Self, property: &FerroProperty) -> bool
Checks whether a styled property has a value assigned to it or a binding targeting it.
has_local_value_binding
fn has_local_value_binding(self: &Self, property: &FerroProperty) -> bool
Whether a local-value binding targets this property, including direct
properties and observable bindings. Unlike is_set, this does not rely
on a styled property's effective-value entry. It does not inspect bindings
at style/template priorities.
set_value
fn set_value<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>, value: T)
Sets a property value with local value priority.
set_value_with_priority
fn set_value_with_priority<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>, value: T, priority: BindingPriority) -> Option<Rc<dyn IDisposable>>
Sets a property value with the given priority. For priorities other than local value, disposing the returned handle removes the value.
set_current_value
fn set_current_value<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>, value: T)
Sets the value of a property without changing its value source.
This is used by a component that programmatically sets the value of one of its own properties without disabling an application's declared use of the property: the effective value changes, but existing bindings and styles continue to work. The new value has the property's current priority.
bind_binding
fn bind_binding(self: &Self, property: &'static FerroProperty, binding: &dyn BindingBase) -> Rc<dyn BindingExpressionBase>
Binds a property to a binding. Returns the binding expression which represents the binding instance on this object.
bind_binding_with_anchor
fn bind_binding_with_anchor(self: &Self, property: &'static FerroProperty, binding: &dyn BindingBase, anchor: Option<&Ref<FerroObject>>) -> Rc<dyn BindingExpressionBase>
Binds a property to a binding.
Some bindings need context to locate their source: a data context,
named elements or resources. If this object is not an element, or is
not yet attached to the tree, anchor provides that context.
bind_binding_with_priority
fn bind_binding_with_priority(self: &Self, property: &'static FerroProperty, binding: &dyn BindingBase, priority: BindingPriority, anchor: Option<&Ref<FerroObject>>) -> Rc<dyn BindingExpressionBase>
Binds a property to a binding at the given priority, whatever the default priority of the binding is. Disposing the returned expression removes the binding.
An addition (no upstream counterpart): the values of WinUI's visual
states are bound at BindingPriority::Animation.
indexer
fn indexer(self: &Self, binding: &crate::data::IndexerDescriptor) -> crate::data::IndexerBinding
Gets a binding to a property of this object: the indexer taking an
IndexerDescriptor
(source[!Property] is source.indexer(&Property.bind())).
bind_indexer
fn bind_indexer(self: &Self, binding: &crate::data::IndexerDescriptor, value: &dyn BindingBase) -> Rc<dyn BindingExpressionBase>
Binds the property of an
IndexerDescriptor to a binding:
the setter of the indexer (target[!Property] = binding is
target.bind_indexer(&Property.bind(), &binding)).
bind
fn bind<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>, source: Rc<dyn IObservable<T>>, priority: BindingPriority) -> Rc<dyn IDisposable>
Binds a property to an observable.
bind_value
fn bind_value<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>, source: Rc<dyn IObservable<BindingValue<T>>>, priority: BindingPriority) -> Rc<dyn IDisposable>
Binds a property to an observable of binding values.
bind_untyped
fn bind_untyped<T: PropertyValue>(self: &Self, property: &'static StyledProperty<T>, source: Rc<dyn IObservable<BoxedValue>>, priority: BindingPriority) -> Rc<dyn IDisposable>
Binds a property to an observable of untyped values.
coerce_value
fn coerce_value(self: &Self, property: &'static FerroProperty)
Coerces the specified property.
get_direct_value
fn get_direct_value<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>) -> T
Gets a direct property value.
set_direct_value
fn set_direct_value<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>, value: T)
Sets a direct property value.
clear_direct_value
fn clear_direct_value<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>)
Resets a direct property to its unset value.
bind_direct
fn bind_direct<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>, source: Rc<dyn IObservable<T>>) -> Rc<dyn IDisposable>
Binds a direct property to an observable.
bind_direct_value
fn bind_direct_value<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>, source: Rc<dyn IObservable<BindingValue<T>>>) -> Rc<dyn IDisposable>
Binds a direct property to an observable of binding values.
bind_direct_untyped
fn bind_direct_untyped<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>, source: Rc<dyn IObservable<BoxedValue>>) -> Rc<dyn IDisposable>
Binds a direct property to an observable of untyped values.
set_and_raise
fn set_and_raise<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>, field: &RefCell<T>, value: T) -> bool
Sets the backing field of a direct property, raising a change notification if the value changed. Returns true if it changed.
set_and_raise_cell
fn set_and_raise_cell<T: PropertyValue + Copy>(self: &Self, property: &'static DirectPropertyBase<T>, field: &Cell<T>, value: T) -> bool
set_and_raise for Copy values stored in a
Cell.
get_value_untyped
fn get_value_untyped(self: &Self, property: &'static FerroProperty) -> BoxedValue
Gets a property value as an untyped value.
set_value_untyped
fn set_value_untyped(self: &Self, property: &'static FerroProperty, value: &dyn Any, priority: BindingPriority) -> Option<Rc<dyn IDisposable>>
Sets a property from an untyped value, which must hold exactly the property's value type or the unset marker.
set_current_value_untyped
fn set_current_value_untyped(self: &Self, property: &'static FerroProperty, value: &dyn Any)
set_current_value with an untyped value.
clear_value_untyped
fn clear_value_untyped(self: &Self, property: &'static FerroProperty)
Clears a property's local value.
bind_property_untyped
fn bind_property_untyped(self: &Self, property: &'static FerroProperty, source: Rc<dyn IObservable<BoxedValue>>, priority: BindingPriority) -> Rc<dyn IDisposable>
Binds a property to an observable of untyped values.
property_changed
fn property_changed(self: &Self, handler: impl Fn(&FerroPropertyChangedEventArgs<'_>) -> () + 'static) -> Rc<dyn IDisposable>
Subscribes to property changes on this object. Disposing the returned handle unsubscribes.
add_property_changed_handler
fn add_property_changed_handler(self: &Self, handler: Rc<dyn Fn(&FerroPropertyChangedEventArgs<'_>) -> ()>) -> u64
Subscribes handler to property changes on this object and returns
the token that remove_property_changed_handler
takes: property_changed for a subscriber
that keeps the object and the token itself, so that no handle is made.
remove_property_changed_handler
fn remove_property_changed_handler(self: &Self, token: u64) -> bool
Ends a subscription of add_property_changed_handler.
property_changed_subscriber_count
fn property_changed_subscriber_count(self: &Self) -> usize
The number of subscribers to property changes on this object (a diagnostics member, used by tests to verify that subscriptions are released).
raise_property_changed
fn raise_property_changed<T: PropertyValue>(self: &Self, property: &'static FerroProperty, old_value: Option<&T>, new_value: &T, priority: BindingPriority, is_effective_value: bool)
Raises a property changed notification.
raise_direct_property_changed
fn raise_direct_property_changed<T: PropertyValue>(self: &Self, property: &'static DirectPropertyBase<T>, old_value: &T, new_value: &T)
Raises a property changed notification for a direct property.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeFerroObjectImplExtClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherFerroObjectDiagnosticExtensionsStaticTypeUpcast<FerroObject>ObjectTypeSubclassable<T>FerroObjectImplDebugFerroObjectExtensions
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.