1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::{Color, PaintNode};
use glib::{object::Cast, translate::*};
use std::fmt;
glib_wrapper! {
pub struct TextNode(Object<ffi::ClutterTextNode, ffi::ClutterTextNodeClass, TextNodeClass>) @extends PaintNode;
match fn {
get_type => || ffi::clutter_text_node_get_type(),
}
}
impl TextNode {
/// Creates a new `PaintNode` that will paint a `pango::Layout`
/// with the given color.
///
/// This function takes a reference on the passed `layout`, so it
/// is safe to call `gobject::ObjectExt::unref` after it returns.
/// ## `layout`
/// a `pango::Layout`, or `None`
/// ## `color`
/// the color used to paint the layout,
/// or `None`
///
/// # Returns
///
/// the newly created `PaintNode`.
/// Use `PaintNodeExt::unref` when done
pub fn new(layout: Option<&pango::Layout>, color: Option<&Color>) -> TextNode {
unsafe {
PaintNode::from_glib_full(ffi::clutter_text_node_new(
layout.to_glib_none().0,
color.to_glib_none().0,
))
.unsafe_cast()
}
}
}
impl fmt::Display for TextNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "TextNode")
}
}