gdk4/draw_context.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::{prelude::*, DrawContext};
6
7mod sealed {
8 pub trait Sealed {}
9 impl<T: super::IsA<super::DrawContext>> Sealed for T {}
10}
11
12// rustdoc-stripper-ignore-next
13/// Trait containing manually implemented methods of
14/// [`DrawContext`](crate::DrawContext).
15pub trait DrawContextExtManual: sealed::Sealed + IsA<DrawContext> + 'static {
16 /// Retrieves the region that is currently being repainted.
17 ///
18 /// After a call to [`DrawContextExt::begin_frame()`][crate::prelude::DrawContextExt::begin_frame()] this function will
19 /// return a union of the region passed to that function and the area of the
20 /// surface that the @self determined needs to be repainted.
21 ///
22 /// If @self is not in between calls to [`DrawContextExt::begin_frame()`][crate::prelude::DrawContextExt::begin_frame()]
23 /// and [`DrawContextExt::end_frame()`][crate::prelude::DrawContextExt::end_frame()], [`None`] will be returned.
24 ///
25 /// # Deprecated since 4.16
26 ///
27 /// Drawing directly to the surface is no longer recommended.
28 /// Use `GskRenderNode` and `GskRenderer`.
29 ///
30 /// # Returns
31 ///
32 /// a Cairo region
33 #[doc(alias = "gdk_draw_context_get_frame_region")]
34 #[doc(alias = "get_frame_region")]
35 fn frame_region(&self) -> Option<cairo::Region> {
36 unsafe {
37 from_glib_none(crate::ffi::gdk_draw_context_get_frame_region(
38 self.as_ref().to_glib_none().0,
39 ) as *mut cairo::ffi::cairo_region_t)
40 }
41 }
42}
43
44impl<O: IsA<DrawContext>> DrawContextExtManual for O {}