[−][src]Struct embedded_text::style::TextBoxStyle
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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
pub fn new(
font: F,
text_color: C,
alignment: A,
vertical_alignment: V,
height_mode: H
) -> Self
[src]
font: F,
text_color: C,
alignment: A,
vertical_alignment: V,
height_mode: H
) -> Self
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]
text_style: TextStyle<C, F>,
alignment: A,
vertical_alignment: V,
height_mode: H
) -> Self
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]
&self,
parser: &mut Parser<'a>,
carried_token: Option<Token<'a>>,
max_line_width: u32
) -> (u32, u32, Option<Token<'a>>)
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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
fn clone(&self) -> TextBoxStyle<C, F, A, V, H>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
fn default() -> TextBoxStyle<C, F, A, V, H>
[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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
fn cmp(&self, other: &TextBoxStyle<C, F, A, V, H>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
fn eq(&self, other: &TextBoxStyle<C, F, A, V, H>) -> bool
[src]
fn ne(&self, other: &TextBoxStyle<C, F, A, V, H>) -> bool
[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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
fn partial_cmp(&self, other: &TextBoxStyle<C, F, A, V, H>) -> Option<Ordering>
[src]
fn lt(&self, other: &TextBoxStyle<C, F, A, V, H>) -> bool
[src]
fn le(&self, other: &TextBoxStyle<C, F, A, V, H>) -> bool
[src]
fn gt(&self, other: &TextBoxStyle<C, F, A, V, H>) -> bool
[src]
fn ge(&self, other: &TextBoxStyle<C, F, A, V, H>) -> bool
[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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
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]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
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,
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,
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,
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,
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,
A: UnwindSafe,
C: UnwindSafe,
F: UnwindSafe,
H: UnwindSafe,
V: UnwindSafe,
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,
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.
fn to_owned(&self) -> T
[src]
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.
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>,