animate/legacy/
color_node.rs

1use crate::{Color, InternalColor, PaintNode, PipelineNode, RgbaColor};
2use glib::{object::Cast, translate::*};
3use std::fmt;
4
5glib_wrapper! {
6    pub struct ColorNode(Object<ffi::ClutterColorNode, ffi::ClutterColorNodeClass, ColorNodeClass>) @extends PipelineNode, PaintNode;
7
8    match fn {
9        get_type => || ffi::clutter_color_node_get_type(),
10    }
11}
12
13impl ColorNode {
14    /// Creates a new `PaintNode` that will paint a solid color
15    /// fill using `color`.
16    /// ## `color`
17    /// the color to paint, or `None`
18    ///
19    /// # Returns
20    ///
21    /// the newly created `PaintNode`. Use
22    ///  `PaintNodeExt::unref` when done
23    pub fn new(color: Option<Color>) -> ColorNode {
24        let color = match color {
25            Some(value) => {
26                let RgbaColor {
27                    red,
28                    green,
29                    blue,
30                    alpha,
31                } = value.into();
32                Some(InternalColor::new(red, green, blue, alpha))
33            }
34            None => None,
35        };
36        unsafe {
37            PaintNode::from_glib_full(ffi::clutter_color_node_new(color.to_glib_none().0))
38                .unsafe_cast()
39        }
40    }
41}
42
43impl fmt::Display for ColorNode {
44    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
45        write!(f, "ColorNode")
46    }
47}