Skip to main content

Style

Struct Style 

Source
pub struct Style {
    pub font_size: Option<f32>,
    pub bold: Option<bool>,
    pub color: Option<String>,
    pub background: Option<String>,
    pub border_color: Option<String>,
    pub border_width: Option<f32>,
    pub borders: Option<String>,
    pub padding: Option<f32>,
    pub text_align: Option<TextAlign>,
    pub vertical_align: Option<VerticalAlign>,
    pub word_wrap: Option<bool>,
}
Expand description

Appearance settings. Every field is optional so styles can be layered: built-in defaults, then a named style, then the control’s own settings, then conditional rules.

Fields§

§font_size: Option<f32>

Font size in points.

§bold: Option<bool>

Bold text.

§color: Option<String>

Text color, #rrggbb or #rrggbbaa.

§background: Option<String>

Fill color.

§border_color: Option<String>

Border color.

§border_width: Option<f32>

Border width in points; 0 for none.

§borders: Option<String>

Which sides have a border: any of top, right, bottom, left, or all.

§padding: Option<f32>

Inner padding in points.

§text_align: Option<TextAlign>

Horizontal alignment.

§vertical_align: Option<VerticalAlign>

Vertical alignment.

§word_wrap: Option<bool>

Wraps long text onto more lines (true by default).

Implementations§

Source§

impl Style

Source

pub fn new() -> Self

An empty style.

Source

pub fn font_size(self, size: f32) -> Self

Sets the font size.

Source

pub fn bold(self) -> Self

Makes the text bold.

Source

pub fn color(self, color: &str) -> Self

Sets the text color (#rrggbb).

Source

pub fn background(self, color: &str) -> Self

Sets the fill color (#rrggbb).

Source

pub fn border(self, sides: &str, width: f32, color: &str) -> Self

Adds a border of width points in color on sides (all, bottom, top bottom…).

Source

pub fn padding(self, padding: f32) -> Self

Sets the inner padding.

Source

pub fn align(self, align: TextAlign) -> Self

Sets the horizontal alignment.

Source

pub fn valign(self, align: VerticalAlign) -> Self

Sets the vertical alignment.

Source

pub fn merged(&self, other: &Style) -> Style

Settings of other override these where other has them.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

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 Style

Source§

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

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

impl Default for Style

Source§

fn default() -> Style

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

impl<'de> Deserialize<'de> for Style
where Style: Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Style

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Style

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Style

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

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> 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
§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.