pub struct SalsaTheme {
pub name: String,
pub cat: Category,
pub p: Palette,
/* private fields */
}Expand description
SalsaTheme holds any predefined styles for the UI.
The foremost usage is as a store of named Styles. It can also hold the structured styles used by rat-widget’s. Or really any value that can be produced by a closure.
It uses a flat naming scheme and doesn’t cascade upwards at all.
Fields§
§name: String§cat: Category§p: PaletteImplementations§
Source§impl SalsaTheme
impl SalsaTheme
Sourcepub fn new(name: impl Into<String>, cat: Category, p: Palette) -> Self
pub fn new(name: impl Into<String>, cat: Category, p: Palette) -> Self
Create an empty theme with a given color palette.
Sourcepub fn define_clone(
&mut self,
name: &'static str,
sample: impl Clone + Any + Debug + 'static,
)
pub fn define_clone( &mut self, name: &'static str, sample: impl Clone + Any + Debug + 'static, )
Define a style a struct that will be cloned for every query.
Sourcepub fn define_fn<O: Any + Debug>(
&mut self,
name: &'static str,
create: impl Fn(&SalsaTheme) -> O + 'static,
)
pub fn define_fn<O: Any + Debug>( &mut self, name: &'static str, create: impl Fn(&SalsaTheme) -> O + 'static, )
Define a style as a call to a constructor fn.
The constructor gets access to all previously initialized styles.
Sourcepub fn define_fn0<O: Any + Debug>(
&mut self,
name: &'static str,
create: impl Fn() -> O + 'static,
)
pub fn define_fn0<O: Any + Debug>( &mut self, name: &'static str, create: impl Fn() -> O + 'static, )
Define a style as a call to a constructor fn.
This one takes no arguments, this is nice to set Widget::default as the style-fn.
Sourcepub fn modify<O: Any + Debug>(
&mut self,
name: &'static str,
modify: impl Fn(Box<dyn Any>, &SalsaTheme) -> Box<O> + 'static,
)
pub fn modify<O: Any + Debug>( &mut self, name: &'static str, modify: impl Fn(Box<dyn Any>, &SalsaTheme) -> Box<O> + 'static, )
Add a modification of a defined style.
Sourcepub fn style_style(&self, name: &str) -> Stylewhere
Self: Sized,
pub fn style_style(&self, name: &str) -> Stylewhere
Self: Sized,
Get one of the defined ratatui-Styles.
This is the same as the single [style] function, it just
fixes the return-type to style. This is useful if the
receiver is declared as impl Into<Style>.
It downcasts the stored value to the required out type. This may fail.
- When debug_assertions are enabled it will panic when called with an unknown style name, or if the downcast to the out type fails.
- Otherwise, it will return the default value of the out type.
Sourcepub fn style<O: Default + Sized + 'static>(&self, name: &str) -> Owhere
Self: Sized,
pub fn style<O: Default + Sized + 'static>(&self, name: &str) -> Owhere
Self: Sized,
Get any of the defined styles.
It downcasts the stored value to the required out type. This may fail.
- When debug_assertions are enabled it will panic when called with an unknown style name, or if the downcast to the out type fails.
- Otherwise, it will return the default value of the out type.
Trait Implementations§
Source§impl Debug for SalsaTheme
impl Debug for SalsaTheme
Source§impl Default for SalsaTheme
impl Default for SalsaTheme
Source§fn default() -> SalsaTheme
fn default() -> SalsaTheme
Auto Trait Implementations§
impl Freeze for SalsaTheme
impl !RefUnwindSafe for SalsaTheme
impl !Send for SalsaTheme
impl !Sync for SalsaTheme
impl Unpin for SalsaTheme
impl !UnwindSafe for SalsaTheme
Blanket Implementations§
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more