// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::ffi;
use glib::{prelude::*, translate::*};

#[cfg(feature = "gtk_v4_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_6")))]
glib::wrapper! {
    #[doc(alias = "ShumateVectorSprite")]
    pub struct VectorSprite(Object<ffi::ShumateVectorSprite, ffi::ShumateVectorSpriteClass>) @implements gdk::Paintable, gtk::SymbolicPaintable;

    match fn {
        type_ => || ffi::shumate_vector_sprite_get_type(),
    }
}

#[cfg(not(any(feature = "gtk_v4_6")))]
glib::wrapper! {
    #[doc(alias = "ShumateVectorSprite")]
    pub struct VectorSprite(Object<ffi::ShumateVectorSprite, ffi::ShumateVectorSpriteClass>) @implements gdk::Paintable;

    match fn {
        type_ => || ffi::shumate_vector_sprite_get_type(),
    }
}

impl VectorSprite {
    #[doc(alias = "shumate_vector_sprite_new")]
    pub fn new(source_paintable: &impl IsA<gdk::Paintable>) -> VectorSprite {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::shumate_vector_sprite_new(
                source_paintable.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_vector_sprite_new_full")]
    pub fn new_full(
        source_paintable: &impl IsA<gdk::Paintable>,
        width: i32,
        height: i32,
        scale_factor: f64,
        source_rect: Option<&gdk::Rectangle>,
    ) -> VectorSprite {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::shumate_vector_sprite_new_full(
                source_paintable.as_ref().to_glib_none().0,
                width,
                height,
                scale_factor,
                mut_override(source_rect.to_glib_none().0),
            ))
        }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`VectorSprite`] objects.
    ///
    /// This method returns an instance of [`VectorSpriteBuilder`](crate::builders::VectorSpriteBuilder) which can be used to create [`VectorSprite`] objects.
    pub fn builder() -> VectorSpriteBuilder {
        VectorSpriteBuilder::new()
    }

    #[doc(alias = "shumate_vector_sprite_get_height")]
    #[doc(alias = "get_height")]
    pub fn height(&self) -> i32 {
        unsafe { ffi::shumate_vector_sprite_get_height(self.to_glib_none().0) }
    }

    #[doc(alias = "shumate_vector_sprite_get_scale_factor")]
    #[doc(alias = "get_scale_factor")]
    #[doc(alias = "scale-factor")]
    pub fn scale_factor(&self) -> f64 {
        unsafe { ffi::shumate_vector_sprite_get_scale_factor(self.to_glib_none().0) }
    }

    #[doc(alias = "shumate_vector_sprite_get_source_paintable")]
    #[doc(alias = "get_source_paintable")]
    #[doc(alias = "source-paintable")]
    pub fn source_paintable(&self) -> Option<gdk::Paintable> {
        unsafe {
            from_glib_none(ffi::shumate_vector_sprite_get_source_paintable(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_vector_sprite_get_source_rect")]
    #[doc(alias = "get_source_rect")]
    #[doc(alias = "source-rect")]
    pub fn source_rect(&self) -> Option<gdk::Rectangle> {
        unsafe {
            from_glib_none(ffi::shumate_vector_sprite_get_source_rect(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_vector_sprite_get_width")]
    #[doc(alias = "get_width")]
    pub fn width(&self) -> i32 {
        unsafe { ffi::shumate_vector_sprite_get_width(self.to_glib_none().0) }
    }
}

#[cfg(feature = "v1_1")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
impl Default for VectorSprite {
    fn default() -> Self {
        glib::object::Object::new::<Self>()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`VectorSprite`] 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 VectorSpriteBuilder {
    builder: glib::object::ObjectBuilder<'static, VectorSprite>,
}

impl VectorSpriteBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    #[cfg(feature = "v1_1")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
    pub fn height(self, height: i32) -> Self {
        Self {
            builder: self.builder.property("height", height),
        }
    }

    #[cfg(feature = "v1_1")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
    pub fn scale_factor(self, scale_factor: f64) -> Self {
        Self {
            builder: self.builder.property("scale-factor", scale_factor),
        }
    }

    #[cfg(feature = "v1_1")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
    pub fn source_paintable(self, source_paintable: &impl IsA<gdk::Paintable>) -> Self {
        Self {
            builder: self
                .builder
                .property("source-paintable", source_paintable.clone().upcast()),
        }
    }

    #[cfg(feature = "v1_1")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
    pub fn source_rect(self, source_rect: &gdk::Rectangle) -> Self {
        Self {
            builder: self.builder.property("source-rect", source_rect),
        }
    }

    #[cfg(feature = "v1_1")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
    pub fn width(self, width: i32) -> Self {
        Self {
            builder: self.builder.property("width", width),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`VectorSprite`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> VectorSprite {
        assert_initialized_main_thread!();
        self.builder.build()
    }
}
