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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031
// Generated by gir (https://github.com/gtk-rs/gir @ d7c0763cacbc)
// from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)
// DO NOT EDIT
#![allow(deprecated)]
use crate::{ffi, AbyssPolicy, Color, Rectangle, TileBackend, TileHandler, TileSource};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
///
///
/// ## Properties
///
///
/// #### `abyss-height`
/// Readable | Writeable | Construct Only
///
///
/// #### `abyss-width`
/// Readable | Writeable | Construct Only
///
///
/// #### `abyss-x`
/// Readable | Writeable | Construct Only
///
///
/// #### `abyss-y`
/// Readable | Writeable | Construct Only
///
///
/// #### `backend`
/// Readable | Writeable | Construct Only
///
///
/// #### `format`
/// Readable | Writeable | Construct
///
///
/// #### `height`
/// Readable | Writeable | Construct
///
///
/// #### `initialized`
/// Readable | Writeable | Construct Only
///
///
/// #### `path`
/// Readable | Writeable | Construct Only
///
///
/// #### `pixels`
/// Readable
///
///
/// #### `px-size`
/// Readable
///
///
/// #### `shift-x`
/// Readable | Writeable | Construct Only
///
///
/// #### `shift-y`
/// Readable | Writeable | Construct Only
///
///
/// #### `tile-height`
/// Readable | Writeable | Construct Only
///
///
/// #### `tile-width`
/// Readable | Writeable | Construct Only
///
///
/// #### `width`
/// Readable | Writeable | Construct
///
///
/// #### `x`
/// Readable | Writeable | Construct
///
///
/// #### `y`
/// Readable | Writeable | Construct
/// <details><summary><h4>TileHandler</h4></summary>
///
///
/// #### `source`
/// Readable | Writeable | Construct
/// </details>
///
/// ## Signals
///
///
/// #### `changed`
///
///
/// # Implements
///
/// [`TileHandlerExt`][trait@crate::prelude::TileHandlerExt], [`TileSourceExt`][trait@crate::prelude::TileSourceExt]
#[doc(alias = "GeglBuffer")]
pub struct Buffer(Object<ffi::GeglBuffer>) @extends TileHandler, TileSource;
match fn {
type_ => || ffi::gegl_buffer_get_type(),
}
}
impl Buffer {
/// Create a new GeglBuffer with the given format and dimensions.
/// ## `format_name`
/// The Babl format name for this buffer, e.g. "RGBA float"
/// ## `x`
/// x origin of the buffer's extent
/// ## `y`
/// y origin of the buffer's extent
/// ## `width`
/// width of the buffer's extent
/// ## `height`
/// height of the buffer's extent
#[doc(alias = "gegl_buffer_introspectable_new")]
pub fn introspectable_new(
format_name: &str,
x: i32,
y: i32,
width: i32,
height: i32,
) -> Buffer {
unsafe {
from_glib_full(ffi::gegl_buffer_introspectable_new(
format_name.to_glib_none().0,
x,
y,
width,
height,
))
}
}
//#[doc(alias = "gegl_buffer_linear_new_from_data")]
//pub fn linear_new_from_data(data: /*Unimplemented*/Option<Basic: Pointer>, format: &babl::Object, extent: &Rectangle, rowstride: i32, destroy_fn_data: /*Unimplemented*/Option<Basic: Pointer>) -> Buffer {
// unsafe { TODO: call ffi:gegl_buffer_linear_new_from_data() }
//}
/// Create a new GeglBuffer from a backend, if NULL is passed in the extent of
/// the buffer will be inherited from the extent of the backend.
///
/// returns a GeglBuffer, that holds a reference to the provided backend.
/// ## `extent`
/// the geometry of the buffer (origin, width and height) a
/// GeglRectangle.
/// ## `backend`
/// an instance of a GeglTileBackend subclass.
#[doc(alias = "gegl_buffer_new_for_backend")]
#[doc(alias = "new_for_backend")]
pub fn for_backend(extent: &Rectangle, backend: &impl IsA<TileBackend>) -> Buffer {
unsafe {
from_glib_full(ffi::gegl_buffer_new_for_backend(
extent.to_glib_none().0,
backend.as_ref().to_glib_none().0,
))
}
}
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`Buffer`] objects.
///
/// This method returns an instance of [`BufferBuilder`](crate::builders::BufferBuilder) which can be used to create [`Buffer`] objects.
pub fn builder() -> BufferBuilder {
BufferBuilder::new()
}
//#[doc(alias = "gegl_buffer_add_handler")]
//pub fn add_handler(&self, handler: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:gegl_buffer_add_handler() }
//}
/// Clears the provided rectangular region by setting all the associated memory
/// to 0.
/// ## `roi`
/// a rectangular region
#[doc(alias = "gegl_buffer_clear")]
pub fn clear(&self, roi: &Rectangle) {
unsafe {
ffi::gegl_buffer_clear(self.to_glib_none().0, roi.to_glib_none().0);
}
}
#[doc(alias = "gegl_buffer_copy")]
pub fn copy(
&self,
src_rect: &Rectangle,
repeat_mode: AbyssPolicy,
dst: &Buffer,
dst_rect: &Rectangle,
) {
unsafe {
ffi::gegl_buffer_copy(
self.to_glib_none().0,
src_rect.to_glib_none().0,
repeat_mode.into_glib(),
dst.to_glib_none().0,
dst_rect.to_glib_none().0,
);
}
}
/// Create a new sub GeglBuffer, that is a view on a larger buffer.
/// ## `extent`
/// coordinates of new buffer.
///
/// # Returns
///
/// the new sub buffer
#[doc(alias = "gegl_buffer_create_sub_buffer")]
#[must_use]
pub fn create_sub_buffer(&self, extent: &Rectangle) -> Option<Buffer> {
unsafe {
from_glib_full(ffi::gegl_buffer_create_sub_buffer(
self.to_glib_none().0,
extent.to_glib_none().0,
))
}
}
/// Duplicate a buffer (internally uses gegl_buffer_copy). Aligned tiles
/// will create copy-on-write clones in the new buffer.
///
/// # Returns
///
/// the new buffer
#[doc(alias = "gegl_buffer_dup")]
#[must_use]
pub fn dup(&self) -> Option<Buffer> {
unsafe { from_glib_full(ffi::gegl_buffer_dup(self.to_glib_none().0)) }
}
/// Flushes all unsaved data to disk, this is not necessary for shared
/// geglbuffers opened with gegl_buffer_open since they auto-sync on writes.
#[doc(alias = "gegl_buffer_flush")]
pub fn flush(&self) {
unsafe {
ffi::gegl_buffer_flush(self.to_glib_none().0);
}
}
/// Invokes the external flush function, if any is set on the provided buffer -
/// this ensures that data pending - in the current implementation only OpenCL -
/// externally to be synchronized with the buffer. Multi threaded code should
/// call such a synchronization before branching out to avoid each of the
/// threads having an implicit synchronization of its own.
/// ## `rect`
/// rectangle
#[doc(alias = "gegl_buffer_flush_ext")]
pub fn flush_ext(&self, rect: &Rectangle) {
unsafe {
ffi::gegl_buffer_flush_ext(self.to_glib_none().0, rect.to_glib_none().0);
}
}
/// Blocks emission of the "changed" signal for `self`.
///
/// While the signal is blocked, changes to `self` are accumulated, and will
/// be emitted once the signal is unblocked, using [`thaw_changed()`][Self::thaw_changed()].
#[doc(alias = "gegl_buffer_freeze_changed")]
pub fn freeze_changed(&self) {
unsafe {
ffi::gegl_buffer_freeze_changed(self.to_glib_none().0);
}
}
//#[doc(alias = "gegl_buffer_get")]
//pub fn get(&self, rect: &Rectangle, scale: f64, format: &babl::Object, dest: /*Unimplemented*/Option<Basic: Pointer>, rowstride: i32, repeat_mode: AbyssPolicy) {
// unsafe { TODO: call ffi:gegl_buffer_get() }
//}
/// Return the abyss extent of a buffer, this expands out to the parents extent in
/// subbuffers.
#[doc(alias = "gegl_buffer_get_abyss")]
#[doc(alias = "get_abyss")]
pub fn abyss(&self) -> Option<Rectangle> {
unsafe { from_glib_none(ffi::gegl_buffer_get_abyss(self.to_glib_none().0)) }
}
/// Returns a pointer to a GeglRectangle structure defining the geometry of a
/// specific GeglBuffer, this is also the default width/height of buffers passed
/// in to gegl_buffer_set and gegl_buffer_get (with a scale of 1.0 at least).
#[doc(alias = "gegl_buffer_get_extent")]
#[doc(alias = "get_extent")]
pub fn extent(&self) -> Option<Rectangle> {
unsafe { from_glib_none(ffi::gegl_buffer_get_extent(self.to_glib_none().0)) }
}
//#[doc(alias = "gegl_buffer_get_tile")]
//#[doc(alias = "get_tile")]
//pub fn tile(&self, x: i32, y: i32, z: i32) -> /*Ignored*/Option<Tile> {
// unsafe { TODO: call ffi:gegl_buffer_get_tile() }
//}
/// Fetch a rectangular linear buffer of pixel data from the GeglBuffer.
/// ## `rect`
/// the coordinates we want to retrieve data from.
/// ## `scale`
/// sampling scale, 1.0 = pixel for pixel 2.0 = magnify, 0.5 scale down.
/// ## `format_name`
/// the format to store data in, if NULL the format of the buffer is used.
/// ## `repeat_mode`
/// how requests outside the buffer extent are handled.
/// Valid values: GEGL_ABYSS_NONE (abyss pixels are zeroed), GEGL_ABYSS_WHITE
/// (abyss pixels are white), GEGL_ABYSS_BLACK (abyss pixels are black),
/// GEGL_ABYSS_CLAMP (coordinates are clamped to the abyss rectangle),
/// GEGL_ABYSS_LOOP (buffer contents are tiled if outside of the abyss rectangle).
///
/// # Returns
///
/// A copy of the requested data
#[doc(alias = "gegl_buffer_introspectable_get")]
pub fn introspectable_get(
&self,
rect: &Rectangle,
scale: f64,
format_name: Option<&str>,
repeat_mode: AbyssPolicy,
) -> Vec<u8> {
unsafe {
let mut data_length = std::mem::MaybeUninit::uninit();
let ret = FromGlibContainer::from_glib_full_num(
ffi::gegl_buffer_introspectable_get(
self.to_glib_none().0,
rect.to_glib_none().0,
scale,
format_name.to_glib_none().0,
repeat_mode.into_glib(),
data_length.as_mut_ptr(),
),
data_length.assume_init() as _,
);
ret
}
}
/// Store a linear raster buffer into the GeglBuffer.
/// ## `rect`
/// the rectangle to write.
/// ## `format_name`
/// the format of the input data.
/// ## `src`
/// pixel data to write to `self`.
#[doc(alias = "gegl_buffer_introspectable_set")]
pub fn introspectable_set(&self, rect: &Rectangle, format_name: &str, src: &[u8]) {
let src_length = src.len() as _;
unsafe {
ffi::gegl_buffer_introspectable_set(
self.to_glib_none().0,
rect.to_glib_none().0,
format_name.to_glib_none().0,
src.to_glib_none().0,
src_length,
);
}
}
//#[doc(alias = "gegl_buffer_iterator_new")]
//pub fn iterator_new(&self, roi: &Rectangle, level: i32, format: &babl::Object, access_mode: AccessMode, abyss_policy: AbyssPolicy, max_slots: i32) -> /*Ignored*/Option<BufferIterator> {
// unsafe { TODO: call ffi:gegl_buffer_iterator_new() }
//}
//#[doc(alias = "gegl_buffer_linear_close")]
//pub fn linear_close(&self, linear: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:gegl_buffer_linear_close() }
//}
//#[doc(alias = "gegl_buffer_linear_open")]
//pub fn linear_open(&self, extent: &Rectangle, rowstride: i32, format: &babl::Object) -> /*Unimplemented*/Option<Basic: Pointer> {
// unsafe { TODO: call ffi:gegl_buffer_linear_open() }
//}
//#[doc(alias = "gegl_buffer_remove_handler")]
//pub fn remove_handler(&self, handler: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:gegl_buffer_remove_handler() }
//}
//#[doc(alias = "gegl_buffer_sample")]
//pub fn sample(&self, x: f64, y: f64, scale: /*Ignored*/&mut BufferMatrix2, dest: /*Unimplemented*/Option<Basic: Pointer>, format: &babl::Object, sampler_type: SamplerType, repeat_mode: AbyssPolicy) {
// unsafe { TODO: call ffi:gegl_buffer_sample() }
//}
//#[doc(alias = "gegl_buffer_sample_at_level")]
//pub fn sample_at_level(&self, x: f64, y: f64, scale: /*Ignored*/&mut BufferMatrix2, dest: /*Unimplemented*/Option<Basic: Pointer>, format: &babl::Object, level: i32, sampler_type: SamplerType, repeat_mode: AbyssPolicy) {
// unsafe { TODO: call ffi:gegl_buffer_sample_at_level() }
//}
/// Clean up resources used by sampling framework of buffer.
///
/// # Deprecated since 0.4.2
///
/// This function has no effect. It is not necessary to call
/// it after using `gegl_buffer_sample()` or `gegl_buffer_sample_at_level()`.
#[cfg_attr(feature = "v0_4_2", deprecated = "Since 0.4.2")]
#[allow(deprecated)]
#[doc(alias = "gegl_buffer_sample_cleanup")]
pub fn sample_cleanup(&self) {
unsafe {
ffi::gegl_buffer_sample_cleanup(self.to_glib_none().0);
}
}
//#[doc(alias = "gegl_buffer_sampler_new")]
//pub fn sampler_new(&self, format: &babl::Object, sampler_type: SamplerType) -> /*Ignored*/Option<Sampler> {
// unsafe { TODO: call ffi:gegl_buffer_sampler_new() }
//}
//#[doc(alias = "gegl_buffer_sampler_new_at_level")]
//pub fn sampler_new_at_level(&self, format: &babl::Object, sampler_type: SamplerType, level: i32) -> /*Ignored*/Option<Sampler> {
// unsafe { TODO: call ffi:gegl_buffer_sampler_new_at_level() }
//}
/// Write a GeglBuffer to a file.
/// ## `path`
/// the path where the gegl buffer will be saved, any writable GIO uri is valid.
/// ## `roi`
/// the region of interest to write, this is the tiles that will be collected and
/// written to disk.
#[doc(alias = "gegl_buffer_save")]
pub fn save(&self, path: &str, roi: &Rectangle) {
unsafe {
ffi::gegl_buffer_save(
self.to_glib_none().0,
path.to_glib_none().0,
roi.to_glib_none().0,
);
}
}
//#[doc(alias = "gegl_buffer_set")]
//pub fn set(&self, rect: &Rectangle, mipmap_level: i32, format: &babl::Object, src: /*Unimplemented*/Option<Basic: Pointer>, rowstride: i32) {
// unsafe { TODO: call ffi:gegl_buffer_set() }
//}
/// Changes the size and position of the abyss rectangle of a buffer.
///
/// Returns TRUE if the change of abyss was successful.
/// ## `abyss`
/// new abyss.
#[doc(alias = "gegl_buffer_set_abyss")]
pub fn set_abyss(&self, abyss: &Rectangle) -> bool {
unsafe {
from_glib(ffi::gegl_buffer_set_abyss(
self.to_glib_none().0,
abyss.to_glib_none().0,
))
}
}
/// Sets the region covered by rect to the specified color.
/// ## `rect`
/// a rectangular region to fill with a color.
/// ## `color`
/// the GeglColor to fill with.
#[doc(alias = "gegl_buffer_set_color")]
pub fn set_color(&self, rect: &Rectangle, color: &impl IsA<Color>) {
unsafe {
ffi::gegl_buffer_set_color(
self.to_glib_none().0,
rect.to_glib_none().0,
color.as_ref().to_glib_none().0,
);
}
}
//#[doc(alias = "gegl_buffer_set_color_from_pixel")]
//pub fn set_color_from_pixel(&self, rect: &Rectangle, pixel: /*Unimplemented*/Option<Basic: Pointer>, pixel_format: &babl::Object) {
// unsafe { TODO: call ffi:gegl_buffer_set_color_from_pixel() }
//}
/// Changes the size and position that is considered active in a buffer, this
/// operation is valid on any buffer, reads on subbuffers outside the master
/// buffer's extent are at the moment undefined.
///
/// Returns TRUE if the change of extent was successful.
/// ## `extent`
/// new extent.
#[doc(alias = "gegl_buffer_set_extent")]
pub fn set_extent(&self, extent: &Rectangle) -> bool {
unsafe {
from_glib(ffi::gegl_buffer_set_extent(
self.to_glib_none().0,
extent.to_glib_none().0,
))
}
}
/// Fill a region with a repeating pattern. Offsets parameters are
/// relative to the origin (0, 0) and not to the rectangle. So be carefull
/// about the origin of `pattern` and `self` extents.
/// ## `rect`
/// the region of `self` to fill
/// ## `pattern`
/// a [`Buffer`][crate::Buffer] to be repeated as a pattern
/// ## `x_offset`
/// where the pattern starts horizontally
/// ## `y_offset`
/// where the pattern starts vertical
#[doc(alias = "gegl_buffer_set_pattern")]
pub fn set_pattern(&self, rect: &Rectangle, pattern: &Buffer, x_offset: i32, y_offset: i32) {
unsafe {
ffi::gegl_buffer_set_pattern(
self.to_glib_none().0,
rect.to_glib_none().0,
pattern.to_glib_none().0,
x_offset,
y_offset,
);
}
}
/// Checks if a pair of buffers share the same underlying tile storage.
///
/// Returns TRUE if `self` and `buffer2` share the same storage.
/// ## `buffer2`
/// a [`Buffer`][crate::Buffer].
#[doc(alias = "gegl_buffer_share_storage")]
pub fn share_storage(&self, buffer2: &Buffer) -> bool {
unsafe {
from_glib(ffi::gegl_buffer_share_storage(
self.to_glib_none().0,
buffer2.to_glib_none().0,
))
}
}
//#[doc(alias = "gegl_buffer_signal_connect")]
//pub fn signal_connect<P: FnOnce() + 'static>(&self, detailed_signal: &str, c_handler: P, data: /*Unimplemented*/Option<Basic: Pointer>) -> libc::c_long {
// unsafe { TODO: call ffi:gegl_buffer_signal_connect() }
//}
/// Unblocks emission of the "changed" signal for `self`.
///
/// Once all calls to [`freeze_changed()`][Self::freeze_changed()] are matched by corresponding
/// calls to [`freeze_changed()`][Self::freeze_changed()], all accumulated changes are emitted.
#[doc(alias = "gegl_buffer_thaw_changed")]
pub fn thaw_changed(&self) {
unsafe {
ffi::gegl_buffer_thaw_changed(self.to_glib_none().0);
}
}
#[doc(alias = "abyss-height")]
pub fn abyss_height(&self) -> i32 {
ObjectExt::property(self, "abyss-height")
}
#[doc(alias = "abyss-width")]
pub fn abyss_width(&self) -> i32 {
ObjectExt::property(self, "abyss-width")
}
#[doc(alias = "abyss-x")]
pub fn abyss_x(&self) -> i32 {
ObjectExt::property(self, "abyss-x")
}
#[doc(alias = "abyss-y")]
pub fn abyss_y(&self) -> i32 {
ObjectExt::property(self, "abyss-y")
}
pub fn backend(&self) -> Option<TileBackend> {
ObjectExt::property(self, "backend")
}
//pub fn format(&self) -> /*Unimplemented*/Basic: Pointer {
// ObjectExt::property(self, "format")
//}
//pub fn set_format(&self, format: /*Unimplemented*/Basic: Pointer) {
// ObjectExt::set_property(self,"format", format)
//}
pub fn height(&self) -> i32 {
ObjectExt::property(self, "height")
}
pub fn set_height(&self, height: i32) {
ObjectExt::set_property(self, "height", height)
}
pub fn is_initialized(&self) -> bool {
ObjectExt::property(self, "initialized")
}
pub fn path(&self) -> Option<glib::GString> {
ObjectExt::property(self, "path")
}
pub fn pixels(&self) -> i32 {
ObjectExt::property(self, "pixels")
}
#[doc(alias = "px-size")]
pub fn px_size(&self) -> i32 {
ObjectExt::property(self, "px-size")
}
#[doc(alias = "shift-x")]
pub fn shift_x(&self) -> i32 {
ObjectExt::property(self, "shift-x")
}
#[doc(alias = "shift-y")]
pub fn shift_y(&self) -> i32 {
ObjectExt::property(self, "shift-y")
}
#[doc(alias = "tile-height")]
pub fn tile_height(&self) -> i32 {
ObjectExt::property(self, "tile-height")
}
#[doc(alias = "tile-width")]
pub fn tile_width(&self) -> i32 {
ObjectExt::property(self, "tile-width")
}
pub fn width(&self) -> i32 {
ObjectExt::property(self, "width")
}
pub fn set_width(&self, width: i32) {
ObjectExt::set_property(self, "width", width)
}
pub fn x(&self) -> i32 {
ObjectExt::property(self, "x")
}
pub fn set_x(&self, x: i32) {
ObjectExt::set_property(self, "x", x)
}
pub fn y(&self) -> i32 {
ObjectExt::property(self, "y")
}
pub fn set_y(&self, y: i32) {
ObjectExt::set_property(self, "y", y)
}
/// Loads an existing GeglBuffer from disk, if it has previously been saved with
/// gegl_buffer_save it should be possible to open through any GIO transport, buffers
/// that have been used as swap needs random access to be opened.
/// ## `path`
/// the path to a gegl buffer on disk.
///
/// # Returns
///
/// a [`Buffer`][crate::Buffer] object.
#[doc(alias = "gegl_buffer_load")]
pub fn load(path: &str) -> Option<Buffer> {
unsafe { from_glib_full(ffi::gegl_buffer_load(path.to_glib_none().0)) }
}
/// Open an existing on-disk GeglBuffer, this buffer is opened in a monitored
/// state so multiple instances of gegl can share the same buffer. Sets on
/// one buffer are reflected in the other.
/// ## `path`
/// the path to a gegl buffer on disk.
///
/// # Returns
///
/// a GeglBuffer object.
#[doc(alias = "gegl_buffer_open")]
pub fn open(path: &str) -> Option<Buffer> {
unsafe { from_glib_full(ffi::gegl_buffer_open(path.to_glib_none().0)) }
}
/// Generates a unique filename in the GEGL swap directory, suitable for
/// using as swap space. When the file is no longer needed, it may be
/// removed with [`swap_remove_file()`][Self::swap_remove_file()]; otherwise, it will be
/// removed when [`exit()`][crate::exit()] is called.
/// ## `suffix`
/// a string to suffix the filename with, for
/// identification purposes, or [`None`].
///
/// # Returns
///
/// a string containing the full
/// file path, or [`None`] is the swap is disabled. The returned string
/// should be freed with `g_free()` when no longer needed.
#[doc(alias = "gegl_buffer_swap_create_file")]
pub fn swap_create_file(suffix: Option<&str>) -> Option<std::path::PathBuf> {
unsafe { from_glib_full(ffi::gegl_buffer_swap_create_file(suffix.to_glib_none().0)) }
}
/// Tests if `path` is a swap file, that is, if it has been created
/// with [`swap_create_file()`][Self::swap_create_file()], and hasn't been removed
/// yet.
/// ## `path`
/// a filename
#[doc(alias = "gegl_buffer_swap_has_file")]
pub fn swap_has_file(path: impl AsRef<std::path::Path>) -> bool {
unsafe {
from_glib(ffi::gegl_buffer_swap_has_file(
path.as_ref().to_glib_none().0,
))
}
}
/// Removes a swap file, generated using [`swap_create_file()`][Self::swap_create_file()],
/// unlinking the file, if exists.
/// ## `path`
/// the swap file to remove, as returned by
/// [`swap_create_file()`][Self::swap_create_file()]
#[doc(alias = "gegl_buffer_swap_remove_file")]
pub fn swap_remove_file(path: impl AsRef<std::path::Path>) {
unsafe {
ffi::gegl_buffer_swap_remove_file(path.as_ref().to_glib_none().0);
}
}
#[doc(alias = "changed")]
pub fn connect_changed<F: Fn(&Self, &Rectangle) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn changed_trampoline<F: Fn(&Buffer, &Rectangle) + 'static>(
this: *mut ffi::GeglBuffer,
object: *mut ffi::GeglRectangle,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(object))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"changed\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
changed_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "format")]
pub fn connect_format_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_format_trampoline<F: Fn(&Buffer) + 'static>(
this: *mut ffi::GeglBuffer,
_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_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::format\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_format_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "height")]
pub fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_height_trampoline<F: Fn(&Buffer) + 'static>(
this: *mut ffi::GeglBuffer,
_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_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::height\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_height_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "pixels")]
pub fn connect_pixels_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_pixels_trampoline<F: Fn(&Buffer) + 'static>(
this: *mut ffi::GeglBuffer,
_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_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::pixels\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_pixels_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "px-size")]
pub fn connect_px_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_px_size_trampoline<F: Fn(&Buffer) + 'static>(
this: *mut ffi::GeglBuffer,
_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_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::px-size\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_px_size_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "width")]
pub fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_width_trampoline<F: Fn(&Buffer) + 'static>(
this: *mut ffi::GeglBuffer,
_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_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::width\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_width_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "x")]
pub fn connect_x_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_x_trampoline<F: Fn(&Buffer) + 'static>(
this: *mut ffi::GeglBuffer,
_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_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::x\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_x_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "y")]
pub fn connect_y_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_y_trampoline<F: Fn(&Buffer) + 'static>(
this: *mut ffi::GeglBuffer,
_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_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::y\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_y_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Buffer`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct BufferBuilder {
builder: glib::object::ObjectBuilder<'static, Buffer>,
}
impl BufferBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
pub fn abyss_height(self, abyss_height: i32) -> Self {
Self {
builder: self.builder.property("abyss-height", abyss_height),
}
}
pub fn abyss_width(self, abyss_width: i32) -> Self {
Self {
builder: self.builder.property("abyss-width", abyss_width),
}
}
pub fn abyss_x(self, abyss_x: i32) -> Self {
Self {
builder: self.builder.property("abyss-x", abyss_x),
}
}
pub fn abyss_y(self, abyss_y: i32) -> Self {
Self {
builder: self.builder.property("abyss-y", abyss_y),
}
}
pub fn backend(self, backend: &impl IsA<TileBackend>) -> Self {
Self {
builder: self.builder.property("backend", backend.clone().upcast()),
}
}
//pub fn format(self, format: /*Unimplemented*/Basic: Pointer) -> Self {
// Self { builder: self.builder.property("format", format), }
//}
pub fn height(self, height: i32) -> Self {
Self {
builder: self.builder.property("height", height),
}
}
pub fn initialized(self, initialized: bool) -> Self {
Self {
builder: self.builder.property("initialized", initialized),
}
}
pub fn path(self, path: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("path", path.into()),
}
}
pub fn shift_x(self, shift_x: i32) -> Self {
Self {
builder: self.builder.property("shift-x", shift_x),
}
}
pub fn shift_y(self, shift_y: i32) -> Self {
Self {
builder: self.builder.property("shift-y", shift_y),
}
}
pub fn tile_height(self, tile_height: i32) -> Self {
Self {
builder: self.builder.property("tile-height", tile_height),
}
}
pub fn tile_width(self, tile_width: i32) -> Self {
Self {
builder: self.builder.property("tile-width", tile_width),
}
}
pub fn width(self, width: i32) -> Self {
Self {
builder: self.builder.property("width", width),
}
}
pub fn x(self, x: i32) -> Self {
Self {
builder: self.builder.property("x", x),
}
}
pub fn y(self, y: i32) -> Self {
Self {
builder: self.builder.property("y", y),
}
}
//pub fn source(self, source: &impl IsA</*Ignored*/glib::Object>) -> Self {
// Self { builder: self.builder.property("source", source.clone().upcast()), }
//}
// rustdoc-stripper-ignore-next
/// Build the [`Buffer`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Buffer {
self.builder.build()
}
}