[−][src]Struct unsegen::base::style::StyleModifier
Defines a set of modifications on a style. Multiple modifiers can be combined before applying them to a style.
Implementations
impl StyleModifier
[src]
pub fn new() -> Self
[src]
Construct a new (not actually) modifier, that leaves all style properties unchanged.
pub fn fg_color(self, fg_color: Color) -> Self
[src]
Make the modifier change the foreground color to the specified value.
pub fn bg_color(self, bg_color: Color) -> Self
[src]
Make the modifier change the background color to the specified value.
pub fn format(self, format: TextFormatModifier) -> Self
[src]
Make the modifier change the textformat of the style to the specified value.
pub fn bold<M: Into<BoolModifyMode>>(self, val: M) -> Self
[src]
Make the modifier change the bold property of the textformat of the style to the specified value.
This is a shortcut for using format
using a TextFormatModifier that changes the bold
property.
Examples:
use unsegen::base::{StyleModifier, TextFormatModifier}; let s1 = StyleModifier::new().bold(true); let s2 = StyleModifier::new().format(TextFormatModifier::new().bold(true)); assert_eq!(s1, s2);
pub fn italic<M: Into<BoolModifyMode>>(self, val: M) -> Self
[src]
Make the modifier change the italic property of the textformat of the style to the specified value.
This is a shortcut for using format
using a TextFormatModifier that changes the italic
property.
Examples:
use unsegen::base::{StyleModifier, TextFormatModifier}; let s1 = StyleModifier::new().italic(true); let s2 = StyleModifier::new().format(TextFormatModifier::new().italic(true)); assert_eq!(s1, s2);
pub fn invert<M: Into<BoolModifyMode>>(self, val: M) -> Self
[src]
Make the modifier change the invert property of the textformat of the style to the specified value.
This is a shortcut for using format
using a TextFormatModifier that changes the invert
property.
Examples:
use unsegen::base::{StyleModifier, TextFormatModifier}; let s1 = StyleModifier::new().invert(true); let s2 = StyleModifier::new().format(TextFormatModifier::new().invert(true)); assert_eq!(s1, s2);
pub fn underline<M: Into<BoolModifyMode>>(self, val: M) -> Self
[src]
Make the modifier change the underline property of the textformat of the style to the specified value.
This is a shortcut for using format
using a TextFormatModifier that changes the underline
property.
Examples:
use unsegen::base::{StyleModifier, TextFormatModifier}; let s1 = StyleModifier::new().underline(true); let s2 = StyleModifier::new().format(TextFormatModifier::new().underline(true)); assert_eq!(s1, s2);
pub fn on_top_of(self, other: StyleModifier) -> Self
[src]
Combine the current value with that of the argument so that the application of the returned value is always equivalent to first applying other and then applying self to some Style.
Examples:
use unsegen::base::*; let mut s1 = Style::default(); let mut s2 = s1; let m1 = StyleModifier::new().fg_color(Color::Red).italic(BoolModifyMode::Toggle).bold(true).underline(false); let m2 = StyleModifier::new().bg_color(Color::Blue).italic(true).bold(false); m1.on_top_of(m2).modify(&mut s1); m2.modify(&mut s2); m1.modify(&mut s2); assert_eq!(s1, s2);
pub fn apply_to_default(self) -> Style
[src]
Apply the modifier to a default (i.e., empty) Style. In a way, this converts the StyleModifier to a Style.
Examples:
use unsegen::base::*; let m = StyleModifier::new().fg_color(Color::Red).italic(true); let mut style = Style::default(); assert_eq!(m.apply(style), m.apply_to_default());
pub fn apply(self, style: Style) -> Style
[src]
Apply this modifier to a given style and return the result. This is essentially a convenience wrapper around modify, which clones the Style.
Examples:
use unsegen::base::*; let m = StyleModifier::new().fg_color(Color::Red).italic(BoolModifyMode::Toggle); let mut style = Style::default(); let style2 = m.apply(style); m.modify(&mut style); assert_eq!(style, style2);
pub fn modify(self, style: &mut Style)
[src]
Modify the given style according to the properties of this modifier.
Trait Implementations
impl Clone for StyleModifier
[src]
fn clone(&self) -> StyleModifier
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for StyleModifier
[src]
impl Debug for StyleModifier
[src]
impl Default for StyleModifier
[src]
fn default() -> StyleModifier
[src]
impl Eq for StyleModifier
[src]
impl PartialEq<StyleModifier> for StyleModifier
[src]
fn eq(&self, other: &StyleModifier) -> bool
[src]
fn ne(&self, other: &StyleModifier) -> bool
[src]
impl StructuralEq for StyleModifier
[src]
impl StructuralPartialEq for StyleModifier
[src]
Auto Trait Implementations
impl RefUnwindSafe for StyleModifier
impl Send for StyleModifier
impl Sync for StyleModifier
impl Unpin for StyleModifier
impl UnwindSafe for StyleModifier
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,