pub struct LayoutLine { /* private fields */ }
Expand description
A LayoutLine
represents one of the lines resulting from laying
out a paragraph via Layout
.
LayoutLine
structures are obtained by calling
Layout::line()
and are only valid until the text,
attributes, or settings of the parent Layout
are modified.
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
Source§impl LayoutLine
impl LayoutLine
Sourcepub fn as_ptr(&self) -> *mut PangoLayoutLine
pub fn as_ptr(&self) -> *mut PangoLayoutLine
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut PangoLayoutLine) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut PangoLayoutLine) -> &Self
Borrows the underlying C value.
Source§impl LayoutLine
impl LayoutLine
Sourcepub fn extents(&self) -> (Rectangle, Rectangle)
pub fn extents(&self) -> (Rectangle, Rectangle)
Computes the logical and ink extents of a layout line.
See FontExt::glyph_extents()
for details
about the interpretation of the rectangles.
§Returns
§ink_rect
rectangle used to store the extents of the glyph string as drawn
§logical_rect
rectangle used to store the logical extents of the glyph string
Sourcepub fn height(&self) -> i32
Available on crate feature v1_44
only.
pub fn height(&self) -> i32
v1_44
only.Computes the height of the line, as the maximum of the heights of fonts used in this line.
Note that the actual baseline-to-baseline distance between lines
of text is influenced by other factors, such as
Layout::set_spacing()
and
Layout::set_line_spacing()
.
§Returns
§height
return location for the line height
Sourcepub fn pixel_extents(&self) -> (Rectangle, Rectangle)
pub fn pixel_extents(&self) -> (Rectangle, Rectangle)
Computes the logical and ink extents of @self in device units.
This function just calls extents()
followed by
two extents_to_pixels()
calls, rounding @ink_rect and @logical_rect
such that the rounded rectangles fully contain the unrounded one (that is,
passes them as first argument to extents_to_pixels()
).
§Returns
§ink_rect
rectangle used to store the extents of the glyph string as drawn
§logical_rect
rectangle used to store the logical extents of the glyph string
Sourcepub fn resolved_direction(&self) -> Direction
Available on crate feature v1_50
only.
pub fn resolved_direction(&self) -> Direction
v1_50
only.Sourcepub fn start_index(&self) -> i32
Available on crate feature v1_50
only.
pub fn start_index(&self) -> i32
v1_50
only.Returns the start index of the line, as byte index into the text of the layout.
§Returns
the start index of the line
Sourcepub fn index_to_x(&self, index_: i32, trailing: bool) -> i32
pub fn index_to_x(&self, index_: i32, trailing: bool) -> i32
Converts an index within a line to a X position.
§index_
byte offset of a grapheme within the layout
§trailing
an integer indicating the edge of the grapheme to retrieve the position of. If > 0, the trailing edge of the grapheme, if 0, the leading of the grapheme
§Returns
§x_pos
location to store the x_offset (in Pango units)
Sourcepub fn is_paragraph_start(&self) -> bool
Available on crate feature v1_50
only.
pub fn is_paragraph_start(&self) -> bool
v1_50
only.Source§impl LayoutLine
impl LayoutLine
pub fn runs(&self) -> Vec<LayoutRun>
Sourcepub fn x_to_index(&self, x_pos: i32) -> HitPosition
pub fn x_to_index(&self, x_pos: i32) -> HitPosition
Converts from x offset to the byte index of the corresponding character within the text of the layout.
If @x_pos is outside the line, @index_ and @trailing will point to the very first or very last position in the line. This determination is based on the resolved direction of the paragraph; for example, if the resolved direction is right-to-left, then an X position to the right of the line (after it) results in 0 being stored in @index_ and @trailing. An X position to the left of the line results in @index_ pointing to the (logical) last grapheme in the line and @trailing being set to the number of characters in that grapheme. The reverse is true for a left-to-right line.
§x_pos
the X offset (in Pango units) from the left edge of the line.
§Returns
false
if @x_pos was outside the line, true
if inside
§index_
location to store calculated byte index for the grapheme in which the user clicked
§trailing
location to store an integer indicating where in the grapheme the user clicked. It will either be zero, or the number of characters in the grapheme. 0 represents the leading edge of the grapheme.
Sourcepub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec<i32>
pub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec<i32>
Gets a list of visual ranges corresponding to a given logical range.
This list is not necessarily minimal - there may be consecutive ranges which are adjacent. The ranges will be sorted from left to right. The ranges are with respect to the left edge of the entire layout, not with respect to the line.
§start_index
Start byte index of the logical range. If this value is less than the start index for the line, then the first range will extend all the way to the leading edge of the layout. Otherwise, it will start at the leading edge of the first character.
§end_index
Ending byte index of the logical range. If this value is greater than the end index for the line, then the last range will extend all the way to the trailing edge of the layout. Otherwise, it will end at the trailing edge of the last character.
§Returns
§ranges
location to
store a pointer to an array of ranges. The array will be of length
2*n_ranges
, with each range starting at (*ranges)[2*n]
and of
width (*ranges)[2*n + 1] - (*ranges)[2*n]
. This array must be freed
with g_free(). The coordinates are relative to the layout and are in
Pango units.
Trait Implementations§
Source§impl Clone for LayoutLine
impl Clone for LayoutLine
Source§impl Debug for LayoutLine
impl Debug for LayoutLine
Source§impl From<LayoutLine> for Value
impl From<LayoutLine> for Value
Source§fn from(s: LayoutLine) -> Self
fn from(s: LayoutLine) -> Self
Source§impl HasParamSpec for LayoutLine
impl HasParamSpec for LayoutLine
type ParamSpec = ParamSpecBoxed
Source§type SetValue = LayoutLine
type SetValue = LayoutLine
type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, LayoutLine>
fn param_spec_builder() -> Self::BuilderFn
Source§impl Hash for LayoutLine
impl Hash for LayoutLine
Source§impl Ord for LayoutLine
impl Ord for LayoutLine
Source§fn cmp(&self, other: &LayoutLine) -> Ordering
fn cmp(&self, other: &LayoutLine) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for LayoutLine
impl PartialEq for LayoutLine
Source§impl PartialOrd for LayoutLine
impl PartialOrd for LayoutLine
Source§impl StaticType for LayoutLine
impl StaticType for LayoutLine
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for LayoutLine
impl StructuralPartialEq for LayoutLine
Auto Trait Implementations§
impl Freeze for LayoutLine
impl RefUnwindSafe for LayoutLine
impl !Send for LayoutLine
impl !Sync for LayoutLine
impl Unpin for LayoutLine
impl UnwindSafe for LayoutLine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)