pango/auto/
layout_line.rs1#[cfg(feature = "v1_50")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
7use crate::Direction;
8use crate::{ffi, Rectangle};
9use glib::translate::*;
10
11glib::wrapper! {
12 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
13 pub struct LayoutLine(Shared<ffi::PangoLayoutLine>);
14
15 match fn {
16 ref => |ptr| ffi::pango_layout_line_ref(ptr),
17 unref => |ptr| ffi::pango_layout_line_unref(ptr),
18 type_ => || ffi::pango_layout_line_get_type(),
19 }
20}
21
22impl LayoutLine {
23 #[doc(alias = "pango_layout_line_get_extents")]
24 #[doc(alias = "get_extents")]
25 pub fn extents(&self) -> (Rectangle, Rectangle) {
26 unsafe {
27 let mut ink_rect = Rectangle::uninitialized();
28 let mut logical_rect = Rectangle::uninitialized();
29 ffi::pango_layout_line_get_extents(
30 self.to_glib_none().0,
31 ink_rect.to_glib_none_mut().0,
32 logical_rect.to_glib_none_mut().0,
33 );
34 (ink_rect, logical_rect)
35 }
36 }
37
38 #[cfg(feature = "v1_44")]
39 #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
40 #[doc(alias = "pango_layout_line_get_height")]
41 #[doc(alias = "get_height")]
42 pub fn height(&self) -> i32 {
43 unsafe {
44 let mut height = std::mem::MaybeUninit::uninit();
45 ffi::pango_layout_line_get_height(self.to_glib_none().0, height.as_mut_ptr());
46 height.assume_init()
47 }
48 }
49
50 #[cfg(feature = "v1_50")]
51 #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
52 #[doc(alias = "pango_layout_line_get_length")]
53 #[doc(alias = "get_length")]
54 pub fn length(&self) -> i32 {
55 unsafe { ffi::pango_layout_line_get_length(self.to_glib_none().0) }
56 }
57
58 #[doc(alias = "pango_layout_line_get_pixel_extents")]
59 #[doc(alias = "get_pixel_extents")]
60 pub fn pixel_extents(&self) -> (Rectangle, Rectangle) {
61 unsafe {
62 let mut ink_rect = Rectangle::uninitialized();
63 let mut logical_rect = Rectangle::uninitialized();
64 ffi::pango_layout_line_get_pixel_extents(
65 self.to_glib_none().0,
66 ink_rect.to_glib_none_mut().0,
67 logical_rect.to_glib_none_mut().0,
68 );
69 (ink_rect, logical_rect)
70 }
71 }
72
73 #[cfg(feature = "v1_50")]
74 #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
75 #[doc(alias = "pango_layout_line_get_resolved_direction")]
76 #[doc(alias = "get_resolved_direction")]
77 pub fn resolved_direction(&self) -> Direction {
78 unsafe {
79 from_glib(ffi::pango_layout_line_get_resolved_direction(
80 self.to_glib_none().0,
81 ))
82 }
83 }
84
85 #[cfg(feature = "v1_50")]
86 #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
87 #[doc(alias = "pango_layout_line_get_start_index")]
88 #[doc(alias = "get_start_index")]
89 pub fn start_index(&self) -> i32 {
90 unsafe { ffi::pango_layout_line_get_start_index(self.to_glib_none().0) }
91 }
92
93 #[doc(alias = "pango_layout_line_index_to_x")]
94 pub fn index_to_x(&self, index_: i32, trailing: bool) -> i32 {
95 unsafe {
96 let mut x_pos = std::mem::MaybeUninit::uninit();
97 ffi::pango_layout_line_index_to_x(
98 self.to_glib_none().0,
99 index_,
100 trailing.into_glib(),
101 x_pos.as_mut_ptr(),
102 );
103 x_pos.assume_init()
104 }
105 }
106
107 #[cfg(feature = "v1_50")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
109 #[doc(alias = "pango_layout_line_is_paragraph_start")]
110 pub fn is_paragraph_start(&self) -> bool {
111 unsafe {
112 from_glib(ffi::pango_layout_line_is_paragraph_start(
113 self.to_glib_none().0,
114 ))
115 }
116 }
117}