Skip to content

Commit a495b1f

Browse files
gsk: Generate PathIntersection
1 parent 5056476 commit a495b1f

File tree

4 files changed

+169
-6
lines changed

4 files changed

+169
-6
lines changed

gsk4/Gir.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ generate = [
3838
"Gsk.OutsetShadowNode",
3939
"Gsk.PathDirection",
4040
"Gsk.PathForeachFlags",
41+
"Gsk.PathIntersection",
4142
"Gsk.PathMeasure",
4243
"Gsk.PathOperation",
4344
"Gsk.RadialGradientNode",

gsk4/src/auto/enums.rs

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,128 @@ impl From<PathDirection> for glib::Value {
982982
}
983983
}
984984

985+
#[cfg(feature = "v4_20")]
986+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
987+
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
988+
#[non_exhaustive]
989+
#[doc(alias = "GskPathIntersection")]
990+
pub enum PathIntersection {
991+
#[doc(alias = "GSK_PATH_INTERSECTION_NONE")]
992+
None,
993+
#[doc(alias = "GSK_PATH_INTERSECTION_NORMAL")]
994+
Normal,
995+
#[doc(alias = "GSK_PATH_INTERSECTION_START")]
996+
Start,
997+
#[doc(alias = "GSK_PATH_INTERSECTION_END")]
998+
End,
999+
#[doc(hidden)]
1000+
__Unknown(i32),
1001+
}
1002+
1003+
#[cfg(feature = "v4_20")]
1004+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1005+
#[doc(hidden)]
1006+
impl IntoGlib for PathIntersection {
1007+
type GlibType = ffi::GskPathIntersection;
1008+
1009+
#[inline]
1010+
fn into_glib(self) -> ffi::GskPathIntersection {
1011+
match self {
1012+
Self::None => ffi::GSK_PATH_INTERSECTION_NONE,
1013+
Self::Normal => ffi::GSK_PATH_INTERSECTION_NORMAL,
1014+
Self::Start => ffi::GSK_PATH_INTERSECTION_START,
1015+
Self::End => ffi::GSK_PATH_INTERSECTION_END,
1016+
Self::__Unknown(value) => value,
1017+
}
1018+
}
1019+
}
1020+
1021+
#[cfg(feature = "v4_20")]
1022+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1023+
#[doc(hidden)]
1024+
impl FromGlib<ffi::GskPathIntersection> for PathIntersection {
1025+
#[inline]
1026+
unsafe fn from_glib(value: ffi::GskPathIntersection) -> Self {
1027+
skip_assert_initialized!();
1028+
1029+
match value {
1030+
ffi::GSK_PATH_INTERSECTION_NONE => Self::None,
1031+
ffi::GSK_PATH_INTERSECTION_NORMAL => Self::Normal,
1032+
ffi::GSK_PATH_INTERSECTION_START => Self::Start,
1033+
ffi::GSK_PATH_INTERSECTION_END => Self::End,
1034+
value => Self::__Unknown(value),
1035+
}
1036+
}
1037+
}
1038+
1039+
#[cfg(feature = "v4_20")]
1040+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1041+
impl StaticType for PathIntersection {
1042+
#[inline]
1043+
#[doc(alias = "gsk_path_intersection_get_type")]
1044+
fn static_type() -> glib::Type {
1045+
unsafe { from_glib(ffi::gsk_path_intersection_get_type()) }
1046+
}
1047+
}
1048+
1049+
#[cfg(feature = "v4_20")]
1050+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1051+
impl glib::HasParamSpec for PathIntersection {
1052+
type ParamSpec = glib::ParamSpecEnum;
1053+
type SetValue = Self;
1054+
type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
1055+
1056+
fn param_spec_builder() -> Self::BuilderFn {
1057+
Self::ParamSpec::builder_with_default
1058+
}
1059+
}
1060+
1061+
#[cfg(feature = "v4_20")]
1062+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1063+
impl glib::value::ValueType for PathIntersection {
1064+
type Type = Self;
1065+
}
1066+
1067+
#[cfg(feature = "v4_20")]
1068+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1069+
unsafe impl<'a> glib::value::FromValue<'a> for PathIntersection {
1070+
type Checker = glib::value::GenericValueTypeChecker<Self>;
1071+
1072+
#[inline]
1073+
unsafe fn from_value(value: &'a glib::Value) -> Self {
1074+
skip_assert_initialized!();
1075+
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
1076+
}
1077+
}
1078+
1079+
#[cfg(feature = "v4_20")]
1080+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1081+
impl ToValue for PathIntersection {
1082+
#[inline]
1083+
fn to_value(&self) -> glib::Value {
1084+
let mut value = glib::Value::for_value_type::<Self>();
1085+
unsafe {
1086+
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
1087+
}
1088+
value
1089+
}
1090+
1091+
#[inline]
1092+
fn value_type(&self) -> glib::Type {
1093+
Self::static_type()
1094+
}
1095+
}
1096+
1097+
#[cfg(feature = "v4_20")]
1098+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1099+
impl From<PathIntersection> for glib::Value {
1100+
#[inline]
1101+
fn from(v: PathIntersection) -> Self {
1102+
skip_assert_initialized!();
1103+
ToValue::to_value(&v)
1104+
}
1105+
}
1106+
9851107
#[cfg(feature = "v4_14")]
9861108
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
9871109
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]

gsk4/src/auto/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ pub use self::enums::MaskMode;
201201
#[cfg(feature = "v4_14")]
202202
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
203203
pub use self::enums::PathDirection;
204+
#[cfg(feature = "v4_20")]
205+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
206+
pub use self::enums::PathIntersection;
204207
#[cfg(feature = "v4_14")]
205208
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
206209
pub use self::enums::PathOperation;

gsk4/src/auto/path.rs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

5+
#[cfg(feature = "v4_20")]
6+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
7+
use crate::PathIntersection;
58
use crate::{ffi, FillRule, PathPoint, Stroke};
69
use glib::translate::*;
710

@@ -17,12 +20,46 @@ glib::wrapper! {
1720
}
1821

1922
impl Path {
20-
//#[cfg(feature = "v4_20")]
21-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
22-
//#[doc(alias = "gsk_path_foreach_intersection")]
23-
//pub fn foreach_intersection(&self, path2: Option<&Path>, func: /*Unimplemented*/FnMut(&Path, &PathPoint, &Path, &PathPoint, /*Ignored*/PathIntersection) -> bool, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> bool {
24-
// unsafe { TODO: call ffi:gsk_path_foreach_intersection() }
25-
//}
23+
#[cfg(feature = "v4_20")]
24+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
25+
#[doc(alias = "gsk_path_foreach_intersection")]
26+
pub fn foreach_intersection<
27+
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, &PathIntersection) -> bool,
28+
>(
29+
&self,
30+
path2: Option<&Path>,
31+
func: P,
32+
) -> bool {
33+
let mut func_data: P = func;
34+
unsafe extern "C" fn func_func<
35+
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, &PathIntersection) -> bool,
36+
>(
37+
path1: *mut ffi::GskPath,
38+
point1: *const ffi::GskPathPoint,
39+
path2: *mut ffi::GskPath,
40+
point2: *const ffi::GskPathPoint,
41+
kind: ffi::GskPathIntersection,
42+
user_data: glib::ffi::gpointer,
43+
) -> glib::ffi::gboolean {
44+
let path1 = from_glib_borrow(path1);
45+
let point1 = from_glib_borrow(point1);
46+
let path2 = from_glib_borrow(path2);
47+
let point2 = from_glib_borrow(point2);
48+
let kind = from_glib_borrow(kind);
49+
let callback = user_data as *mut P;
50+
(*callback)(&path1, &point1, &path2, &point2, &kind).into_glib()
51+
}
52+
let func = Some(func_func::<P> as _);
53+
let super_callback0: &mut P = &mut func_data;
54+
unsafe {
55+
from_glib(ffi::gsk_path_foreach_intersection(
56+
self.to_glib_none().0,
57+
path2.to_glib_none().0,
58+
func,
59+
super_callback0 as *mut _ as *mut _,
60+
))
61+
}
62+
}
2663

2764
#[doc(alias = "gsk_path_get_bounds")]
2865
#[doc(alias = "get_bounds")]

0 commit comments

Comments
 (0)