pub struct Classes(/* private fields */);Expand description
Holds a collection of style classes for a styled element.
Similar to CSS, each control may have any number of styling classes
applied. Classes whose name starts with : are pseudoclasses and may only
be added or removed by the control itself, through IPseudoClasses.
The value is a shared handle: clones refer to the same collection, and handles compare by identity.
Implementations§
Source§impl Classes
impl Classes
Sourcepub fn from_names<S: Into<String>>(items: impl IntoIterator<Item = S>) -> Self
pub fn from_names<S: Into<String>>(items: impl IntoIterator<Item = S>) -> Self
Creates a collection from the given class names.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
The number of class names the collection can hold before its storage grows.
Sourcepub fn set_capacity(&self, capacity: usize)
pub fn set_capacity(&self, capacity: usize)
Sets the number of class names the collection can hold before its storage grows.
§Panics
Panics if capacity is less than the number of class names.
Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Returns whether a class is present in the collection.
Sourcepub fn add_collection_changed(
&self,
handler: Rc<CollectionChangedHandler<String>>,
) -> u64
pub fn add_collection_changed( &self, handler: Rc<CollectionChangedHandler<String>>, ) -> u64
Subscribes to collection changes; see FerroList::add_collection_changed.
pub fn remove_collection_changed(&self, token: u64) -> bool
Sourcepub fn add(&self, name: &str)
pub fn add(&self, name: &str)
Adds a style class to the collection. Only standard classes may be added via this method.
Sourcepub fn add_range<S: AsRef<str>>(&self, names: impl IntoIterator<Item = S>)
pub fn add_range<S: AsRef<str>>(&self, names: impl IntoIterator<Item = S>)
Adds style classes to the collection.
Sourcepub fn insert_range<S: AsRef<str>>(
&self,
index: usize,
names: impl IntoIterator<Item = S>,
)
pub fn insert_range<S: AsRef<str>>( &self, index: usize, names: impl IntoIterator<Item = S>, )
Inserts style classes into the collection.
Sourcepub fn remove_all<S: AsRef<str>>(&self, names: impl IntoIterator<Item = S>)
pub fn remove_all<S: AsRef<str>>(&self, names: impl IntoIterator<Item = S>)
Removes style classes from the collection.
Sourcepub fn remove_range(&self, index: usize, count: usize)
pub fn remove_range(&self, index: usize, count: usize)
Removes a range of style classes from the collection.
Sourcepub fn replace<S: AsRef<str>>(&self, source: &[S])
pub fn replace<S: AsRef<str>>(&self, source: &[S])
Removes all non-pseudoclasses in the collection and adds a new set.
Sourcepub fn add_listener(&self, listener: Rc<dyn Fn()>) -> u64
pub fn add_listener(&self, listener: Rc<dyn Fn()>) -> u64
Registers a listener invoked whenever the classes change. Returns a
token for remove_listener.
pub fn remove_listener(&self, token: u64) -> bool
Sourcepub fn listener_count(&self) -> usize
pub fn listener_count(&self) -> usize
The number of registered listeners.
Trait Implementations§
Source§impl IPseudoClasses for Classes
impl IPseudoClasses for Classes
Source§impl MarkupTyped for Classes
impl MarkupTyped for Classes
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Auto Trait Implementations§
impl !RefUnwindSafe for Classes
impl !Send for Classes
impl !Sync for Classes
impl !UnwindSafe for Classes
impl Freeze for Classes
impl Unpin for Classes
impl UnsafeUnpin for Classes
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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