[][src]Struct embedded_text::style::TextBoxStyle

pub struct TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
{ pub text_style: TextStyle<C, F>, pub alignment: A, pub vertical_alignment: V, pub height_mode: H, pub line_spacing: i32, }

Styling options of a TextBox.

TextBoxStyle contains the Font, foreground and background PixelColor, line spacing, HeightMode, HorizontalTextAlignment and VerticalTextAlignment information necessary to draw a TextBox.

To construct a new TextBoxStyle object, use the new or from_text_style methods or the TextBoxStyleBuilder object.

Fields

text_style: TextStyle<C, F>

Style properties for text.

alignment: A

Horizontal text alignment.

vertical_alignment: V

Vertical text alignment.

height_mode: H

The height behaviour

line_spacing: i32

Desired space between lines, in pixels

Implementations

impl<C, F, A, V, H> TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

pub fn new(
    font: F,
    text_color: C,
    alignment: A,
    vertical_alignment: V,
    height_mode: H
) -> Self
[src]

Creates a TextBoxStyle object with transparent background.

pub fn from_text_style(
    text_style: TextStyle<C, F>,
    alignment: A,
    vertical_alignment: V,
    height_mode: H
) -> Self
[src]

Creates a TextBoxStyle object from the given text style and alignment.

#[must_use]pub fn measure_line<'a>(
    &self,
    parser: &mut Parser<'a>,
    carried_token: Option<Token<'a>>,
    max_line_width: u32
) -> (u32, u32, Option<Token<'a>>)
[src]

Measure the width and count spaces in a single line of text.

Returns (width, rendered space count, carried token)

Instead of peeking ahead when processing tokens, this function advances the parser before processing a token. If a token opens a new line, it will be returned as the carried token. If the carried token is None, the parser has finished processing the text.

#[must_use]pub fn measure_text_height(&self, text: &str, max_width: u32) -> u32[src]

Measures text height when rendered using a given width.

Example: measure height of text when rendered using a 6x8 font and 72px width.

let style = TextBoxStyleBuilder::new(Font6x8)
    .text_color(BinaryColor::On)
    .build();

let height = style.measure_text_height(
    "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
    72,
);

// Expect 7 lines of text, wrapped in something like the following:

// |Lorem Ipsum |
// |is simply   |
// |dummy text  |
// |of the      |
// |printing and|
// |typesetting |
// |industry.   |

assert_eq!(7 * 8, height);

Trait Implementations

impl<C: Clone, F: Clone, A: Clone, V: Clone, H: Clone> Clone for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: Copy, F: Copy, A: Copy, V: Copy, H: Copy> Copy for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: Debug, F: Debug, A: Debug, V: Debug, H: Debug> Debug for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: Default, F: Default, A: Default, V: Default, H: Default> Default for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: Eq, F: Eq, A: Eq, V: Eq, H: Eq> Eq for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: Hash, F: Hash, A: Hash, V: Hash, H: Hash> Hash for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: Ord, F: Ord, A: Ord, V: Ord, H: Ord> Ord for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: PartialEq, F: PartialEq, A: PartialEq, V: PartialEq, H: PartialEq> PartialEq<TextBoxStyle<C, F, A, V, H>> for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C: PartialOrd, F: PartialOrd, A: PartialOrd, V: PartialOrd, H: PartialOrd> PartialOrd<TextBoxStyle<C, F, A, V, H>> for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C, F, A, V, H> StructuralEq for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

impl<C, F, A, V, H> StructuralPartialEq for TextBoxStyle<C, F, A, V, H> where
    C: PixelColor,
    F: Font + Copy,
    A: HorizontalTextAlignment,
    V: VerticalTextAlignment,
    H: HeightMode
[src]

Auto Trait Implementations

impl<C, F, A, V, H> RefUnwindSafe for TextBoxStyle<C, F, A, V, H> where
    A: RefUnwindSafe,
    C: RefUnwindSafe,
    F: RefUnwindSafe,
    H: RefUnwindSafe,
    V: RefUnwindSafe

impl<C, F, A, V, H> Send for TextBoxStyle<C, F, A, V, H> where
    A: Send,
    C: Send,
    F: Send,
    H: Send,
    V: Send

impl<C, F, A, V, H> Sync for TextBoxStyle<C, F, A, V, H> where
    A: Sync,
    C: Sync,
    F: Sync,
    H: Sync,
    V: Sync

impl<C, F, A, V, H> Unpin for TextBoxStyle<C, F, A, V, H> where
    A: Unpin,
    C: Unpin,
    F: Unpin,
    H: Unpin,
    V: Unpin

impl<C, F, A, V, H> UnwindSafe for TextBoxStyle<C, F, A, V, H> where
    A: UnwindSafe,
    C: UnwindSafe,
    F: UnwindSafe,
    H: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.