Struct FormattedText

Source
pub struct FormattedText {
    pub shadow: InheritableVariable<bool>,
    pub shadow_brush: InheritableVariable<Brush>,
    pub shadow_dilation: InheritableVariable<f32>,
    pub shadow_offset: InheritableVariable<Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>>,
    /* private fields */
}

Fields§

§shadow: InheritableVariable<bool>§shadow_brush: InheritableVariable<Brush>§shadow_dilation: InheritableVariable<f32>§shadow_offset: InheritableVariable<Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>>

Implementations§

Source§

impl FormattedText

Source

pub const FONT: &'static str = "font"

Source

pub const TEXT: &'static str = "text"

Source

pub const VERTICAL_ALIGNMENT: &'static str = "vertical_alignment"

Source

pub const HORIZONTAL_ALIGNMENT: &'static str = "horizontal_alignment"

Source

pub const BRUSH: &'static str = "brush"

Source

pub const WRAP: &'static str = "wrap"

Source

pub const MASK_CHAR: &'static str = "mask_char"

Source

pub const FONT_SIZE: &'static str = "font_size"

Source

pub const SHADOW: &'static str = "shadow"

Source

pub const SHADOW_BRUSH: &'static str = "shadow_brush"

Source

pub const SHADOW_DILATION: &'static str = "shadow_dilation"

Source

pub const SHADOW_OFFSET: &'static str = "shadow_offset"

Source§

impl FormattedText

Source

pub fn nearest_valid_position(&self, start: Position) -> Position

Source

pub fn get_relative_position_x( &self, start: Position, offset: isize, ) -> Position

Source

pub fn get_relative_position_y( &self, start: Position, offset: isize, ) -> Position

Source

pub fn get_line_range(&self, line: usize) -> Range<Position>

Source

pub fn iter_line_ranges_within( &self, range: Range<Position>, ) -> impl Iterator<Item = Range<Position>>

Source

pub fn end_position(&self) -> Position

Source

pub fn position_range_to_char_index_range( &self, range: Range<Position>, ) -> Range<usize>

Source

pub fn position_to_char_index_unclamped( &self, position: Position, ) -> Option<usize>

Maps input Position to a linear position in character array. The index returned is the index of the character after the position, which may be out-of-bounds if thee position is at the end of the text. You should check the index before trying to use it to fetch data from inner array of characters.

Source

pub fn position_to_char_index_clamped( &self, position: Position, ) -> Option<usize>

Maps input Position to a linear position in character array. The index returned is usually the index of the character after the position, but if the position is at the end of a line then return the index of the character before the position. In other words, the last two positions of each line are mapped to the same character index. Output index will always be valid for fetching, if the method returned Some(index). The index however cannot be used for text insertion, because it cannot point to a “place after last char”.

Source

pub fn char_index_to_position(&self, i: usize) -> Option<Position>

Maps linear character index (as in string) to its actual location in the text.

Source

pub fn position_to_local( &self, position: Position, ) -> Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>

Source

pub fn local_to_position( &self, point: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>, ) -> Position

Source

pub fn get_glyphs(&self) -> &[TextGlyph]

Source

pub fn get_font(&self) -> Resource<Font>

Source

pub fn set_font(&mut self, font: Resource<Font>) -> &mut FormattedText

Source

pub fn font_size(&self) -> &StyledProperty<f32>

Source

pub fn super_sampled_font_size(&self) -> f32

Source

pub fn set_font_size( &mut self, font_size: StyledProperty<f32>, ) -> &mut FormattedText

Source

pub fn get_lines(&self) -> &[TextLine]

Source

pub fn set_vertical_alignment( &mut self, vertical_alignment: VerticalAlignment, ) -> &mut FormattedText

Source

pub fn vertical_alignment(&self) -> VerticalAlignment

Source

pub fn set_horizontal_alignment( &mut self, horizontal_alignment: HorizontalAlignment, ) -> &mut FormattedText

Source

pub fn horizontal_alignment(&self) -> HorizontalAlignment

Source

pub fn set_brush(&mut self, brush: Brush) -> &mut FormattedText

Source

pub fn brush(&self) -> Brush

Source

pub fn set_super_sampling_scale(&mut self, scale: f32) -> &mut FormattedText

Source

pub fn set_constraint( &mut self, constraint: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>, ) -> &mut FormattedText

Source

pub fn get_raw_text(&self) -> &[char]

Source

pub fn text(&self) -> String

Source

pub fn text_range(&self, range: Range<usize>) -> String

Source

pub fn get_range_width<T>(&self, range: T) -> f32
where T: IntoIterator<Item = usize>,

Source

pub fn set_text<P>(&mut self, text: P) -> &mut FormattedText
where P: AsRef<str>,

Source

pub fn set_wrap(&mut self, wrap: WrapMode) -> &mut FormattedText

Source

pub fn set_shadow(&mut self, shadow: bool) -> &mut FormattedText

Sets whether the shadow enabled or not.

Source

pub fn set_shadow_brush(&mut self, brush: Brush) -> &mut FormattedText

Sets desired shadow brush. It will be used to render the shadow.

Source

pub fn set_shadow_dilation(&mut self, thickness: f32) -> &mut FormattedText

Sets desired shadow dilation in units. Keep in mind that the dilation is absolute, not percentage-based.

Source

pub fn set_shadow_offset( &mut self, offset: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>, ) -> &mut FormattedText

Sets desired shadow offset in units.

Source

pub fn wrap_mode(&self) -> WrapMode

Source

pub fn insert_char(&mut self, code: char, index: usize) -> &mut FormattedText

Source

pub fn insert_str(&mut self, str: &str, position: usize) -> &mut FormattedText

Source

pub fn remove_range(&mut self, range: Range<usize>) -> &mut FormattedText

Source

pub fn remove_at(&mut self, index: usize) -> &mut FormattedText

Source

pub fn build( &mut self, ) -> Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>

Trait Implementations§

Source§

impl Clone for FormattedText

Source§

fn clone(&self) -> FormattedText

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FormattedText

Source§

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

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

impl Default for FormattedText

Source§

fn default() -> FormattedText

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

impl Reflect for FormattedText

Source§

fn source_path() -> &'static str

Source§

fn type_name(&self) -> &'static str

Source§

fn doc(&self) -> &'static str

Source§

fn assembly_name(&self) -> &'static str

Returns a parent assembly name of the type that implements this trait. WARNING: You should use proc-macro (#[derive(Reflect)]) to ensure that this method will return correct assembly name. In other words - there’s no guarantee, that any implementation other than proc-macro will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME") as an implementation.
Source§

fn type_assembly_name() -> &'static str

Returns a parent assembly name of the type that implements this trait. WARNING: You should use proc-macro (#[derive(Reflect)]) to ensure that this method will return correct assembly name. In other words - there’s no guarantee, that any implementation other than proc-macro will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME") as an implementation.
Source§

fn fields_info(&self, func: &mut dyn FnMut(&[FieldInfo<'_, '_>]))

Source§

fn into_any(self: Box<FormattedText>) -> Box<dyn Any>

Source§

fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>

Source§

fn as_any(&self, func: &mut dyn FnMut(&(dyn Any + 'static)))

Source§

fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Any + 'static)))

Source§

fn as_reflect(&self, func: &mut dyn FnMut(&(dyn Reflect + 'static)))

Source§

fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Reflect + 'static)))

Source§

fn fields(&self, func: &mut dyn FnMut(&[&(dyn Reflect + 'static)]))

Source§

fn fields_mut( &mut self, func: &mut dyn FnMut(&mut [&mut (dyn Reflect + 'static)]), )

Source§

fn field( &self, name: &str, func: &mut dyn FnMut(Option<&(dyn Reflect + 'static)>), )

Source§

fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut (dyn Reflect + 'static)>), )

Source§

fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>), )

Calls user method specified with #[reflect(setter = ..)] or falls back to Reflect::field_mut
Source§

fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))

Source§

fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>), )

Source§

fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))

Source§

fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>), )

Source§

fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>), )

Source§

fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>), )

Source§

fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>), )

Source§

fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>), )

Source§

impl Visit for FormattedText

Source§

fn visit(&mut self, name: &str, visitor: &mut Visitor) -> Result<(), VisitError>

Read or write this value, depending on whether Visitor::is_reading() is true or false. Read more

Auto Trait Implementations§

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> AsyncTaskResult for T
where T: Any + Send + 'static,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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
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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

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

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<R> GetField for R
where R: Reflect,

Source§

fn get_field<T>(&self, name: &str, func: &mut dyn FnMut(Option<&T>))
where T: 'static,

Source§

fn get_field_mut<T>(&mut self, name: &str, func: &mut dyn FnMut(Option<&mut T>))
where T: 'static,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ReflectBase for T
where T: Reflect,

Source§

fn as_any_raw(&self) -> &(dyn Any + 'static)

Source§

fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

impl<T> ResolvePath for T
where T: Reflect,

Source§

fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )

Source§

fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )

Source§

fn get_resolve_path<'p, T>( &self, path: &'p str, func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>), )
where T: Reflect,

Source§

fn get_resolve_path_mut<'p, T>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>), )
where T: Reflect,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ScriptMessagePayload for T
where T: 'static + Send + Debug,

Source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns self as &dyn Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns self as &dyn Any
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Value for T
where T: Reflect + Clone + Debug + Send,

Source§

fn clone_box(&self) -> Box<dyn Value>

Source§

fn into_box_reflect(self: Box<T>) -> Box<dyn Reflect>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more