pub struct SalsaTheme {
pub name: String,
pub theme: String,
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§theme: String§p: PaletteImplementations§
Source§impl SalsaTheme
impl SalsaTheme
Sourcepub fn define_style(&mut self, name: &'static str, style: Style)
pub fn define_style(&mut self, name: &'static str, style: Style)
Define a style as a plain Style.
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 defined 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 WidgetStyle::default as the style-fn.
Sourcepub fn modify<O: Any + Default + Debug + Sized + 'static>(
&mut self,
name: &'static str,
modify: impl Fn(O, &SalsaTheme) -> O + 'static,
)
pub fn modify<O: Any + Default + Debug + Sized + 'static>( &mut self, name: &'static str, modify: impl Fn(O, &SalsaTheme) -> O + 'static, )
Add a modification of a defined style.
This function is applied to the original style every time the style is queried.
Currently only a single modification is possible. If you set a second one it will overwrite the previous.
Panic
- When debug_assertions are enabled the modifier will panic if
it gets a type other than
O. - Otherwise it will fall back to the default value of
O.
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 defined as impl Into<Style>.
This may fail:
Panic
- 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:
Panic
- 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
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