1use std::borrow::Borrow;
4
5use glib::translate::*;
6
7use crate::{ffi, prelude::*, Snapshot};
8
9mod sealed {
10 pub trait Sealed {}
11 impl<T: super::IsA<super::Snapshot>> Sealed for T {}
12}
13
14pub trait SnapshotExtManual: sealed::Sealed + IsA<Snapshot> + 'static {
15 #[doc(alias = "gtk_snapshot_append_border")]
27 fn append_border(
28 &self,
29 outline: &gsk::RoundedRect,
30 border_width: &[f32; 4],
31 border_color: &[gdk::RGBA; 4],
32 ) {
33 unsafe {
34 let border_color_ptr: Vec<gdk::ffi::GdkRGBA> =
35 border_color.iter().map(|c| *c.to_glib_none().0).collect();
36 ffi::gtk_snapshot_append_border(
37 self.as_ref().to_glib_none().0,
38 outline.to_glib_none().0,
39 border_width,
40 border_color_ptr.as_ptr() as *const _,
41 )
42 }
43 }
44
45 #[doc(alias = "gtk_snapshot_push_debug")]
53 fn push_debug(&self, message: impl IntoGStr) {
54 unsafe {
55 message.run_with_gstr(|message| {
56 ffi::gtk_snapshot_push_debug(self.as_ref().to_glib_none().0, message.as_ptr())
57 })
58 }
59 }
60}
61
62impl<O: IsA<Snapshot>> SnapshotExtManual for O {}
63
64impl AsRef<Snapshot> for gdk::Snapshot {
65 #[inline]
66 fn as_ref(&self) -> &Snapshot {
67 self.downcast_ref().unwrap()
68 }
69}
70
71impl From<gdk::Snapshot> for Snapshot {
72 #[inline]
73 fn from(e: gdk::Snapshot) -> Snapshot {
74 assert_initialized_main_thread!();
75 e.downcast().unwrap()
76 }
77}
78
79impl Borrow<Snapshot> for gdk::Snapshot {
80 #[inline]
81 fn borrow(&self) -> &Snapshot {
82 self.downcast_ref().unwrap()
83 }
84}
85
86unsafe impl IsA<Snapshot> for gdk::Snapshot {}