animate/legacy/
text_node.rs1use crate::{Color, InternalColor, PaintNode, RgbaColor};
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 pub fn new(layout: Option<&pango::Layout>, color: Option<Color>) -> TextNode {
30 let color = match color {
31 Some(value) => {
32 let RgbaColor {
33 red,
34 green,
35 blue,
36 alpha,
37 } = value.into();
38 Some(InternalColor::new(red, green, blue, alpha))
39 }
40 None => None,
41 };
42 unsafe {
43 PaintNode::from_glib_full(ffi::clutter_text_node_new(
44 layout.to_glib_none().0,
45 color.to_glib_none().0,
46 ))
47 .unsafe_cast()
48 }
49 }
50}
51
52impl fmt::Display for TextNode {
53 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54 write!(f, "TextNode")
55 }
56}