gdk4/
draw_context.rs

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
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::translate::*;

use crate::{prelude::*, DrawContext};

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::DrawContext>> Sealed for T {}
}

// rustdoc-stripper-ignore-next
/// Trait containing manually implemented methods of
/// [`DrawContext`](crate::DrawContext).
pub trait DrawContextExtManual: sealed::Sealed + IsA<DrawContext> + 'static {
    /// Retrieves the region that is currently being repainted.
    ///
    /// After a call to [`DrawContextExt::begin_frame()`][crate::prelude::DrawContextExt::begin_frame()] this function will
    /// return a union of the region passed to that function and the area of the
    /// surface that the @self determined needs to be repainted.
    ///
    /// If @self is not in between calls to [`DrawContextExt::begin_frame()`][crate::prelude::DrawContextExt::begin_frame()]
    /// and [`DrawContextExt::end_frame()`][crate::prelude::DrawContextExt::end_frame()], [`None`] will be returned.
    ///
    /// # Deprecated since 4.16
    ///
    /// Drawing directly to the surface is no longer recommended.
    ///   Use `GskRenderNode` and `GskRenderer`.
    ///
    /// # Returns
    ///
    /// a Cairo region
    #[doc(alias = "gdk_draw_context_get_frame_region")]
    #[doc(alias = "get_frame_region")]
    fn frame_region(&self) -> Option<cairo::Region> {
        unsafe {
            from_glib_none(crate::ffi::gdk_draw_context_get_frame_region(
                self.as_ref().to_glib_none().0,
            ) as *mut cairo::ffi::cairo_region_t)
        }
    }
}

impl<O: IsA<DrawContext>> DrawContextExtManual for O {}