clutter/auto/
paint_node.rs1use crate::ActorBox;
2use glib::{object::IsA, translate::*};
3use std::fmt;
4
5glib_wrapper! {
6 pub struct PaintNode(Object<ffi::ClutterPaintNode, ffi::ClutterPaintNodeClass, PaintNodeClass>);
7
8 match fn {
9 get_type => || ffi::clutter_paint_node_get_type(),
10 }
11}
12
13pub const NONE_PAINT_NODE: Option<&PaintNode> = None;
14
15pub trait PaintNodeExt: 'static {
21 fn add_child<P: IsA<PaintNode>>(&self, child: &P);
27
28 fn add_rectangle(&self, rect: &ActorBox);
33
34 fn add_texture_rectangle(&self, rect: &ActorBox, x_1: f32, y_1: f32, x_2: f32, y_2: f32);
46
47 fn set_name(&self, name: &str);
55}
56
57impl<O: IsA<PaintNode>> PaintNodeExt for O {
58 fn add_child<P: IsA<PaintNode>>(&self, child: &P) {
59 unsafe {
60 ffi::clutter_paint_node_add_child(
61 self.as_ref().to_glib_none().0,
62 child.as_ref().to_glib_none().0,
63 );
64 }
65 }
66
67 fn add_rectangle(&self, rect: &ActorBox) {
68 unsafe {
69 ffi::clutter_paint_node_add_rectangle(
70 self.as_ref().to_glib_none().0,
71 rect.to_glib_none().0,
72 );
73 }
74 }
75
76 fn add_texture_rectangle(&self, rect: &ActorBox, x_1: f32, y_1: f32, x_2: f32, y_2: f32) {
77 unsafe {
78 ffi::clutter_paint_node_add_texture_rectangle(
79 self.as_ref().to_glib_none().0,
80 rect.to_glib_none().0,
81 x_1,
82 y_1,
83 x_2,
84 y_2,
85 );
86 }
87 }
88
89 fn set_name(&self, name: &str) {
90 unsafe {
91 ffi::clutter_paint_node_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
92 }
93 }
94}
95
96impl fmt::Display for PaintNode {
97 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
98 write!(f, "PaintNode")
99 }
100}