Skip to main content

HasClasses

Trait HasClasses 

Source
pub trait HasClasses {
Show 13 methods // Required methods fn classes(&self) -> &Classes; fn classes_mut(&mut self) -> &mut Classes; // Provided methods fn has_class(&self, class: &str) -> bool { ... } fn add_class(&mut self, class: impl Into<ClassName>) -> &mut Self where Self: Sized { ... } fn set_class( &mut self, class: impl Into<ClassName>, present: bool, ) -> &mut Self where Self: Sized { ... } fn remove_class(&mut self, class: impl Into<ClassName>) -> &mut Self where Self: Sized { ... } fn with_class(self, class: impl Into<ClassName>) -> Self where Self: Sized { ... } fn add_classes(&mut self, classes: Classes) -> &mut Self { ... } fn with_classes(self, classes: Classes) -> Self where Self: Sized { ... } fn add_class_if( &mut self, class: impl Into<ClassName>, condition: bool, ) -> &mut Self where Self: Sized { ... } fn with_class_if(self, class: impl Into<ClassName>, condition: bool) -> Self where Self: Sized { ... } fn iter_classes(&self) -> Iter<'_, ClassName> ⓘ { ... } fn classes_as_slice(&self) -> &[ClassName] { ... }
}
Available on crate feature egui only.
Expand description

Any widgets supporting crate::class::Classes must implement this trait.

Required Methods§

Source

fn classes(&self) -> &Classes

Source

fn classes_mut(&mut self) -> &mut Classes

Provided Methods§

Source

fn has_class(&self, class: &str) -> bool

True if the class is present.

Source

fn add_class(&mut self, class: impl Into<ClassName>) -> &mut Self
where Self: Sized,

Add the given class in-place.

Source

fn set_class(&mut self, class: impl Into<ClassName>, present: bool) -> &mut Self
where Self: Sized,

Add the given class in-place if present, remove it otherwise.

Use this for a setter that takes a bool, so that the last call wins.

Source

fn remove_class(&mut self, class: impl Into<ClassName>) -> &mut Self
where Self: Sized,

Remove the given class in-place.

Source

fn with_class(self, class: impl Into<ClassName>) -> Self
where Self: Sized,

Add the given class by consuming self.

Source

fn add_classes(&mut self, classes: Classes) -> &mut Self

Append all the given classes at the end, deduplicating them.

Source

fn with_classes(self, classes: Classes) -> Self
where Self: Sized,

Append all the given classes at the end, deduplicating them. Consuming self.

Source

fn add_class_if( &mut self, class: impl Into<ClassName>, condition: bool, ) -> &mut Self
where Self: Sized,

Add a class to the list if the condition is true.

A class is never added twice. This never removes a class: use Self::set_class for that.

Source

fn with_class_if(self, class: impl Into<ClassName>, condition: bool) -> Self
where Self: Sized,

Add the given class by consuming self if the condition is true.

A class is never added twice. This never removes a class: use Self::set_class for that.

Source

fn iter_classes(&self) -> Iter<'_, ClassName> ⓘ

Iterate over the classes, in the order they were added.

Source

fn classes_as_slice(&self) -> &[ClassName]

Return the classes as a slice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§