Styles
struct · ferroui-base · v0.5.0
struct Styles
A style that consists of a number of child styles.
Members
TYPEto_refconstructnewwith_ownercollection_changedowner_changedcountownerresourcesset_resourceshas_resourcesgetsetsnapshottry_get_resourceadd_rangeinsert_rangemove_itemmove_rangeremove_allremove_rangeindex_ofinsertremove_ataddclearcontainsremoveadd_ownerremove_owner
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<Styles>
Returns a strong reference to this object.
construct
fn construct() -> Self
Creates the class data; see FerroObject::construct.
new
fn new() -> Ref<Self>
Creates an empty styles collection.
with_owner
fn with_owner(owner: impl Into<ResourceHostRef>) -> Ref<Self>
Creates an empty styles collection that belongs to owner.
collection_changed
fn collection_changed(self: &Self, handler: impl Fn(&NotifyCollectionChangedEventArgs<'a, Rc<dyn IStyle>>) -> () + 'static) -> Rc<dyn IDisposable>
Raised when the collection changes. Disposing the returned handle unsubscribes.
owner_changed
fn owner_changed(self: &Self, handler: impl Fn() -> () + 'static) -> Rc<dyn IDisposable>
Raised when the owner of the collection changes.
count
fn count(self: &Self) -> usize
The number of styles.
owner
fn owner(self: &Self) -> Option<ResourceHostRef>
The owner of the collection.
resources
fn resources(self: &Self) -> Ref<ResourceDictionary>
The dictionary of style resources.
set_resources
fn set_resources(self: &Self, value: Ref<ResourceDictionary>)
has_resources
fn has_resources(self: &Self) -> bool
Whether the collection or any of its styles has resources.
get
fn get(self: &Self, index: usize) -> Rc<dyn IStyle>
The style at index. Panics if out of range.
set
fn set(self: &Self, index: usize, value: impl Into<Rc<dyn IStyle>>)
Replaces the style at index.
The replacement is notified as a removal followed by an insertion.
snapshot
fn snapshot(self: &Self) -> Rc<Vec<Rc<dyn IStyle>>>
A snapshot of the styles.
try_get_resource
fn try_get_resource(self: &Self, key: &ResourceKey, theme: Option<&ThemeVariant>) -> Option<ResourceValue>
Tries to find a resource in the collection's resources and then in its styles, last style first.
add_range
fn add_range(self: &Self, items: impl IntoIterator<Item = Rc<dyn IStyle>>)
insert_range
fn insert_range(self: &Self, index: usize, items: impl IntoIterator<Item = Rc<dyn IStyle>>)
move_item
fn move_item(self: &Self, old_index: usize, new_index: usize)
move_range
fn move_range(self: &Self, old_index: usize, count: usize, new_index: usize)
remove_all
fn remove_all(self: &Self, items: impl IntoIterator<Item = Rc<dyn IStyle>>)
remove_range
fn remove_range(self: &Self, index: usize, count: usize)
index_of
fn index_of(self: &Self, item: impl Into<Rc<dyn IStyle>>) -> Option<usize>
The index of a style, if it is in the collection.
insert
fn insert(self: &Self, index: usize, item: impl Into<Rc<dyn IStyle>>)
remove_at
fn remove_at(self: &Self, index: usize)
add
fn add(self: &Self, item: impl Into<Rc<dyn IStyle>>)
Adds a style to the collection.
clear
fn clear(self: &Self)
Removes all styles from the collection.
contains
fn contains(self: &Self, item: impl Into<Rc<dyn IStyle>>) -> bool
remove
fn remove(self: &Self, item: impl Into<Rc<dyn IStyle>>) -> bool
Removes a style from the collection. Returns whether it was present.
add_owner
fn add_owner(self: &Self, owner: &ResourceHostRef)
Adds an owner to the collection and the resource providers in it.
remove_owner
fn remove_owner(self: &Self, owner: &ResourceHostRef)
Removes the owner of the collection and the resource providers in it.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeFerroObjectImplExtClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyErasedDestructorIntoEitherDerefUpcast<T>Upcast<Styles>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleFerroObjectImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.