gdk4/
surface.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, prelude::*, Surface};
6
7// rustdoc-stripper-ignore-next
8/// Trait containing manually implemented methods of
9/// [`Surface`](crate::Surface).
10pub trait SurfaceExtManual: IsA<Surface> + 'static {
11    #[doc(alias = "gdk_surface_create_similar_surface")]
12    fn create_similar_surface(
13        &self,
14        content: cairo::Content,
15        width: i32,
16        height: i32,
17    ) -> cairo::Surface {
18        unsafe {
19            from_glib_full(ffi::gdk_surface_create_similar_surface(
20                self.as_ref().to_glib_none().0,
21                content.into(),
22                width,
23                height,
24            ))
25        }
26    }
27
28    // Returns true if the coordinates were successfully translated
29    #[doc(alias = "gdk_surface_translate_coordinates")]
30    fn translate_coordinates(&self, to: &Surface, mut x: f64, mut y: f64) -> bool {
31        unsafe {
32            from_glib(ffi::gdk_surface_translate_coordinates(
33                self.as_ref().to_glib_none().0,
34                to.to_glib_none().0,
35                &mut x,
36                &mut y,
37            ))
38        }
39    }
40}
41
42impl<O: IsA<Surface>> SurfaceExtManual for O {}