clutter/auto/
text_node.rs

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