1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
use crate::{Actor, ActorBox, Vertex}; use glib::{object::IsA, translate::*}; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PaintVolume(Boxed<ffi::ClutterPaintVolume>); match fn { copy => |ptr| ffi::clutter_paint_volume_copy(mut_override(ptr)), free => |ptr| ffi::clutter_paint_volume_free(ptr), get_type => || ffi::clutter_paint_volume_get_type(), } } impl PaintVolume { /// Retrieves the depth of the volume's, axis aligned, bounding box. /// /// In other words; this takes into account what actor's coordinate /// space `self` belongs too and conceptually fits an axis aligned box /// around the volume. It returns the size of that bounding box as /// measured along the z-axis. /// /// If, for example, `ActorExt::get_transformed_paint_volume` /// is used to transform a 2D child actor that is 100px wide, 100px /// high and 0px deep into container coordinates then the depth might /// not simply be 0px if the child actor has a 3D rotation applied to /// it. /// /// Remember: if `ActorExt::get_transformed_paint_volume` is /// used then the transformed volume will be defined relative to the /// container actor and in container coordinates a 2D child actor /// can have a 3D bounding volume. /// /// There are no accuracy guarantees for the reported depth, /// except that it must always be greater than, or equal to, the actor's /// depth. This is because actors may report simple, loose fitting paint /// volumes for efficiency. /// /// # Returns /// /// the depth, in units of `self`'s local coordinate system. pub fn get_depth(&self) -> f32 { unsafe { ffi::clutter_paint_volume_get_depth(self.to_glib_none().0) } } /// Retrieves the height of the volume's, axis aligned, bounding box. /// /// In other words; this takes into account what actor's coordinate /// space `self` belongs too and conceptually fits an axis aligned box /// around the volume. It returns the size of that bounding box as /// measured along the y-axis. /// /// If, for example, `ActorExt::get_transformed_paint_volume` /// is used to transform a 2D child actor that is 100px wide, 100px /// high and 0px deep into container coordinates then the height might /// not simply be 100px if the child actor has a 3D rotation applied to /// it. /// /// Remember: if `ActorExt::get_transformed_paint_volume` is /// used then a transformed child volume will be defined relative to the /// ancestor container actor and so a 2D child actor /// can have a 3D bounding volume. /// /// There are no accuracy guarantees for the reported height, /// except that it must always be greater than, or equal to, the actor's /// height. This is because actors may report simple, loose fitting paint /// volumes for efficiency. /// /// # Returns /// /// the height, in units of `self`'s local coordinate system. pub fn get_height(&self) -> f32 { unsafe { ffi::clutter_paint_volume_get_height(self.to_glib_none().0) } } /// Retrieves the origin of the `PaintVolume`. /// ## `vertex` /// the return location for a `Vertex` pub fn get_origin(&self) -> Vertex { unsafe { let mut vertex = Vertex::uninitialized(); ffi::clutter_paint_volume_get_origin( self.to_glib_none().0, vertex.to_glib_none_mut().0, ); vertex } } /// Retrieves the width of the volume's, axis aligned, bounding box. /// /// In other words; this takes into account what actor's coordinate /// space `self` belongs too and conceptually fits an axis aligned box /// around the volume. It returns the size of that bounding box as /// measured along the x-axis. /// /// If, for example, `ActorExt::get_transformed_paint_volume` /// is used to transform a 2D child actor that is 100px wide, 100px /// high and 0px deep into container coordinates then the width might /// not simply be 100px if the child actor has a 3D rotation applied to /// it. /// /// Remember: if `ActorExt::get_transformed_paint_volume` is /// used then a transformed child volume will be defined relative to the /// ancestor container actor and so a 2D child actor can have a 3D /// bounding volume. /// /// There are no accuracy guarantees for the reported width, /// except that it must always be greater than, or equal to, the /// actor's width. This is because actors may report simple, loose /// fitting paint volumes for efficiency. /// /// # Returns /// /// the width, in units of `self`'s local coordinate system. pub fn get_width(&self) -> f32 { unsafe { ffi::clutter_paint_volume_get_width(self.to_glib_none().0) } } /// Sets the depth of the paint volume. The depth is measured along /// the z axis in the actor coordinates that `self` is associated with. /// ## `depth` /// the depth of the paint volume, in pixels pub fn set_depth(&mut self, depth: f32) { unsafe { ffi::clutter_paint_volume_set_depth(self.to_glib_none_mut().0, depth); } } /// Sets the `PaintVolume` from the allocation of `actor`. /// /// This function should be used when overriding the /// `ActorClass.get_paint_volume`() by `Actor` sub-classes /// that do not paint outside their allocation. /// /// A typical example is: /// /// /// ```text /// static gboolean /// my_actor_get_paint_volume (Actor *self, /// PaintVolume *volume) /// { /// return paint_volume_set_from_allocation (volume, self); /// } /// ``` /// ## `actor` /// a `Actor` /// /// # Returns /// /// `true` if the paint volume was successfully set, and `false` /// otherwise pub fn set_from_allocation<P: IsA<Actor>>(&mut self, actor: &P) -> bool { unsafe { from_glib(ffi::clutter_paint_volume_set_from_allocation( self.to_glib_none_mut().0, actor.as_ref().to_glib_none().0, )) } } /// Sets the height of the paint volume. The height is measured along /// the y axis in the actor coordinates that `self` is associated with. /// ## `height` /// the height of the paint volume, in pixels pub fn set_height(&mut self, height: f32) { unsafe { ffi::clutter_paint_volume_set_height(self.to_glib_none_mut().0, height); } } /// Sets the origin of the paint volume. /// /// The origin is defined as the X, Y and Z coordinates of the top-left /// corner of an actor's paint volume, in actor coordinates. /// /// The default is origin is assumed at: (0, 0, 0) /// ## `origin` /// a `Vertex` pub fn set_origin(&mut self, origin: &Vertex) { unsafe { ffi::clutter_paint_volume_set_origin( self.to_glib_none_mut().0, origin.to_glib_none().0, ); } } /// Sets the width of the paint volume. The width is measured along /// the x axis in the actor coordinates that `self` is associated with. /// ## `width` /// the width of the paint volume, in pixels pub fn set_width(&mut self, width: f32) { unsafe { ffi::clutter_paint_volume_set_width(self.to_glib_none_mut().0, width); } } /// Updates the geometry of `self` to encompass `self` and `another_pv`. /// /// There are no guarantees about how precisely the two volumes /// will be unioned. /// ## `another_pv` /// A second `PaintVolume` to union with `self` pub fn union(&mut self, another_pv: &PaintVolume) { unsafe { ffi::clutter_paint_volume_union(self.to_glib_none_mut().0, another_pv.to_glib_none().0); } } /// Unions the 2D region represented by `box_` to a `PaintVolume`. /// /// This function is similar to `PaintVolume::union`, but it is /// specific for 2D regions. /// ## `box_` /// a `ActorBox` to union to `self` pub fn union_box(&mut self, box_: &ActorBox) { unsafe { ffi::clutter_paint_volume_union_box(self.to_glib_none_mut().0, box_.to_glib_none().0); } } }