Skip to main content

ResourceSelectorConverter

Struct ResourceSelectorConverter 

Source
pub struct ResourceSelectorConverter { /* private fields */ }
Expand description

A resource dictionary that converts a resource key to the resource it holds under that key.

Implementations§

Source§

impl ResourceSelectorConverter

Source

pub const TYPE: &'static TypeInfo = <ResourceSelectorConverter as ::ferroui_base::StaticType>::TYPE

The runtime type of this class.

Source

pub fn to_ref(&self) -> Ref<ResourceSelectorConverter>

Returns a strong reference to this object.

Source§

impl ResourceSelectorConverter

Source

pub fn construct() -> Self

Source

pub fn new() -> Ref<Self>

Source

pub fn as_value_converter(this: Ref<Self>) -> Rc<dyn IValueConverter>

The converter as its contract (the class implements it in the original).

Source

pub fn convert( &self, key: Option<&BoxedValue>, _culture: &CultureInfo, ) -> Result<Option<BoxedValue>, BindingError>

Convert: the resource of the dictionary whose key is the text key. Fails when key is not text.

Source

pub fn convert_back( &self, _value: Option<&BoxedValue>, _culture: &CultureInfo, ) -> Result<Option<BoxedValue>, BindingError>

ConvertBack: fails, the conversion has no inverse.

Methods from Deref<Target = ResourceDictionary>§

Source

pub fn to_ref(&self) -> Ref<ResourceDictionary>

Returns a strong reference to this object.

Source

pub fn count(&self) -> usize

The number of resources in the dictionary itself.

Source

pub fn get(&self, key: &ResourceKey) -> Option<Rc<dyn AnyValue>>

Gets a resource of the dictionary itself; None (a null value) if the key is not present.

Source

pub fn set(&self, key: impl Into<ResourceKey>, value: Option<Rc<dyn AnyValue>>)

Adds or replaces a resource.

Source

pub fn keys(&self) -> Vec<ResourceKey>

The keys of the resources in the dictionary itself.

Source

pub fn merged_dictionaries(&self) -> FerroList<Rc<dyn IResourceProvider>>

The child resource dictionaries.

The list is returned by handle: clones refer to the same list.

Source

pub fn add_merged_dictionary( &self, provider: impl Into<Rc<dyn IResourceProvider>>, )

Adds a child resource dictionary.

Source

pub fn remove_merged_dictionary( &self, provider: &Rc<dyn IResourceProvider>, ) -> bool

Removes a child resource dictionary. Returns whether it was present.

Source

pub fn theme_dictionaries( &self, ) -> FerroDictionary<ThemeVariant, Rc<dyn IThemeVariantProvider>>

The resource providers used for specific theme variants.

The dictionary is returned by handle: clones refer to the same dictionary. A provider added to it gets the owner of this dictionary; a removed one loses it.

Source

pub fn theme_dictionaries_snapshot( &self, ) -> Vec<(ThemeVariant, Rc<dyn IThemeVariantProvider>)>

A snapshot of the resource providers used for specific theme variants.

Source

pub fn theme_dictionary( &self, variant: &ThemeVariant, ) -> Option<Rc<dyn IThemeVariantProvider>>

The resource provider used for the given theme variant.

Source

pub fn add_theme_dictionary( &self, variant: ThemeVariant, provider: impl Into<Rc<dyn IThemeVariantProvider>>, )

Adds a resource provider for a theme variant. Panics if the variant already has one.

Source

pub fn set_theme_dictionary( &self, variant: ThemeVariant, provider: impl Into<Rc<dyn IThemeVariantProvider>>, )

Adds or replaces the resource provider of a theme variant.

Source

pub fn remove_theme_dictionary(&self, variant: &ThemeVariant) -> bool

Removes the resource provider of a theme variant. Returns whether it was present.

Source

pub fn key(&self) -> Option<ThemeVariant>

The key that is used in the theme dictionaries of the containing resource dictionary.

Source

pub fn set_key(&self, value: Option<ThemeVariant>)

Source

pub fn add(&self, key: impl Into<ResourceKey>, value: Option<Rc<dyn AnyValue>>)

Adds a resource. Panics if the key is already present.

Source

pub fn add_value<T>(&self, key: impl Into<ResourceKey>, value: T)
where T: PartialEq + 'static,

Adds a resource value. Panics if the key is already present.

Source

pub fn add_deferred_fn( &self, key: impl Into<ResourceKey>, factory: impl Fn(Option<&Rc<dyn IServiceProvider>>) -> Option<Rc<dyn AnyValue>> + 'static, )

Adds a resource that is created by factory the first time it is requested.

Source

pub fn add_deferred( &self, key: impl Into<ResourceKey>, deferred_content: Rc<dyn IDeferredContent>, )

Adds a resource that is built from deferred_content the first time it is requested.

Source

pub fn add_not_shared_deferred( &self, key: impl Into<ResourceKey>, deferred_content: Rc<dyn IDeferredContent>, )

Adds a resource that is built from deferred_content every time it is requested.

Source

pub fn set_items( &self, values: impl IntoIterator<Item = (ResourceKey, Option<Rc<dyn AnyValue>>)>, )

Adds or replaces multiple resources, raising a single notification.

Source

pub fn clear(&self)

Removes all resources of the dictionary itself.

Source

pub fn contains_key(&self, key: &ResourceKey) -> bool

Whether the dictionary itself contains the key.

Source

pub fn remove(&self, key: &ResourceKey) -> bool

Removes a resource. Returns whether it was present.

Source

pub fn try_get_value( &self, key: &ResourceKey, ) -> Option<Option<Rc<dyn AnyValue>>>

Gets a resource of the dictionary itself, building it if it is deferred.

Source

pub fn ensure_capacity(&self, capacity: usize)

Ensures that the dictionary can hold up to capacity resources without further expansion of its backing storage.

Source

pub fn contains_deferred_key(&self, key: &ResourceKey) -> bool

Whether the key is present and its resource has not been built yet.

Methods from Deref<Target = ResourceProvider>§

Source

pub fn to_ref(&self) -> Ref<ResourceProvider>

Returns a strong reference to this object.

Source

pub fn has_resources(&self) -> bool

Whether the provider has resources.

Source

pub fn try_get_resource( &self, key: &ResourceKey, theme: Option<&ThemeVariant>, ) -> Option<Option<Rc<dyn AnyValue>>>

Tries to find a resource within the provider.

Source

pub fn on_add_owner(&self, owner: &ResourceHostRef)

Handles when the owner is added. The base method notifies the owner about its resources changing, if the provider has any.

Source

pub fn on_remove_owner(&self, owner: &ResourceHostRef)

Handles when the owner is removed. The base method notifies the owner about its resources changing, if the provider has any.

Source

pub fn owner(&self) -> Option<ResourceHostRef>

The owner of the resource provider.

Source

pub fn owner_changed(&self, handler: impl Fn() + 'static) -> Rc<dyn IDisposable>

Raised when the owner of the resource provider changes.

Source

pub fn raise_resources_changed(&self)

Notifies the owner, if any, that the resources of the provider have changed.

Source

pub fn add_owner(&self, owner: &ResourceHostRef)

Adds an owner to the resource provider.

Source

pub fn remove_owner(&self, owner: &ResourceHostRef)

Removes a resource provider owner.

Methods from Deref<Target = FerroObject>§

Source

pub fn dispatcher(&self) -> &Arc<Dispatcher> ⓘ

Returns the Dispatcher that this object is associated with: the dispatcher of the thread that owns the object.

Source

pub fn check_access(&self) -> bool

Returns whether the calling thread is the thread that owns this object.

Source

pub fn verify_access(&self)

Checks that the calling thread is the thread that owns this object.

§Panics

Panics when it is not.

Source

pub fn to_ref(&self) -> Ref<FerroObject>

A strong reference to this object.

Source

pub fn to_weak(&self) -> WeakRef<FerroObject>

A weak reference to this object.

Source

pub fn get_type(&self) -> &'static TypeInfo

The runtime type of the object.

Source

pub fn is<T>(&self) -> bool
where T: ObjectType,

Whether the object is of class T or a class derived from it.

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ObjectType,

Returns the object viewed as class T if it is one.

Source

pub fn on_property_changed(&self, change: &FerroPropertyChangedEventArgs<'_>)

Invokes the on_property_changed virtual member.

Source

pub fn inheritance_parent(&self) -> Option<Ref<FerroObject>>

The parent object that inherited property values are inherited from.

Source

pub fn set_inheritance_parent(&self, value: impl Into<Nullable<FerroObject>>)

Sets the parent object that inherited property values are inherited from.

Source

pub fn clear_value<T>(&self, property: &'static StyledProperty<T>)
where T: PropertyValue,

Clears a property’s local value.

Source

pub fn get_value<T>(&self, property: &'static StyledProperty<T>) -> T
where T: PropertyValue,

Gets a property value.

Source

pub fn get_base_value<T>( &self, property: &'static StyledProperty<T>, ) -> Option<T>
where T: PropertyValue,

Gets a property’s base value: the value excluding animated values. Returns None if the value comes from inheritance or the default.

Source

pub fn is_animating(&self, property: &FerroProperty) -> bool

Checks whether a property is animating.

Source

pub fn is_set(&self, property: &FerroProperty) -> bool

Checks whether a styled property has a value assigned to it or a binding targeting it.

Source

pub fn set_value<T>(&self, property: &'static StyledProperty<T>, value: T)
where T: PropertyValue,

Sets a property value with local value priority.

Source

pub fn set_value_with_priority<T>( &self, property: &'static StyledProperty<T>, value: T, priority: BindingPriority, ) -> Option<Rc<dyn IDisposable>>
where T: PropertyValue,

Sets a property value with the given priority. For priorities other than local value, disposing the returned handle removes the value.

Source

pub fn set_current_value<T>( &self, property: &'static StyledProperty<T>, value: T, )
where T: PropertyValue,

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.

Source

pub fn bind_binding( &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.

Source

pub fn bind_binding_with_anchor( &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.

Source

pub fn indexer(&self, binding: &IndexerDescriptor) -> IndexerBinding

Gets a binding to a property of this object: the indexer taking an IndexerDescriptor (source[!Property] is source.indexer(&Property.bind())).

Source

pub fn bind_indexer( &self, binding: &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)).

Source

pub fn bind<T>( &self, property: &'static StyledProperty<T>, source: Rc<dyn IObservable<T>>, priority: BindingPriority, ) -> Rc<dyn IDisposable>
where T: PropertyValue,

Binds a property to an observable.

Source

pub fn bind_value<T>( &self, property: &'static StyledProperty<T>, source: Rc<dyn IObservable<BindingValue<T>>>, priority: BindingPriority, ) -> Rc<dyn IDisposable>
where T: PropertyValue,

Binds a property to an observable of binding values.

Source

pub fn bind_untyped<T>( &self, property: &'static StyledProperty<T>, source: Rc<dyn IObservable<Rc<dyn AnyValue>>>, priority: BindingPriority, ) -> Rc<dyn IDisposable>
where T: PropertyValue,

Binds a property to an observable of untyped values.

Source

pub fn coerce_value(&self, property: &'static FerroProperty)

Coerces the specified property.

Source

pub fn get_direct_value<T>(&self, property: &'static DirectPropertyBase<T>) -> T
where T: PropertyValue,

Gets a direct property value.

Source

pub fn set_direct_value<T>( &self, property: &'static DirectPropertyBase<T>, value: T, )
where T: PropertyValue,

Sets a direct property value.

Source

pub fn clear_direct_value<T>(&self, property: &'static DirectPropertyBase<T>)
where T: PropertyValue,

Resets a direct property to its unset value.

Source

pub fn bind_direct<T>( &self, property: &'static DirectPropertyBase<T>, source: Rc<dyn IObservable<T>>, ) -> Rc<dyn IDisposable>
where T: PropertyValue,

Binds a direct property to an observable.

Source

pub fn bind_direct_value<T>( &self, property: &'static DirectPropertyBase<T>, source: Rc<dyn IObservable<BindingValue<T>>>, ) -> Rc<dyn IDisposable>
where T: PropertyValue,

Binds a direct property to an observable of binding values.

Source

pub fn bind_direct_untyped<T>( &self, property: &'static DirectPropertyBase<T>, source: Rc<dyn IObservable<Rc<dyn AnyValue>>>, ) -> Rc<dyn IDisposable>
where T: PropertyValue,

Binds a direct property to an observable of untyped values.

Source

pub fn set_and_raise<T>( &self, property: &'static DirectPropertyBase<T>, field: &RefCell<T>, value: T, ) -> bool
where T: PropertyValue,

Sets the backing field of a direct property, raising a change notification if the value changed. Returns true if it changed.

Source

pub fn set_and_raise_cell<T>( &self, property: &'static DirectPropertyBase<T>, field: &Cell<T>, value: T, ) -> bool
where T: PropertyValue + Copy,

set_and_raise for Copy values stored in a Cell.

Source

pub fn get_value_untyped( &self, property: &'static FerroProperty, ) -> Rc<dyn AnyValue>

Gets a property value as an untyped value.

Source

pub fn set_value_untyped( &self, property: &'static FerroProperty, value: &(dyn Any + 'static), 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.

Source

pub fn set_current_value_untyped( &self, property: &'static FerroProperty, value: &(dyn Any + 'static), )

set_current_value with an untyped value.

Source

pub fn clear_value_untyped(&self, property: &'static FerroProperty)

Clears a property’s local value.

Source

pub fn bind_property_untyped( &self, property: &'static FerroProperty, source: Rc<dyn IObservable<Rc<dyn AnyValue>>>, priority: BindingPriority, ) -> Rc<dyn IDisposable>

Binds a property to an observable of untyped values.

Source

pub fn property_changed( &self, handler: impl Fn(&FerroPropertyChangedEventArgs<'_>) + 'static, ) -> Rc<dyn IDisposable>

Subscribes to property changes on this object. Disposing the returned handle unsubscribes.

Source

pub fn add_property_changed_handler( &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.

Source

pub fn remove_property_changed_handler(&self, token: u64) -> bool

Ends a subscription of add_property_changed_handler.

Source

pub fn property_changed_subscriber_count(&self) -> usize

The number of subscribers to property changes on this object (a diagnostics member, used by tests to verify that subscriptions are released).

Source

pub fn raise_property_changed<T>( &self, property: &'static FerroProperty, old_value: Option<&T>, new_value: &T, priority: BindingPriority, is_effective_value: bool, )
where T: PropertyValue,

Raises a property changed notification.

Source

pub fn raise_direct_property_changed<T>( &self, property: &'static DirectPropertyBase<T>, old_value: &T, new_value: &T, )
where T: PropertyValue,

Raises a property changed notification for a direct property.

Trait Implementations§

Source§

impl Deref for ResourceSelectorConverter

Source§

type Target = ResourceDictionary

The resulting type after dereferencing.
Source§

fn deref(&self) -> &ResourceDictionary

Dereferences the value.
Source§

impl FerroObjectImpl for ResourceSelectorConverter

Source§

fn constructed(this: &Self)

Called once, right after the object has been allocated. This is where constructor logic that needs a reference to the object runs. Overrides must call parent_constructed first.
Source§

fn on_property_changed_core( this: &Self, change: &FerroPropertyChangedEventArgs<'_>, )

Called for every property change on the object, including changes of non-effective (base) values. Overriding this is rarely needed; override on_property_changed instead.
Source§

fn on_property_changed(this: &Self, change: &FerroPropertyChangedEventArgs<'_>)

Called when the effective value of a property changes on the object.
Source§

fn update_data_validation( this: &Self, property: &'static FerroProperty, state: BindingValueType, error: Option<&BindingError>, )

Called to update the validation state for properties for which data validation is enabled.
Source§

impl ObjectType for ResourceSelectorConverter

Source§

type Parent = ResourceDictionary

The base class. The root class is its own parent.
Source§

type VTable = <ResourceDictionary as ObjectType>::VTable

The virtual table of the class.
Source§

fn vtable() -> &'static Self::VTable

The virtual table used by instances whose most-derived class is Self.
Source§

fn register_class()

The static initialisation of the class. The first call on a thread, after doing the same for the base class: Read more
Source§

impl ResourceProviderImpl for ResourceSelectorConverter

Source§

fn has_resources(this: &Self) -> bool

Whether the provider has resources.
Source§

fn try_get_resource( this: &Self, key: &ResourceKey, theme: Option<&ThemeVariant>, ) -> Option<Option<Rc<dyn AnyValue>>>

Tries to find a resource within the provider.
Source§

fn on_add_owner(this: &Self, owner: &ResourceHostRef)

Handles when the owner is added. The base method notifies the owner about its resources changing, if the provider has any.
Source§

fn on_remove_owner(this: &Self, owner: &ResourceHostRef)

Handles when the owner is removed. The base method notifies the owner about its resources changing, if the provider has any.
Source§

impl StaticType for ResourceSelectorConverter

Source§

const TYPE: &'static TypeInfo

The runtime type.
Source§

impl<T> Subclassable<T> for ResourceSelectorConverter

Source§

impl Upcast<ResourceSelectorConverter> for ResourceSelectorConverter

Source§

impl<T: ?Sized> Upcast<T> for ResourceSelectorConverter

Source§

fn upcast(&self) -> &T

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> FerroObjectImplExt for T
where T: FerroObjectImpl,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ResourceProviderImplExt for T

Source§

fn parent_has_resources(this: &Self) -> bool

Calls the base class implementation of the member.
Source§

fn parent_try_get_resource( this: &Self, key: &ResourceKey, theme: Option<&ThemeVariant>, ) -> Option<Option<Rc<dyn AnyValue>>>

Calls the base class implementation of the member.
Source§

fn parent_on_add_owner(this: &Self, owner: &ResourceHostRef)

Calls the base class implementation of the member.
Source§

fn parent_on_remove_owner(this: &Self, owner: &ResourceHostRef)

Calls the base class implementation of the member.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.