diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d6ec23465ee7..b9bd2cbb24d8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -24,7 +24,7 @@ jobs: - { name: "gdk-pixbuf", features: "v2_42", nightly: "--all-features", test_sys: true } - { name: "gio", features: "v2_84", nightly: "--all-features", test_sys: true } - { name: "glib", features: "v2_84,log", nightly: "--all-features", test_sys: true } - - { name: "graphene", features: "", nightly: "", test_sys: true } + - { name: "graphene", features: "v1_12", nightly: "", test_sys: true } - { name: "pango", features: "v1_56", nightly: "--all-features", test_sys: true } - { name: "pangocairo", features: "", nightly: "--all-features", test_sys: true } steps: diff --git a/gdk-pixbuf/src/auto/versions.txt b/gdk-pixbuf/src/auto/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/gdk-pixbuf/src/auto/versions.txt +++ b/gdk-pixbuf/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/gdk-pixbuf/sys/versions.txt b/gdk-pixbuf/sys/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/gdk-pixbuf/sys/versions.txt +++ b/gdk-pixbuf/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/gio/src/auto/versions.txt b/gio/src/auto/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/gio/src/auto/versions.txt +++ b/gio/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/gio/src/auto/zlib_compressor.rs b/gio/src/auto/zlib_compressor.rs index ebac20abd7f5..f4e722c8850e 100644 --- a/gio/src/auto/zlib_compressor.rs +++ b/gio/src/auto/zlib_compressor.rs @@ -32,6 +32,14 @@ impl ZlibCompressor { unsafe { from_glib_none(ffi::g_zlib_compressor_get_file_info(self.to_glib_none().0)) } } + #[cfg(feature = "v2_86")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))] + #[doc(alias = "g_zlib_compressor_get_os")] + #[doc(alias = "get_os")] + pub fn os(&self) -> i32 { + unsafe { ffi::g_zlib_compressor_get_os(self.to_glib_none().0) } + } + #[doc(alias = "g_zlib_compressor_set_file_info")] #[doc(alias = "file-info")] pub fn set_file_info(&self, file_info: Option<&FileInfo>) { @@ -40,6 +48,16 @@ impl ZlibCompressor { } } + #[cfg(feature = "v2_86")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))] + #[doc(alias = "g_zlib_compressor_set_os")] + #[doc(alias = "os")] + pub fn set_os(&self, os: i32) { + unsafe { + ffi::g_zlib_compressor_set_os(self.to_glib_none().0, os); + } + } + pub fn format(&self) -> ZlibCompressorFormat { ObjectExt::property(self, "format") } @@ -70,4 +88,29 @@ impl ZlibCompressor { ) } } + + #[cfg(feature = "v2_86")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))] + #[doc(alias = "os")] + pub fn connect_os_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_os_trampoline( + this: *mut ffi::GZlibCompressor, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"notify::os".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_os_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } } diff --git a/gio/sys/src/lib.rs b/gio/sys/src/lib.rs index 34ca7b92631a..9a7cf7a10660 100644 --- a/gio/sys/src/lib.rs +++ b/gio/sys/src/lib.rs @@ -15040,10 +15040,16 @@ extern "C" { level: c_int, ) -> *mut GZlibCompressor; pub fn g_zlib_compressor_get_file_info(compressor: *mut GZlibCompressor) -> *mut GFileInfo; + #[cfg(feature = "v2_86")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))] + pub fn g_zlib_compressor_get_os(compressor: *mut GZlibCompressor) -> c_int; pub fn g_zlib_compressor_set_file_info( compressor: *mut GZlibCompressor, file_info: *mut GFileInfo, ); + #[cfg(feature = "v2_86")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))] + pub fn g_zlib_compressor_set_os(compressor: *mut GZlibCompressor, os: c_int); //========================================================================= // GZlibDecompressor diff --git a/gio/sys/versions.txt b/gio/sys/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/gio/sys/versions.txt +++ b/gio/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/gir b/gir index 19e8a2f15e0e..b2a1c6f9b362 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit 19e8a2f15e0eb97563cbee857846b2d57506ec7d +Subproject commit b2a1c6f9b3622c45e67af75479eaf640a8af0081 diff --git a/gir-files b/gir-files index be4559caec2b..5262e0fefdc7 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit be4559caec2b8c8a7ad098669486da174838c796 +Subproject commit 5262e0fefdc77120e81e62fe32257a84f11a64bf diff --git a/glib/Gir.toml b/glib/Gir.toml index 2c32f533b932..f9bdbd0e8a0c 100644 --- a/glib/Gir.toml +++ b/glib/Gir.toml @@ -837,6 +837,17 @@ concurrency = "send+sync" # parameter type ignore = true + [[object.function]] + name = "dup_context" + # implemented as the normal getter + manual = true + + [[object.function]] + name = "get_context" + # implemented conditionally around this or + # dup_context() (see above) + manual = true + [[object]] name = "GLib.ThreadPool" status = "manual" diff --git a/glib/gobject-sys/versions.txt b/glib/gobject-sys/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/glib/gobject-sys/versions.txt +++ b/glib/gobject-sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/glib/src/auto/source.rs b/glib/src/auto/source.rs index 62b8f64ab57c..0be5459ff079 100644 --- a/glib/src/auto/source.rs +++ b/glib/src/auto/source.rs @@ -2,7 +2,7 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use crate::{ffi, translate::*, MainContext}; +use crate::{ffi, translate::*}; crate::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -51,12 +51,6 @@ impl Source { unsafe { from_glib(ffi::g_source_get_can_recurse(self.to_glib_none().0)) } } - #[doc(alias = "g_source_get_context")] - #[doc(alias = "get_context")] - pub fn context(&self) -> Option { - unsafe { from_glib_none(ffi::g_source_get_context(self.to_glib_none().0)) } - } - #[doc(alias = "g_source_get_name")] #[doc(alias = "get_name")] pub fn name(&self) -> Option { diff --git a/glib/src/auto/versions.txt b/glib/src/auto/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/glib/src/auto/versions.txt +++ b/glib/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/glib/src/source.rs b/glib/src/source.rs index 45adfb38340c..b7702fa8d45a 100644 --- a/glib/src/source.rs +++ b/glib/src/source.rs @@ -1270,4 +1270,18 @@ impl Source { )) } } + + #[doc(alias = "g_source_get_context")] + #[doc(alias = "get_context")] + #[doc(alias = "g_source_dup_context")] + pub fn context(&self) -> Option { + #[cfg(feature = "v2_86")] + unsafe { + from_glib_full(ffi::g_source_dup_context(self.to_glib_none().0)) + } + #[cfg(not(feature = "v2_86"))] + unsafe { + from_glib_none(ffi::g_source_get_context(self.to_glib_none().0)) + } + } } diff --git a/glib/sys/src/lib.rs b/glib/sys/src/lib.rs index 2bf7a9b665f5..4cf6c049fa71 100644 --- a/glib/sys/src/lib.rs +++ b/glib/sys/src/lib.rs @@ -5147,6 +5147,9 @@ extern "C" { pub fn g_source_add_unix_fd(source: *mut GSource, fd: c_int, events: GIOCondition) -> gpointer; pub fn g_source_attach(source: *mut GSource, context: *mut GMainContext) -> c_uint; pub fn g_source_destroy(source: *mut GSource); + #[cfg(feature = "v2_86")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))] + pub fn g_source_dup_context(source: *mut GSource) -> *mut GMainContext; pub fn g_source_get_can_recurse(source: *mut GSource) -> gboolean; pub fn g_source_get_context(source: *mut GSource) -> *mut GMainContext; pub fn g_source_get_current_time(source: *mut GSource, timeval: *mut GTimeVal); diff --git a/glib/sys/versions.txt b/glib/sys/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/glib/sys/versions.txt +++ b/glib/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/graphene/Cargo.toml b/graphene/Cargo.toml index 23aa26b6ba42..a44d2024a35f 100644 --- a/graphene/Cargo.toml +++ b/graphene/Cargo.toml @@ -17,6 +17,7 @@ version.workspace = true name = "graphene" [features] +v1_12 = ["graphene-sys/v1_12"] [dependencies] graphene-sys.workspace = true diff --git a/graphene/Gir.toml b/graphene/Gir.toml index 3d4a793f412b..348249edf9f1 100644 --- a/graphene/Gir.toml +++ b/graphene/Gir.toml @@ -54,6 +54,46 @@ boxed_inline = true # float array manual = true +[[object]] +name = "Graphene.Box2D" +status = "generate" +boxed_inline = true + [[object.function]] + # contents undefined + name = "alloc" + ignore = true + [[object.function]] + name = "init_from_box" + ignore = true # Copy like constructor + [[object.function]] + name = "init" + manual = true # manual proper constructor + rename = "new" + [[object.function]] + name = "init_from_points" + manual = true # manual proper constructor + rename = "from_points" + [[object.function]] + name = "init_from_vec2" + manual = true # manual proper constructor + rename = "from_vec2" + [[object.function]] + name = "init_from_rect" + manual = true # manual proper constructor + rename = "from_rect" + [[object.function]] + name = "init_from_vectors" + manual = true # manual proper constructor + rename = "from_vectors" + [[object.function]] + name = "get_vertices" + # float array + manual = true + [[object.function]] + name = "to_float" + # float array + manual = true + [[object]] name = "Graphene.Euler" status = "generate" diff --git a/graphene/src/auto/box2_d.rs b/graphene/src/auto/box2_d.rs new file mode 100644 index 000000000000..d4df48a0ab57 --- /dev/null +++ b/graphene/src/auto/box2_d.rs @@ -0,0 +1,252 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, Point, Rect, Vec2}; +use glib::translate::*; + +glib::wrapper! { + pub struct Box2D(BoxedInline); + + match fn { + copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_box2d_get_type(), ptr as *mut _) as *mut ffi::graphene_box2d_t, + free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_box2d_get_type(), ptr as *mut _), + type_ => || ffi::graphene_box2d_get_type(), + } +} + +impl Box2D { + #[doc(alias = "graphene_box2d_contains_box")] + pub fn contains_box(&self, b: &Box2D) -> bool { + unsafe { ffi::graphene_box2d_contains_box(self.to_glib_none().0, b.to_glib_none().0) } + } + + #[doc(alias = "graphene_box2d_contains_point")] + pub fn contains_point(&self, point: &Point) -> bool { + unsafe { ffi::graphene_box2d_contains_point(self.to_glib_none().0, point.to_glib_none().0) } + } + + #[doc(alias = "graphene_box2d_contains_rect")] + pub fn contains_rect(&self, rect: &Rect) -> bool { + unsafe { ffi::graphene_box2d_contains_rect(self.to_glib_none().0, rect.to_glib_none().0) } + } + + #[doc(alias = "graphene_box2d_equal")] + fn equal(&self, b: &Box2D) -> bool { + unsafe { ffi::graphene_box2d_equal(self.to_glib_none().0, b.to_glib_none().0) } + } + + #[doc(alias = "graphene_box2d_expand")] + #[must_use] + pub fn expand(&self, point: &Point) -> Box2D { + unsafe { + let mut res = Box2D::uninitialized(); + ffi::graphene_box2d_expand( + self.to_glib_none().0, + point.to_glib_none().0, + res.to_glib_none_mut().0, + ); + res + } + } + + #[doc(alias = "graphene_box2d_expand_scalar")] + #[must_use] + pub fn expand_scalar(&self, scalar: f32) -> Box2D { + unsafe { + let mut res = Box2D::uninitialized(); + ffi::graphene_box2d_expand_scalar( + self.to_glib_none().0, + scalar, + res.to_glib_none_mut().0, + ); + res + } + } + + #[doc(alias = "graphene_box2d_expand_vec2")] + #[must_use] + pub fn expand_vec2(&self, vec: &Vec2) -> Box2D { + unsafe { + let mut res = Box2D::uninitialized(); + ffi::graphene_box2d_expand_vec2( + self.to_glib_none().0, + vec.to_glib_none().0, + res.to_glib_none_mut().0, + ); + res + } + } + + #[doc(alias = "graphene_box2d_get_center")] + #[doc(alias = "get_center")] + pub fn center(&self) -> Point { + unsafe { + let mut center = Point::uninitialized(); + ffi::graphene_box2d_get_center(self.to_glib_none().0, center.to_glib_none_mut().0); + center + } + } + + #[doc(alias = "graphene_box2d_get_height")] + #[doc(alias = "get_height")] + pub fn height(&self) -> f32 { + unsafe { ffi::graphene_box2d_get_height(self.to_glib_none().0) } + } + + #[doc(alias = "graphene_box2d_get_max")] + #[doc(alias = "get_max")] + pub fn max(&self) -> Point { + unsafe { + let mut max = Point::uninitialized(); + ffi::graphene_box2d_get_max(self.to_glib_none().0, max.to_glib_none_mut().0); + max + } + } + + #[doc(alias = "graphene_box2d_get_min")] + #[doc(alias = "get_min")] + pub fn min(&self) -> Point { + unsafe { + let mut min = Point::uninitialized(); + ffi::graphene_box2d_get_min(self.to_glib_none().0, min.to_glib_none_mut().0); + min + } + } + + #[doc(alias = "graphene_box2d_get_minmax")] + #[doc(alias = "get_minmax")] + pub fn minmax(&self) -> (Point, Point) { + unsafe { + let mut min = Point::uninitialized(); + let mut max = Point::uninitialized(); + ffi::graphene_box2d_get_minmax( + self.to_glib_none().0, + min.to_glib_none_mut().0, + max.to_glib_none_mut().0, + ); + (min, max) + } + } + + #[doc(alias = "graphene_box2d_get_size")] + #[doc(alias = "get_size")] + pub fn size(&self) -> Vec2 { + unsafe { + let mut size = Vec2::uninitialized(); + ffi::graphene_box2d_get_size(self.to_glib_none().0, size.to_glib_none_mut().0); + size + } + } + + #[doc(alias = "graphene_box2d_get_width")] + #[doc(alias = "get_width")] + pub fn width(&self) -> f32 { + unsafe { ffi::graphene_box2d_get_width(self.to_glib_none().0) } + } + + #[doc(alias = "graphene_box2d_intersection")] + pub fn intersection(&self, b: &Box2D) -> Option { + unsafe { + let mut res = Box2D::uninitialized(); + let ret = ffi::graphene_box2d_intersection( + self.to_glib_none().0, + b.to_glib_none().0, + res.to_glib_none_mut().0, + ); + if ret { + Some(res) + } else { + None + } + } + } + + #[doc(alias = "graphene_box2d_intersects")] + pub fn intersects(&self, b: &Box2D) -> bool { + unsafe { ffi::graphene_box2d_intersects(self.to_glib_none().0, b.to_glib_none().0) } + } + + #[doc(alias = "graphene_box2d_scale_offset")] + #[must_use] + pub fn scale_offset(&self, scale: Option<&Vec2>, offset: Option<&Point>) -> Box2D { + unsafe { + let mut res = Box2D::uninitialized(); + ffi::graphene_box2d_scale_offset( + self.to_glib_none().0, + scale.to_glib_none().0, + offset.to_glib_none().0, + res.to_glib_none_mut().0, + ); + res + } + } + + #[doc(alias = "graphene_box2d_to_rect")] + pub fn to_rect(&self) -> Rect { + unsafe { + let mut rect = Rect::uninitialized(); + ffi::graphene_box2d_to_rect(self.to_glib_none().0, rect.to_glib_none_mut().0); + rect + } + } + + #[doc(alias = "graphene_box2d_union")] + #[must_use] + pub fn union(&self, b: &Box2D) -> Box2D { + unsafe { + let mut res = Box2D::uninitialized(); + ffi::graphene_box2d_union( + self.to_glib_none().0, + b.to_glib_none().0, + res.to_glib_none_mut().0, + ); + res + } + } + + #[doc(alias = "graphene_box2d_empty")] + pub fn empty() -> Box2D { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::graphene_box2d_empty()) } + } + + #[doc(alias = "graphene_box2d_infinite")] + pub fn infinite() -> Box2D { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::graphene_box2d_infinite()) } + } + + #[doc(alias = "graphene_box2d_minus_one")] + pub fn minus_one() -> Box2D { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::graphene_box2d_minus_one()) } + } + + #[doc(alias = "graphene_box2d_one")] + pub fn one() -> Box2D { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::graphene_box2d_one()) } + } + + #[doc(alias = "graphene_box2d_one_minus_one")] + pub fn one_minus_one() -> Box2D { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::graphene_box2d_one_minus_one()) } + } + + #[doc(alias = "graphene_box2d_zero")] + pub fn zero() -> Box2D { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::graphene_box2d_zero()) } + } +} + +impl PartialEq for Box2D { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.equal(other) + } +} + +impl Eq for Box2D {} diff --git a/graphene/src/auto/box_.rs b/graphene/src/auto/box_.rs index dd166c992a26..0a605aaae7d5 100644 --- a/graphene/src/auto/box_.rs +++ b/graphene/src/auto/box_.rs @@ -128,6 +128,23 @@ impl Box { } } + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + #[doc(alias = "graphene_box_get_minmax")] + #[doc(alias = "get_minmax")] + pub fn minmax(&self) -> (Point3D, Point3D) { + unsafe { + let mut min = Point3D::uninitialized(); + let mut max = Point3D::uninitialized(); + ffi::graphene_box_get_minmax( + self.to_glib_none().0, + min.to_glib_none_mut().0, + max.to_glib_none_mut().0, + ); + (min, max) + } + } + #[doc(alias = "graphene_box_get_size")] #[doc(alias = "get_size")] pub fn size(&self) -> Vec3 { diff --git a/graphene/src/auto/mod.rs b/graphene/src/auto/mod.rs index 80a130dadfa9..39c0b5b0d535 100644 --- a/graphene/src/auto/mod.rs +++ b/graphene/src/auto/mod.rs @@ -5,6 +5,13 @@ mod box_; pub use self::box_::Box; +#[cfg(feature = "v1_12")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] +mod box2_d; +#[cfg(feature = "v1_12")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] +pub use self::box2_d::Box2D; + mod euler; pub use self::euler::Euler; diff --git a/graphene/src/auto/point.rs b/graphene/src/auto/point.rs index f9c3085af9f2..cf8b5c50e83d 100644 --- a/graphene/src/auto/point.rs +++ b/graphene/src/auto/point.rs @@ -31,6 +31,13 @@ impl Point { } } + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + #[doc(alias = "graphene_point_distance_squared")] + pub fn distance_squared(&self, b: &Point) -> f32 { + unsafe { ffi::graphene_point_distance_squared(self.to_glib_none().0, b.to_glib_none().0) } + } + #[doc(alias = "graphene_point_equal")] fn equal(&self, b: &Point) -> bool { unsafe { ffi::graphene_point_equal(self.to_glib_none().0, b.to_glib_none().0) } diff --git a/graphene/src/auto/versions.txt b/graphene/src/auto/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/graphene/src/auto/versions.txt +++ b/graphene/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/graphene/src/box2_d.rs b/graphene/src/box2_d.rs new file mode 100644 index 000000000000..b48b9e74a170 --- /dev/null +++ b/graphene/src/box2_d.rs @@ -0,0 +1,118 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use std::fmt; + +use glib::translate::*; + +use crate::{ffi, Box2D, Point, Rect, Vec2}; + +impl Box2D { + #[doc(alias = "graphene_box2d_get_vertices")] + #[doc(alias = "get_vertices")] + pub fn vertices(&self) -> &[Vec2; 4] { + unsafe { + let mut out: [ffi::graphene_vec2_t; 4] = std::mem::zeroed(); + ffi::graphene_box2d_get_vertices(self.to_glib_none().0, &mut out as *mut _); + &*(&out as *const [ffi::graphene_vec2_t; 4] as *const [Vec2; 4]) + } + } + + #[doc(alias = "graphene_box2d_to_float")] + pub fn to_float(&self) -> [f32; 4] { + unsafe { + let mut out = std::mem::MaybeUninit::uninit(); + ffi::graphene_box2d_to_float(self.to_glib_none().0, out.as_mut_ptr()); + out.assume_init() + } + } + + #[doc(alias = "graphene_box2d_init")] + pub fn new(min: Option<&Point>, max: Option<&Point>) -> Self { + assert_initialized_main_thread!(); + unsafe { + let mut b = Self::uninitialized(); + ffi::graphene_box2d_init( + b.to_glib_none_mut().0, + min.to_glib_none().0, + max.to_glib_none().0, + ); + b + } + } + + #[doc(alias = "graphene_box2d_init_from_points")] + #[doc(alias = "init_from_points")] + pub fn from_points(points: &[Point]) -> Self { + assert_initialized_main_thread!(); + + let n = points.len() as u32; + + unsafe { + let mut b = Self::uninitialized(); + ffi::graphene_box2d_init_from_points( + b.to_glib_none_mut().0, + n, + points.to_glib_none().0, + ); + b + } + } + + #[doc(alias = "graphene_box2d_init_from_vec2")] + #[doc(alias = "init_from_vec2")] + pub fn from_vec2(min: Option<&Vec2>, max: Option<&Vec2>) -> Self { + assert_initialized_main_thread!(); + unsafe { + let mut b = Self::uninitialized(); + ffi::graphene_box2d_init_from_vec2( + b.to_glib_none_mut().0, + min.to_glib_none().0, + max.to_glib_none().0, + ); + b + } + } + + #[doc(alias = "graphene_box2d_init_from_vectors")] + #[doc(alias = "init_from_vectors")] + pub fn from_vectors(vectors: &[Vec2]) -> Self { + assert_initialized_main_thread!(); + + let n = vectors.len() as u32; + + unsafe { + let mut b = Self::uninitialized(); + ffi::graphene_box2d_init_from_vectors( + b.to_glib_none_mut().0, + n, + vectors.to_glib_none().0, + ); + b + } + } + + #[doc(alias = "graphene_box2d_init_from_rect")] + pub fn init_from_rect(src: &Rect) -> Self { + assert_initialized_main_thread!(); + unsafe { + let mut b = Self::uninitialized(); + ffi::graphene_box2d_init_from_rect(b.to_glib_none_mut().0, src.to_glib_none().0); + b + } + } +} + +impl Default for Box2D { + fn default() -> Self { + Self::zero() + } +} + +impl fmt::Debug for Box2D { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Box2D") + .field("min", &self.min()) + .field("max", &self.max()) + .finish() + } +} diff --git a/graphene/src/lib.rs b/graphene/src/lib.rs index c425d3df9fec..398107d32ada 100644 --- a/graphene/src/lib.rs +++ b/graphene/src/lib.rs @@ -22,6 +22,9 @@ pub mod prelude; pub use crate::auto::*; +#[cfg(feature = "v1_12")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] +mod box2_d; mod box_; mod euler; mod frustum; diff --git a/graphene/sys/Cargo.toml b/graphene/sys/Cargo.toml index b0b444ad9245..801d7fe64c91 100644 --- a/graphene/sys/Cargo.toml +++ b/graphene/sys/Cargo.toml @@ -49,9 +49,13 @@ workspace = true name = "graphene-gobject-1.0" version = "1.10" +[package.metadata.system-deps.graphene_gobject_1_0.v1_12] +version = "1.11" + [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] all-features = true [features] +v1_12 = [] diff --git a/graphene/sys/src/lib.rs b/graphene/sys/src/lib.rs index 9a4a9abe3b52..2b64ad7e78cc 100644 --- a/graphene/sys/src/lib.rs +++ b/graphene/sys/src/lib.rs @@ -71,6 +71,19 @@ pub const GRAPHENE_VEC3_LEN: c_int = 3; pub const GRAPHENE_VEC4_LEN: c_int = 4; // Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct graphene_box2d_t { + pub minmax: graphene_vec4_t, +} + +impl ::std::fmt::Debug for graphene_box2d_t { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("graphene_box2d_t @ {self:p}")) + .finish() + } +} + #[derive(Copy, Clone)] #[repr(C)] pub struct graphene_box_t { @@ -356,6 +369,184 @@ impl ::std::fmt::Debug for graphene_vec4_t { extern "C" { + //========================================================================= + // graphene_box2d_t + //========================================================================= + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_type() -> GType; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_alloc() -> *mut graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_contains_box( + a: *const graphene_box2d_t, + b: *const graphene_box2d_t, + ) -> bool; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_contains_point( + box_: *const graphene_box2d_t, + point: *const graphene_point_t, + ) -> bool; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_contains_rect( + box_: *const graphene_box2d_t, + rect: *const graphene_rect_t, + ) -> bool; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_equal(a: *const graphene_box2d_t, b: *const graphene_box2d_t) -> bool; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_expand( + box_: *const graphene_box2d_t, + point: *const graphene_point_t, + res: *mut graphene_box2d_t, + ); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_expand_scalar( + box_: *const graphene_box2d_t, + scalar: c_float, + res: *mut graphene_box2d_t, + ); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_expand_vec2( + box_: *const graphene_box2d_t, + vec: *const graphene_vec2_t, + res: *mut graphene_box2d_t, + ); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_free(box_: *mut graphene_box2d_t); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_center(box_: *const graphene_box2d_t, center: *mut graphene_point_t); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_height(box_: *const graphene_box2d_t) -> c_float; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_max(box_: *const graphene_box2d_t, max: *mut graphene_point_t); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_min(box_: *const graphene_box2d_t, min: *mut graphene_point_t); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_minmax( + box_: *const graphene_box2d_t, + min: *mut graphene_point_t, + max: *mut graphene_point_t, + ); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_size(box_: *const graphene_box2d_t, size: *mut graphene_vec2_t); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_vertices( + box_: *const graphene_box2d_t, + vertices: *mut [graphene_vec2_t; 4], + ); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_get_width(box_: *const graphene_box2d_t) -> c_float; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_init( + box_: *mut graphene_box2d_t, + min: *const graphene_point_t, + max: *const graphene_point_t, + ) -> *mut graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_init_from_box( + box_: *mut graphene_box2d_t, + src: *const graphene_box2d_t, + ) -> *mut graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_init_from_points( + box_: *mut graphene_box2d_t, + n_points: c_uint, + points: *const graphene_point_t, + ) -> *mut graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_init_from_rect( + box_: *mut graphene_box2d_t, + src: *const graphene_rect_t, + ) -> *mut graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_init_from_vec2( + box_: *mut graphene_box2d_t, + min: *const graphene_vec2_t, + max: *const graphene_vec2_t, + ) -> *mut graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_init_from_vectors( + box_: *mut graphene_box2d_t, + n_vectors: c_uint, + vectors: *const graphene_vec2_t, + ) -> *mut graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_intersection( + a: *const graphene_box2d_t, + b: *const graphene_box2d_t, + res: *mut graphene_box2d_t, + ) -> bool; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_intersects( + a: *const graphene_box2d_t, + b: *const graphene_box2d_t, + ) -> bool; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_scale_offset( + box_: *const graphene_box2d_t, + scale: *const graphene_vec2_t, + offset: *const graphene_point_t, + res: *mut graphene_box2d_t, + ); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_to_float(box_: *const graphene_box2d_t, v: *mut [c_float; 4]); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_to_rect(box_: *const graphene_box2d_t, rect: *mut graphene_rect_t); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_union( + a: *const graphene_box2d_t, + b: *const graphene_box2d_t, + res: *mut graphene_box2d_t, + ); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_empty() -> *const graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_infinite() -> *const graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_minus_one() -> *const graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_one() -> *const graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_one_minus_one() -> *const graphene_box2d_t; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box2d_zero() -> *const graphene_box2d_t; + //========================================================================= // graphene_box_t //========================================================================= @@ -392,6 +583,13 @@ extern "C" { pub fn graphene_box_get_height(box_: *const graphene_box_t) -> c_float; pub fn graphene_box_get_max(box_: *const graphene_box_t, max: *mut graphene_point3d_t); pub fn graphene_box_get_min(box_: *const graphene_box_t, min: *mut graphene_point3d_t); + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_box_get_minmax( + box_: *const graphene_box_t, + min: *mut graphene_point3d_t, + max: *mut graphene_point3d_t, + ); pub fn graphene_box_get_size(box_: *const graphene_box_t, size: *mut graphene_vec3_t); pub fn graphene_box_get_vertices( box_: *const graphene_box_t, @@ -927,6 +1125,12 @@ extern "C" { d_x: *mut c_float, d_y: *mut c_float, ) -> c_float; + #[cfg(feature = "v1_12")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))] + pub fn graphene_point_distance_squared( + a: *const graphene_point_t, + b: *const graphene_point_t, + ) -> c_float; pub fn graphene_point_equal(a: *const graphene_point_t, b: *const graphene_point_t) -> bool; pub fn graphene_point_free(p: *mut graphene_point_t); pub fn graphene_point_init( diff --git a/graphene/sys/tests/abi.rs b/graphene/sys/tests/abi.rs index 754bc592a282..82e22ed129d1 100644 --- a/graphene/sys/tests/abi.rs +++ b/graphene/sys/tests/abi.rs @@ -201,6 +201,13 @@ fn get_c_output(name: &str) -> Result> { } const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "graphene_box2d_t", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), ( "graphene_box_t", Layout { diff --git a/graphene/sys/tests/layout.c b/graphene/sys/tests/layout.c index 108cb5b2c5bd..88126d5d998a 100644 --- a/graphene/sys/tests/layout.c +++ b/graphene/sys/tests/layout.c @@ -7,6 +7,7 @@ #include int main() { + printf("%s;%zu;%zu\n", "graphene_box2d_t", sizeof(graphene_box2d_t), alignof(graphene_box2d_t)); printf("%s;%zu;%zu\n", "graphene_box_t", sizeof(graphene_box_t), alignof(graphene_box_t)); printf("%s;%zu;%zu\n", "graphene_euler_order_t", sizeof(graphene_euler_order_t), alignof(graphene_euler_order_t)); printf("%s;%zu;%zu\n", "graphene_euler_t", sizeof(graphene_euler_t), alignof(graphene_euler_t)); diff --git a/graphene/sys/versions.txt b/graphene/sys/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/graphene/sys/versions.txt +++ b/graphene/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/pango/src/auto/versions.txt b/pango/src/auto/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/pango/src/auto/versions.txt +++ b/pango/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/pango/sys/versions.txt b/pango/sys/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/pango/sys/versions.txt +++ b/pango/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/pangocairo/src/auto/versions.txt b/pangocairo/src/auto/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/pangocairo/src/auto/versions.txt +++ b/pangocairo/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7) diff --git a/pangocairo/sys/versions.txt b/pangocairo/sys/versions.txt index 25101d8e282d..d37007d58839 100644 --- a/pangocairo/sys/versions.txt +++ b/pangocairo/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) -from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) +Generated by gir (https://github.com/gtk-rs/gir @ b2a1c6f9b362) +from gir-files (https://github.com/gtk-rs/gir-files @ 5262e0fefdc7)