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

/*
* Copyright (c) 2018-2026 (https://github.com/phase1geo/Minder)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Trevor Williams <phase1geo@gmail.com>
*/

#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gtk/gtk.h>
#include <string.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 TYPE_ANIMATOR_NODES_ALPHA (animator_nodes_alpha_get_type ())
#define ANIMATOR_NODES_ALPHA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ANIMATOR_NODES_ALPHA, AnimatorNodesAlpha))
#define ANIMATOR_NODES_ALPHA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ANIMATOR_NODES_ALPHA, AnimatorNodesAlphaClass))
#define IS_ANIMATOR_NODES_ALPHA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ANIMATOR_NODES_ALPHA))
#define IS_ANIMATOR_NODES_ALPHA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ANIMATOR_NODES_ALPHA))
#define ANIMATOR_NODES_ALPHA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ANIMATOR_NODES_ALPHA, AnimatorNodesAlphaClass))

typedef struct _AnimatorNodesAlpha AnimatorNodesAlpha;
typedef struct _AnimatorNodesAlphaClass AnimatorNodesAlphaClass;
typedef struct _AnimatorNodesAlphaPrivate AnimatorNodesAlphaPrivate;

#define TYPE_NODE (node_get_type ())
#define NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE, Node))
#define NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE, NodeClass))
#define IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE))
#define IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE))
#define NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE, NodeClass))

typedef struct _Node Node;
typedef struct _NodeClass NodeClass;
enum  {
	ANIMATOR_NODES_ALPHA_0_PROPERTY,
	ANIMATOR_NODES_ALPHA_NUM_PROPERTIES
};
static GParamSpec* animator_nodes_alpha_properties[ANIMATOR_NODES_ALPHA_NUM_PROPERTIES];
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

#define TYPE_DRAW_AREA (draw_area_get_type ())
#define DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DRAW_AREA, DrawArea))
#define DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DRAW_AREA, DrawAreaClass))
#define IS_DRAW_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DRAW_AREA))
#define IS_DRAW_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DRAW_AREA))
#define DRAW_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DRAW_AREA, DrawAreaClass))

typedef struct _DrawArea DrawArea;
typedef struct _DrawAreaClass DrawAreaClass;

struct _AnimatorNodesAlpha {
	GObject parent_instance;
	AnimatorNodesAlphaPrivate * priv;
};

struct _AnimatorNodesAlphaClass {
	GObjectClass parent_class;
};

struct _AnimatorNodesAlphaPrivate {
	GArray* _old_alpha;
	GArray* _new_alpha;
	GArray* _nodes;
};

static gint AnimatorNodesAlpha_private_offset;
static gpointer animator_nodes_alpha_parent_class = NULL;

VALA_EXTERN GType animator_nodes_alpha_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AnimatorNodesAlpha, g_object_unref)
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
VALA_EXTERN GType draw_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DrawArea, g_object_unref)
VALA_EXTERN AnimatorNodesAlpha* animator_nodes_alpha_new (DrawArea* da,
                                              GArray* nodes,
                                              GArray* fade_out);
VALA_EXTERN AnimatorNodesAlpha* animator_nodes_alpha_construct (GType object_type,
                                                    DrawArea* da,
                                                    GArray* nodes,
                                                    GArray* fade_out);
static void _g_object_unref0_ (gpointer var);
static void _vala_Node_free_function_content_of (gpointer data);
VALA_EXTERN gdouble node_get_alpha (Node* self);
VALA_EXTERN void animator_nodes_alpha_gather_new_node_alpha (AnimatorNodesAlpha* self,
                                                 GArray* fade_out);
VALA_EXTERN gint animator_nodes_alpha_length (AnimatorNodesAlpha* self);
VALA_EXTERN gdouble animator_nodes_alpha_old_alpha (AnimatorNodesAlpha* self,
                                        gint index);
VALA_EXTERN gdouble animator_nodes_alpha_new_alpha (AnimatorNodesAlpha* self,
                                        gint index);
VALA_EXTERN Node* animator_nodes_alpha_node (AnimatorNodesAlpha* self,
                                 gint index);
static void animator_nodes_alpha_finalize (GObject * obj);
static GType animator_nodes_alpha_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
animator_nodes_alpha_get_instance_private (AnimatorNodesAlpha* self)
{
	return G_STRUCT_MEMBER_P (self, AnimatorNodesAlpha_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static void
_vala_Node_free_function_content_of (gpointer data)
{
	Node* self;
	self = *((Node**) data);
	_g_object_unref0_ (self);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

AnimatorNodesAlpha*
animator_nodes_alpha_construct (GType object_type,
                                DrawArea* da,
                                GArray* nodes,
                                GArray* fade_out)
{
	AnimatorNodesAlpha * self = NULL;
	GArray* _tmp0_;
	GArray* _tmp1_;
	GArray* _tmp2_;
	g_return_val_if_fail (da != NULL, NULL);
	g_return_val_if_fail (nodes != NULL, NULL);
	g_return_val_if_fail (fade_out != NULL, NULL);
	self = (AnimatorNodesAlpha*) g_object_new (object_type, NULL);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (gdouble));
	_g_array_unref0 (self->priv->_old_alpha);
	self->priv->_old_alpha = _tmp0_;
	_tmp1_ = g_array_new (TRUE, TRUE, sizeof (gdouble));
	_g_array_unref0 (self->priv->_new_alpha);
	self->priv->_new_alpha = _tmp1_;
	_tmp2_ = g_array_new (TRUE, TRUE, sizeof (Node*));
	g_array_set_clear_func (_tmp2_, (GDestroyNotify) _vala_Node_free_function_content_of);
	_g_array_unref0 (self->priv->_nodes);
	self->priv->_nodes = _tmp2_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				gdouble _tmp5_ = 0.0;
				GArray* _tmp9_;
				GArray* _tmp10_;
				Node* _tmp11_;
				Node* _tmp12_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				if (!(((guint) i) < nodes->len)) {
					break;
				}
				if (*g_array_index (fade_out, gboolean*, (guint) i)) {
					Node* _tmp6_;
					gdouble _tmp7_;
					gdouble _tmp8_;
					_tmp6_ = g_array_index (nodes, Node*, (guint) i);
					_tmp7_ = node_get_alpha (_tmp6_);
					_tmp8_ = _tmp7_;
					_tmp5_ = _tmp8_;
				} else {
					_tmp5_ = 0.0;
				}
				_tmp9_ = self->priv->_old_alpha;
				g_array_append_val (_tmp9_, _tmp5_);
				_tmp10_ = self->priv->_nodes;
				_tmp11_ = g_array_index (nodes, Node*, (guint) i);
				_tmp12_ = _g_object_ref0 (_tmp11_);
				g_array_append_val (_tmp10_, _tmp12_);
			}
		}
	}
	return self;
}

AnimatorNodesAlpha*
animator_nodes_alpha_new (DrawArea* da,
                          GArray* nodes,
                          GArray* fade_out)
{
	return animator_nodes_alpha_construct (TYPE_ANIMATOR_NODES_ALPHA, da, nodes, fade_out);
}

void
animator_nodes_alpha_gather_new_node_alpha (AnimatorNodesAlpha* self,
                                            GArray* fade_out)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (fade_out != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				gdouble _tmp3_ = 0.0;
				GArray* _tmp8_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_nodes;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				if (*g_array_index (fade_out, gboolean*, (guint) i)) {
					_tmp3_ = 0.0;
				} else {
					GArray* _tmp4_;
					Node* _tmp5_;
					gdouble _tmp6_;
					gdouble _tmp7_;
					_tmp4_ = self->priv->_nodes;
					_tmp5_ = g_array_index (_tmp4_, Node*, (guint) i);
					_tmp6_ = node_get_alpha (_tmp5_);
					_tmp7_ = _tmp6_;
					_tmp3_ = _tmp7_;
				}
				_tmp8_ = self->priv->_new_alpha;
				g_array_append_val (_tmp8_, _tmp3_);
			}
		}
	}
}

gint
animator_nodes_alpha_length (AnimatorNodesAlpha* self)
{
	GArray* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->_nodes;
	result = (gint) _tmp0_->len;
	return result;
}

gdouble
animator_nodes_alpha_old_alpha (AnimatorNodesAlpha* self,
                                gint index)
{
	GArray* _tmp0_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->priv->_old_alpha;
	result = g_array_index (_tmp0_, gdouble, (guint) index);
	return result;
}

gdouble
animator_nodes_alpha_new_alpha (AnimatorNodesAlpha* self,
                                gint index)
{
	GArray* _tmp0_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->priv->_new_alpha;
	result = g_array_index (_tmp0_, gdouble, (guint) index);
	return result;
}

Node*
animator_nodes_alpha_node (AnimatorNodesAlpha* self,
                           gint index)
{
	GArray* _tmp0_;
	Node* _tmp1_;
	Node* _tmp2_;
	Node* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_nodes;
	_tmp1_ = g_array_index (_tmp0_, Node*, (guint) index);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

static void
animator_nodes_alpha_class_init (AnimatorNodesAlphaClass * klass,
                                 gpointer klass_data)
{
	animator_nodes_alpha_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AnimatorNodesAlpha_private_offset);
	G_OBJECT_CLASS (klass)->finalize = animator_nodes_alpha_finalize;
}

static void
animator_nodes_alpha_instance_init (AnimatorNodesAlpha * self,
                                    gpointer klass)
{
	self->priv = animator_nodes_alpha_get_instance_private (self);
}

static void
animator_nodes_alpha_finalize (GObject * obj)
{
	AnimatorNodesAlpha * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ANIMATOR_NODES_ALPHA, AnimatorNodesAlpha);
	_g_array_unref0 (self->priv->_old_alpha);
	_g_array_unref0 (self->priv->_new_alpha);
	_g_array_unref0 (self->priv->_nodes);
	G_OBJECT_CLASS (animator_nodes_alpha_parent_class)->finalize (obj);
}

static GType
animator_nodes_alpha_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AnimatorNodesAlphaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) animator_nodes_alpha_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AnimatorNodesAlpha), 0, (GInstanceInitFunc) animator_nodes_alpha_instance_init, NULL };
	GType animator_nodes_alpha_type_id;
	animator_nodes_alpha_type_id = g_type_register_static (G_TYPE_OBJECT, "AnimatorNodesAlpha", &g_define_type_info, 0);
	AnimatorNodesAlpha_private_offset = g_type_add_instance_private (animator_nodes_alpha_type_id, sizeof (AnimatorNodesAlphaPrivate));
	return animator_nodes_alpha_type_id;
}

GType
animator_nodes_alpha_get_type (void)
{
	static volatile gsize animator_nodes_alpha_type_id__once = 0;
	if (g_once_init_enter (&animator_nodes_alpha_type_id__once)) {
		GType animator_nodes_alpha_type_id;
		animator_nodes_alpha_type_id = animator_nodes_alpha_get_type_once ();
		g_once_init_leave (&animator_nodes_alpha_type_id__once, animator_nodes_alpha_type_id);
	}
	return animator_nodes_alpha_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

