/* transform-bin.c generated by valac 0.56.19, the Vala compiler
 * generated from transform-bin.vala, do not modify */

/* This file is part of Elastic. License: GPL-3.0+.*/

#include <adwaita.h>
#include <glib-object.h>
#include <gsk/gsk.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <graphene-gobject.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define ELASTIC_TYPE_TRANSFORM_BIN (elastic_transform_bin_get_type ())
#define ELASTIC_TRANSFORM_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ELASTIC_TYPE_TRANSFORM_BIN, ElasticTransformBin))
#define ELASTIC_TRANSFORM_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ELASTIC_TYPE_TRANSFORM_BIN, ElasticTransformBinClass))
#define ELASTIC_IS_TRANSFORM_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ELASTIC_TYPE_TRANSFORM_BIN))
#define ELASTIC_IS_TRANSFORM_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ELASTIC_TYPE_TRANSFORM_BIN))
#define ELASTIC_TRANSFORM_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ELASTIC_TYPE_TRANSFORM_BIN, ElasticTransformBinClass))

typedef struct _ElasticTransformBin ElasticTransformBin;
typedef struct _ElasticTransformBinClass ElasticTransformBinClass;
typedef struct _ElasticTransformBinPrivate ElasticTransformBinPrivate;
enum  {
	ELASTIC_TRANSFORM_BIN_0_PROPERTY,
	ELASTIC_TRANSFORM_BIN_TRANSFORM_PROPERTY,
	ELASTIC_TRANSFORM_BIN_NUM_PROPERTIES
};
static GParamSpec* elastic_transform_bin_properties[ELASTIC_TRANSFORM_BIN_NUM_PROPERTIES];
#define _gsk_transform_unref0(var) ((var == NULL) ? NULL : (var = (gsk_transform_unref (var), NULL)))

struct _ElasticTransformBin {
	AdwBin parent_instance;
	ElasticTransformBinPrivate * priv;
};

struct _ElasticTransformBinClass {
	AdwBinClass parent_class;
};

struct _ElasticTransformBinPrivate {
	GskTransform* _transform;
};

static gint ElasticTransformBin_private_offset;
static gpointer elastic_transform_bin_parent_class = NULL;

VALA_EXTERN GType elastic_transform_bin_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ElasticTransformBin, g_object_unref)
static void elastic_transform_bin_real_measure (GtkWidget* base,
                                         GtkOrientation orientation,
                                         gint for_size,
                                         gint* minimum,
                                         gint* natural,
                                         gint* minimum_baseline,
                                         gint* natural_baseline);
static void elastic_transform_bin_real_size_allocate (GtkWidget* base,
                                               gint width,
                                               gint height,
                                               gint baseline);
VALA_EXTERN GskTransform* elastic_transform_bin_get_transform (ElasticTransformBin* self);
VALA_EXTERN ElasticTransformBin* elastic_transform_bin_new (void);
VALA_EXTERN ElasticTransformBin* elastic_transform_bin_construct (GType object_type);
VALA_EXTERN void elastic_transform_bin_set_transform (ElasticTransformBin* self,
                                          GskTransform* value);
static GObject * elastic_transform_bin_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static void _gtk_widget_queue_allocate_g_object_notify (GObject* _sender,
                                                 GParamSpec* pspec,
                                                 gpointer self);
static void elastic_transform_bin_finalize (GObject * obj);
static GType elastic_transform_bin_get_type_once (void);
static void _vala_elastic_transform_bin_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_elastic_transform_bin_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);

static inline gpointer
elastic_transform_bin_get_instance_private (ElasticTransformBin* self)
{
	return G_STRUCT_MEMBER_P (self, ElasticTransformBin_private_offset);
}

static void
elastic_transform_bin_real_measure (GtkWidget* base,
                                    GtkOrientation orientation,
                                    gint for_size,
                                    gint* minimum,
                                    gint* natural,
                                    gint* minimum_baseline,
                                    gint* natural_baseline)
{
	ElasticTransformBin * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	gint _tmp4_ = 0;
	gint _tmp5_ = 0;
	gint _tmp6_ = 0;
	gint _tmp7_ = 0;
	self = (ElasticTransformBin*) base;
	_tmp0_ = adw_bin_get_child ((AdwBin*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		_vala_minimum = 0;
		_vala_natural = 0;
		_vala_minimum_baseline = -1;
		_vala_natural_baseline = -1;
		if (minimum) {
			*minimum = _vala_minimum;
		}
		if (natural) {
			*natural = _vala_natural;
		}
		if (minimum_baseline) {
			*minimum_baseline = _vala_minimum_baseline;
		}
		if (natural_baseline) {
			*natural_baseline = _vala_natural_baseline;
		}
		return;
	}
	_tmp2_ = adw_bin_get_child ((AdwBin*) self);
	_tmp3_ = _tmp2_;
	gtk_widget_measure (_tmp3_, orientation, for_size, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
	_vala_minimum = _tmp4_;
	_vala_natural = _tmp5_;
	_vala_minimum_baseline = _tmp6_;
	_vala_natural_baseline = _tmp7_;
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
	if (minimum_baseline) {
		*minimum_baseline = _vala_minimum_baseline;
	}
	if (natural_baseline) {
		*natural_baseline = _vala_natural_baseline;
	}
}

static gpointer
_gsk_transform_ref0 (gpointer self)
{
	return self ? gsk_transform_ref (self) : NULL;
}

static void
elastic_transform_bin_real_size_allocate (GtkWidget* base,
                                          gint width,
                                          gint height,
                                          gint baseline)
{
	ElasticTransformBin * self;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GskTransform* t = NULL;
	GskTransform* _tmp2_;
	GskTransform* _tmp3_;
	graphene_point_t _tmp4_ = {0};
	GskTransform* _tmp5_;
	GskTransform* _tmp6_;
	GskTransform* _tmp10_;
	graphene_point_t _tmp11_ = {0};
	GskTransform* _tmp12_;
	GtkWidget* _tmp13_;
	GtkWidget* _tmp14_;
	GskTransform* _tmp15_;
	GskTransform* _tmp16_;
	self = (ElasticTransformBin*) base;
	_tmp0_ = adw_bin_get_child ((AdwBin*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		return;
	}
	_tmp2_ = gsk_transform_new ();
	t = _tmp2_;
	_tmp3_ = t;
	t = NULL;
	_tmp4_.x = (gfloat) (width / 2);
	_tmp4_.y = (gfloat) (height / 2);
	_tmp5_ = gsk_transform_translate (_tmp3_, &_tmp4_);
	_gsk_transform_unref0 (t);
	t = _tmp5_;
	_tmp6_ = self->priv->_transform;
	if (_tmp6_ != NULL) {
		GskTransform* _tmp7_;
		GskTransform* _tmp8_;
		GskTransform* _tmp9_;
		_tmp7_ = t;
		t = NULL;
		_tmp8_ = self->priv->_transform;
		_tmp9_ = gsk_transform_transform (_tmp7_, _tmp8_);
		_gsk_transform_unref0 (t);
		t = _tmp9_;
	}
	_tmp10_ = t;
	t = NULL;
	_tmp11_.x = (gfloat) ((-width) / 2);
	_tmp11_.y = (gfloat) ((-height) / 2);
	_tmp12_ = gsk_transform_translate (_tmp10_, &_tmp11_);
	_gsk_transform_unref0 (t);
	t = _tmp12_;
	_tmp13_ = adw_bin_get_child ((AdwBin*) self);
	_tmp14_ = _tmp13_;
	_tmp15_ = t;
	_tmp16_ = _gsk_transform_ref0 (_tmp15_);
	gtk_widget_allocate (_tmp14_, width, height, baseline, _tmp16_);
	_gsk_transform_unref0 (t);
}

ElasticTransformBin*
elastic_transform_bin_construct (GType object_type)
{
	ElasticTransformBin * self = NULL;
	self = (ElasticTransformBin*) g_object_new (object_type, NULL);
	return self;
}

ElasticTransformBin*
elastic_transform_bin_new (void)
{
	return elastic_transform_bin_construct (ELASTIC_TYPE_TRANSFORM_BIN);
}

GskTransform*
elastic_transform_bin_get_transform (ElasticTransformBin* self)
{
	GskTransform* result;
	GskTransform* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_transform;
	result = _tmp0_;
	return result;
}

void
elastic_transform_bin_set_transform (ElasticTransformBin* self,
                                     GskTransform* value)
{
	GskTransform* old_value;
	g_return_if_fail (self != NULL);
	old_value = elastic_transform_bin_get_transform (self);
	if (old_value != value) {
		GskTransform* _tmp0_;
		_tmp0_ = _gsk_transform_ref0 (value);
		_gsk_transform_unref0 (self->priv->_transform);
		self->priv->_transform = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, elastic_transform_bin_properties[ELASTIC_TRANSFORM_BIN_TRANSFORM_PROPERTY]);
	}
}

static void
_gtk_widget_queue_allocate_g_object_notify (GObject* _sender,
                                            GParamSpec* pspec,
                                            gpointer self)
{
	gtk_widget_queue_allocate ((GtkWidget*) self);
}

static GObject *
elastic_transform_bin_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ElasticTransformBin * self;
	parent_class = G_OBJECT_CLASS (elastic_transform_bin_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ELASTIC_TYPE_TRANSFORM_BIN, ElasticTransformBin);
	gtk_widget_set_layout_manager ((GtkWidget*) self, NULL);
	g_signal_connect_object ((GObject*) self, "notify::transform", (GCallback) _gtk_widget_queue_allocate_g_object_notify, (GtkWidget*) self, 0);
	return obj;
}

static void
elastic_transform_bin_class_init (ElasticTransformBinClass * klass,
                                  gpointer klass_data)
{
	elastic_transform_bin_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ElasticTransformBin_private_offset);
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) elastic_transform_bin_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) elastic_transform_bin_real_size_allocate;
	G_OBJECT_CLASS (klass)->get_property = _vala_elastic_transform_bin_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_elastic_transform_bin_set_property;
	G_OBJECT_CLASS (klass)->constructor = elastic_transform_bin_constructor;
	G_OBJECT_CLASS (klass)->finalize = elastic_transform_bin_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ELASTIC_TRANSFORM_BIN_TRANSFORM_PROPERTY, elastic_transform_bin_properties[ELASTIC_TRANSFORM_BIN_TRANSFORM_PROPERTY] = g_param_spec_boxed ("transform", "transform", "transform", gsk_transform_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "transform-bin");
}

static void
elastic_transform_bin_instance_init (ElasticTransformBin * self,
                                     gpointer klass)
{
	self->priv = elastic_transform_bin_get_instance_private (self);
}

static void
elastic_transform_bin_finalize (GObject * obj)
{
	ElasticTransformBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ELASTIC_TYPE_TRANSFORM_BIN, ElasticTransformBin);
	_gsk_transform_unref0 (self->priv->_transform);
	G_OBJECT_CLASS (elastic_transform_bin_parent_class)->finalize (obj);
}

static GType
elastic_transform_bin_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ElasticTransformBinClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) elastic_transform_bin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ElasticTransformBin), 0, (GInstanceInitFunc) elastic_transform_bin_instance_init, NULL };
	GType elastic_transform_bin_type_id;
	elastic_transform_bin_type_id = g_type_register_static (adw_bin_get_type (), "ElasticTransformBin", &g_define_type_info, 0);
	ElasticTransformBin_private_offset = g_type_add_instance_private (elastic_transform_bin_type_id, sizeof (ElasticTransformBinPrivate));
	return elastic_transform_bin_type_id;
}

GType
elastic_transform_bin_get_type (void)
{
	static volatile gsize elastic_transform_bin_type_id__once = 0;
	if (g_once_init_enter (&elastic_transform_bin_type_id__once)) {
		GType elastic_transform_bin_type_id;
		elastic_transform_bin_type_id = elastic_transform_bin_get_type_once ();
		g_once_init_leave (&elastic_transform_bin_type_id__once, elastic_transform_bin_type_id);
	}
	return elastic_transform_bin_type_id__once;
}

static void
_vala_elastic_transform_bin_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	ElasticTransformBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ELASTIC_TYPE_TRANSFORM_BIN, ElasticTransformBin);
	switch (property_id) {
		case ELASTIC_TRANSFORM_BIN_TRANSFORM_PROPERTY:
		g_value_set_boxed (value, elastic_transform_bin_get_transform (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_elastic_transform_bin_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	ElasticTransformBin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ELASTIC_TYPE_TRANSFORM_BIN, ElasticTransformBin);
	switch (property_id) {
		case ELASTIC_TRANSFORM_BIN_TRANSFORM_PROPERTY:
		elastic_transform_bin_set_transform (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

