Skip to main content

Classes

Struct Classes 

Source
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

Source

pub fn new() -> Self

Creates an empty collection.

Source

pub fn from_names<S: Into<String>>(items: impl IntoIterator<Item = S>) -> Self

Creates a collection from the given class names.

Source

pub fn ptr_eq(&self, other: &Self) -> bool

Whether two handles refer to the same collection.

Source

pub fn parse(s: &str) -> Classes

Parses a space-separated list of class names.

Source

pub fn capacity(&self) -> usize

The number of class names the collection can hold before its storage grows.

Source

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.

Source

pub fn count(&self) -> usize

The number of classes.

Source

pub fn get(&self, index: usize) -> String

The class at index.

Source

pub fn snapshot(&self) -> Rc<Vec<String>>

A snapshot of the classes.

Source

pub fn contains(&self, name: &str) -> bool

Returns whether a class is present in the collection.

Source

pub fn add_collection_changed( &self, handler: Rc<CollectionChangedHandler<String>>, ) -> u64

Subscribes to collection changes; see FerroList::add_collection_changed.

Source

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

Source

pub fn add(&self, name: &str)

Adds a style class to the collection. Only standard classes may be added via this method.

Source

pub fn add_range<S: AsRef<str>>(&self, names: impl IntoIterator<Item = S>)

Adds style classes to the collection.

Source

pub fn clear(&self)

Removes all non-pseudoclasses from the collection.

Source

pub fn insert(&self, index: usize, name: &str)

Inserts a style class into the collection.

Source

pub fn insert_range<S: AsRef<str>>( &self, index: usize, names: impl IntoIterator<Item = S>, )

Inserts style classes into the collection.

Source

pub fn remove(&self, name: &str) -> bool

Removes a style class from the collection.

Source

pub fn remove_all<S: AsRef<str>>(&self, names: impl IntoIterator<Item = S>)

Removes style classes from the collection.

Source

pub fn remove_at(&self, index: usize)

Removes the style class at the specified index.

Source

pub fn remove_range(&self, index: usize, count: usize)

Removes a range of style classes from the collection.

Source

pub fn replace<S: AsRef<str>>(&self, source: &[S])

Removes all non-pseudoclasses in the collection and adds a new set.

Source

pub fn set(&self, name: &str, value: bool)

Adds or removes a style class.

Source

pub fn add_listener(&self, listener: Rc<dyn Fn()>) -> u64

Registers a listener invoked whenever the classes change. Returns a token for remove_listener.

Source

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

Source

pub fn listener_count(&self) -> usize

The number of registered listeners.

Trait Implementations§

Source§

impl Clone for Classes

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Classes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Classes

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl IPseudoClasses for Classes

Source§

fn add_pseudo(&self, name: &str)

Adds a pseudoclass to the collection.
Source§

fn remove_pseudo(&self, name: &str) -> bool

Removes a pseudoclass from the collection.
Source§

fn contains(&self, name: &str) -> bool

Returns whether a pseudoclass is present in the collection.
Source§

impl MarkupTyped for Classes

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl PartialEq for Classes

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> AnyValue for T
where T: PartialEq + 'static,

Source§

fn any_value_as_any(&self) -> &(dyn Any + 'static)

Source§

fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool

Source§

fn any_value_type_name(&self) -> &'static str

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<T> PropertyValue for T
where T: Clone + PartialEq + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.