Struct Galley

Source
pub struct Galley {
    pub job: Arc<LayoutJob>,
    pub rows: Vec<Row>,
    pub elided: bool,
    pub rect: Rect,
    pub mesh_bounds: Rect,
    pub num_vertices: usize,
    pub num_indices: usize,
    pub pixels_per_point: f32,
}
Expand description

Text that has been laid out, ready for painting.

You can create a Galley using crate::Fonts::layout_job;

Needs to be recreated if the underlying font atlas texture changes, which happens under the following conditions:

  • pixels_per_point or max_texture_size change. These parameters are set in crate::text::Fonts::begin_frame. When using egui they are set from egui::InputState and can change at any time.
  • The atlas has become full. This can happen any time a new glyph is added to the atlas, which in turn can happen any time new text is laid out.

Fields§

§job: Arc<LayoutJob>

The job that this galley is the result of. Contains the original string and style sections.

§rows: Vec<Row>

Rows of text, from top to bottom.

The number of characters in all rows sum up to job.text.chars().count() unless Self::elided is true.

Note that a paragraph (a piece of text separated with \n) can be split up into multiple rows.

§elided: bool

Set to true the text was truncated due to TextWrapping::max_rows.

§rect: Rect

Bounding rect.

rect.top() is always 0.0.

With LayoutJob::halign:

§mesh_bounds: Rect

Tight bounding box around all the meshes in all the rows. Can be used for culling.

§num_vertices: usize

Total number of vertices in all the row meshes.

§num_indices: usize

Total number of indices in all the row meshes.

§pixels_per_point: f32

The number of physical pixels for each logical point. Since this affects the layout, we keep track of it so that we can warn if this has changed once we get to tessellation.

Implementations§

Source§

impl Galley

Source

pub fn is_empty(&self) -> bool

Source

pub fn text(&self) -> &str

The full, non-elided text of the input job.

Source

pub fn size(&self) -> Vec2

Source§

impl Galley

§Physical positions
Source

pub fn pos_from_pcursor(&self, pcursor: PCursor) -> Rect

Returns a 0-width Rect.

Source

pub fn pos_from_cursor(&self, cursor: &Cursor) -> Rect

Returns a 0-width Rect.

Source

pub fn cursor_from_pos(&self, pos: Vec2) -> Cursor

Cursor at the given position within the galley

Source§

impl Galley

§Cursor positions
Source

pub fn end(&self) -> Cursor

Cursor to one-past last character.

Source

pub fn end_rcursor(&self) -> RCursor

Source§

impl Galley

§Cursor conversions
Source

pub fn from_ccursor(&self, ccursor: CCursor) -> Cursor

Source

pub fn from_rcursor(&self, rcursor: RCursor) -> Cursor

Source

pub fn from_pcursor(&self, pcursor: PCursor) -> Cursor

Source§

impl Galley

§Cursor positions
Source

pub fn cursor_left_one_character(&self, cursor: &Cursor) -> Cursor

Source

pub fn cursor_right_one_character(&self, cursor: &Cursor) -> Cursor

Source

pub fn cursor_up_one_row(&self, cursor: &Cursor) -> Cursor

Source

pub fn cursor_down_one_row(&self, cursor: &Cursor) -> Cursor

Source

pub fn cursor_begin_of_row(&self, cursor: &Cursor) -> Cursor

Source

pub fn cursor_end_of_row(&self, cursor: &Cursor) -> Cursor

Trait Implementations§

Source§

impl Clone for Galley

Source§

fn clone(&self) -> Galley

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 Galley

Source§

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

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

impl PartialEq for Galley

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Galley

Auto Trait Implementations§

§

impl Freeze for Galley

§

impl RefUnwindSafe for Galley

§

impl Send for Galley

§

impl Sync for Galley

§

impl Unpin for Galley

§

impl UnwindSafe for Galley

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
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

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<T> Same for T

Source§

type Output = T

Should always be Self
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

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

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,