animate/legacy/paint_node.rs
1use 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
13/// Trait containing all `PaintNode` methods.
14///
15/// # Implementors
16///
17/// [`ClipNode`](struct.ClipNode.html), [`PaintNode`](struct.PaintNode.html), [`PipelineNode`](struct.PipelineNode.html), [`TextNode`](struct.TextNode.html)
18pub trait PaintNodeExt: 'static {
19 /// Adds `child` to the list of children of `self`.
20 ///
21 /// This function will acquire a reference on `child`.
22 /// ## `child`
23 /// the child `PaintNode` to add
24 fn add_child<P: IsA<PaintNode>>(&self, child: &P);
25
26 /// Adds a rectangle region to the `self`, as described by the
27 /// passed `rect`.
28 /// ## `rect`
29 /// a `ActorBox`
30 fn add_rectangle(&self, rect: &ActorBox);
31
32 /// Adds a rectangle region to the `self`, with texture coordinates.
33 /// ## `rect`
34 /// a `ActorBox`
35 /// ## `x_1`
36 /// the left X coordinate of the texture
37 /// ## `y_1`
38 /// the top Y coordinate of the texture
39 /// ## `x_2`
40 /// the right X coordinate of the texture
41 /// ## `y_2`
42 /// the bottom Y coordinate of the texture
43 fn add_texture_rectangle(&self, rect: &ActorBox, x_1: f32, y_1: f32, x_2: f32, y_2: f32);
44
45 /// Sets a user-readable `name` for `self`.
46 ///
47 /// The `name` will be used for debugging purposes.
48 ///
49 /// The `self` will copy the passed string.
50 /// ## `name`
51 /// a string annotating the `self`
52 fn set_name(&self, name: &str);
53}
54
55impl<O: IsA<PaintNode>> PaintNodeExt for O {
56 fn add_child<P: IsA<PaintNode>>(&self, child: &P) {
57 unsafe {
58 ffi::clutter_paint_node_add_child(
59 self.as_ref().to_glib_none().0,
60 child.as_ref().to_glib_none().0,
61 );
62 }
63 }
64
65 fn add_rectangle(&self, rect: &ActorBox) {
66 unsafe {
67 ffi::clutter_paint_node_add_rectangle(
68 self.as_ref().to_glib_none().0,
69 rect.to_glib_none().0,
70 );
71 }
72 }
73
74 fn add_texture_rectangle(&self, rect: &ActorBox, x_1: f32, y_1: f32, x_2: f32, y_2: f32) {
75 unsafe {
76 ffi::clutter_paint_node_add_texture_rectangle(
77 self.as_ref().to_glib_none().0,
78 rect.to_glib_none().0,
79 x_1,
80 y_1,
81 x_2,
82 y_2,
83 );
84 }
85 }
86
87 fn set_name(&self, name: &str) {
88 unsafe {
89 ffi::clutter_paint_node_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
90 }
91 }
92}
93
94impl fmt::Display for PaintNode {
95 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
96 write!(f, "PaintNode")
97 }
98}