/* AnimatorCallouts.c generated by valac 0.56.19, the Vala compiler
 * generated from AnimatorCallouts.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_CALLOUTS (animator_callouts_get_type ())
#define ANIMATOR_CALLOUTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ANIMATOR_CALLOUTS, AnimatorCallouts))
#define ANIMATOR_CALLOUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ANIMATOR_CALLOUTS, AnimatorCalloutsClass))
#define IS_ANIMATOR_CALLOUTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ANIMATOR_CALLOUTS))
#define IS_ANIMATOR_CALLOUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ANIMATOR_CALLOUTS))
#define ANIMATOR_CALLOUTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ANIMATOR_CALLOUTS, AnimatorCalloutsClass))

typedef struct _AnimatorCallouts AnimatorCallouts;
typedef struct _AnimatorCalloutsClass AnimatorCalloutsClass;
typedef struct _AnimatorCalloutsPrivate AnimatorCalloutsPrivate;

#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_CALLOUTS_0_PROPERTY,
	ANIMATOR_CALLOUTS_NUM_PROPERTIES
};
static GParamSpec* animator_callouts_properties[ANIMATOR_CALLOUTS_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;

#define TYPE_CALLOUT (callout_get_type ())
#define CALLOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CALLOUT, Callout))
#define CALLOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CALLOUT, CalloutClass))
#define IS_CALLOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CALLOUT))
#define IS_CALLOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CALLOUT))
#define CALLOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CALLOUT, CalloutClass))

typedef struct _Callout Callout;
typedef struct _CalloutClass CalloutClass;
typedef enum  {
	CALLOUT_MODE_NONE = 0,
	CALLOUT_MODE_SELECTED,
	CALLOUT_MODE_EDITABLE,
	CALLOUT_MODE_HIDING,
	CALLOUT_MODE_HIDDEN
} CalloutMode;

#define TYPE_CALLOUT_MODE (callout_mode_get_type ())

struct _AnimatorCallouts {
	GObject parent_instance;
	AnimatorCalloutsPrivate * priv;
};

struct _AnimatorCalloutsClass {
	GObjectClass parent_class;
};

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

static gint AnimatorCallouts_private_offset;
static gpointer animator_callouts_parent_class = NULL;

VALA_EXTERN GType animator_callouts_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AnimatorCallouts, 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 AnimatorCallouts* animator_callouts_new (DrawArea* da,
                                         GArray* nodes,
                                         gboolean fade_out);
VALA_EXTERN AnimatorCallouts* animator_callouts_construct (GType object_type,
                                               DrawArea* da,
                                               GArray* nodes,
                                               gboolean fade_out);
static void _g_free0_ (gpointer var);
static void _vala_gdouble_free_function_content_of (gpointer data);
static void _g_object_unref0_ (gpointer var);
static void _vala_Node_free_function_content_of (gpointer data);
static void animator_callouts_gather_old_callout_alphas (AnimatorCallouts* self,
                                                  Node* n,
                                                  gboolean fade_out);
VALA_EXTERN GType callout_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Callout, g_object_unref)
VALA_EXTERN Callout* node_get_callout (Node* self);
VALA_EXTERN GType callout_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void callout_set_mode (Callout* self,
                       CalloutMode value);
VALA_EXTERN gdouble callout_get_alpha (Callout* self);
static gdouble* _double_dup (gdouble* self);
VALA_EXTERN GArray* node_children (Node* self);
VALA_EXTERN void animator_callouts_gather_new_callout_alphas (AnimatorCallouts* self,
                                                  gboolean fade_out);
VALA_EXTERN gdouble node_get_alpha (Node* self);
VALA_EXTERN guint animator_callouts_length (AnimatorCallouts* self);
VALA_EXTERN gdouble animator_callouts_old_alpha (AnimatorCallouts* self,
                                     gint index);
VALA_EXTERN gdouble animator_callouts_new_alpha (AnimatorCallouts* self,
                                     gint index);
VALA_EXTERN Node* animator_callouts_node (AnimatorCallouts* self,
                              gint index);
static void animator_callouts_finalize (GObject * obj);
static GType animator_callouts_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
animator_callouts_get_instance_private (AnimatorCallouts* self)
{
	return G_STRUCT_MEMBER_P (self, AnimatorCallouts_private_offset);
}

static void
_g_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_free (var), NULL));
}

static void
_vala_gdouble_free_function_content_of (gpointer data)
{
	gdouble* self;
	self = *((gdouble**) data);
	_g_free0_ (self);
}

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);
}

AnimatorCallouts*
animator_callouts_construct (GType object_type,
                             DrawArea* da,
                             GArray* nodes,
                             gboolean fade_out)
{
	AnimatorCallouts * self = NULL;
	GArray* _tmp0_;
	GArray* _tmp1_;
	GArray* _tmp2_;
	g_return_val_if_fail (da != NULL, NULL);
	g_return_val_if_fail (nodes != NULL, NULL);
	self = (AnimatorCallouts*) g_object_new (object_type, NULL);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (gdouble*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_gdouble_free_function_content_of);
	_g_array_unref0 (self->priv->_old_alpha);
	self->priv->_old_alpha = _tmp0_;
	_tmp1_ = g_array_new (TRUE, TRUE, sizeof (gdouble*));
	g_array_set_clear_func (_tmp1_, (GDestroyNotify) _vala_gdouble_free_function_content_of);
	_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) {
				Node* _tmp5_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				if (!(((guint) i) < nodes->len)) {
					break;
				}
				_tmp5_ = g_array_index (nodes, Node*, (guint) i);
				animator_callouts_gather_old_callout_alphas (self, _tmp5_, fade_out);
			}
		}
	}
	return self;
}

AnimatorCallouts*
animator_callouts_new (DrawArea* da,
                       GArray* nodes,
                       gboolean fade_out)
{
	return animator_callouts_construct (TYPE_ANIMATOR_CALLOUTS, da, nodes, fade_out);
}

static gdouble*
_double_dup (gdouble* self)
{
	gdouble* dup;
	dup = g_new0 (gdouble, 1);
	memcpy (dup, self, sizeof (gdouble));
	return dup;
}

static gpointer
__double_dup0 (gpointer self)
{
	return self ? _double_dup (self) : NULL;
}

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

static void
animator_callouts_gather_old_callout_alphas (AnimatorCallouts* self,
                                             Node* n,
                                             gboolean fade_out)
{
	Callout* _tmp0_;
	Callout* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (n != NULL);
	_tmp0_ = node_get_callout (n);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		CalloutMode _tmp2_ = 0;
		Callout* _tmp3_;
		Callout* _tmp4_;
		gdouble _tmp5_ = 0.0;
		GArray* _tmp10_;
		gdouble* _tmp11_;
		GArray* _tmp12_;
		Node* _tmp13_;
		if (fade_out) {
			_tmp2_ = CALLOUT_MODE_HIDING;
		} else {
			_tmp2_ = CALLOUT_MODE_NONE;
		}
		_tmp3_ = node_get_callout (n);
		_tmp4_ = _tmp3_;
		callout_set_mode (_tmp4_, _tmp2_);
		if (fade_out) {
			Callout* _tmp6_;
			Callout* _tmp7_;
			gdouble _tmp8_;
			gdouble _tmp9_;
			_tmp6_ = node_get_callout (n);
			_tmp7_ = _tmp6_;
			_tmp8_ = callout_get_alpha (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp5_ = _tmp9_;
		} else {
			_tmp5_ = 0.0;
		}
		_tmp10_ = self->priv->_old_alpha;
		_tmp11_ = __double_dup0 (&_tmp5_);
		g_array_append_val (_tmp10_, _tmp11_);
		_tmp12_ = self->priv->_nodes;
		_tmp13_ = _g_object_ref0 (n);
		g_array_append_val (_tmp12_, _tmp13_);
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp14_ = FALSE;
			_tmp14_ = TRUE;
			while (TRUE) {
				GArray* _tmp16_;
				GArray* _tmp17_;
				gboolean _tmp18_;
				GArray* _tmp19_;
				GArray* _tmp20_;
				Node* _tmp21_;
				if (!_tmp14_) {
					gint _tmp15_;
					_tmp15_ = i;
					i = _tmp15_ + 1;
				}
				_tmp14_ = FALSE;
				_tmp16_ = node_children (n);
				_tmp17_ = _tmp16_;
				_tmp18_ = !(((guint) i) < _tmp17_->len);
				_g_array_unref0 (_tmp17_);
				if (_tmp18_) {
					break;
				}
				_tmp19_ = node_children (n);
				_tmp20_ = _tmp19_;
				_tmp21_ = g_array_index (_tmp20_, Node*, (guint) i);
				animator_callouts_gather_old_callout_alphas (self, _tmp21_, fade_out);
				_g_array_unref0 (_tmp20_);
			}
		}
	}
}

void
animator_callouts_gather_new_callout_alphas (AnimatorCallouts* self,
                                             gboolean fade_out)
{
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				gdouble _tmp3_ = 0.0;
				GArray* _tmp8_;
				gdouble* _tmp9_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_nodes;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				if (fade_out) {
					_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;
				_tmp9_ = __double_dup0 (&_tmp3_);
				g_array_append_val (_tmp8_, _tmp9_);
			}
		}
	}
}

guint
animator_callouts_length (AnimatorCallouts* self)
{
	GArray* _tmp0_;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->_nodes;
	result = _tmp0_->len;
	return result;
}

gdouble
animator_callouts_old_alpha (AnimatorCallouts* 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_callouts_new_alpha (AnimatorCallouts* 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_callouts_node (AnimatorCallouts* 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_callouts_class_init (AnimatorCalloutsClass * klass,
                              gpointer klass_data)
{
	animator_callouts_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AnimatorCallouts_private_offset);
	G_OBJECT_CLASS (klass)->finalize = animator_callouts_finalize;
}

static void
animator_callouts_instance_init (AnimatorCallouts * self,
                                 gpointer klass)
{
	self->priv = animator_callouts_get_instance_private (self);
}

static void
animator_callouts_finalize (GObject * obj)
{
	AnimatorCallouts * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_ANIMATOR_CALLOUTS, AnimatorCallouts);
	_g_array_unref0 (self->priv->_old_alpha);
	_g_array_unref0 (self->priv->_new_alpha);
	_g_array_unref0 (self->priv->_nodes);
	G_OBJECT_CLASS (animator_callouts_parent_class)->finalize (obj);
}

static GType
animator_callouts_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AnimatorCalloutsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) animator_callouts_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AnimatorCallouts), 0, (GInstanceInitFunc) animator_callouts_instance_init, NULL };
	GType animator_callouts_type_id;
	animator_callouts_type_id = g_type_register_static (G_TYPE_OBJECT, "AnimatorCallouts", &g_define_type_info, 0);
	AnimatorCallouts_private_offset = g_type_add_instance_private (animator_callouts_type_id, sizeof (AnimatorCalloutsPrivate));
	return animator_callouts_type_id;
}

GType
animator_callouts_get_type (void)
{
	static volatile gsize animator_callouts_type_id__once = 0;
	if (g_once_init_enter (&animator_callouts_type_id__once)) {
		GType animator_callouts_type_id;
		animator_callouts_type_id = animator_callouts_get_type_once ();
		g_once_init_leave (&animator_callouts_type_id__once, animator_callouts_type_id);
	}
	return animator_callouts_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;
}

