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

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
   This file is part of GNOME Reversi, also known as Iagno.

   Copyright 2026 Andrey Kutejko

   GNOME Reversi 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 3 of the License, or
   (at your option) any later version.

   GNOME Reversi 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 GNOME Reversi.  If not, see <https://www.gnu.org/licenses/>.
*/

#include <glib-object.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gtk/gtk.h>
#include <gsk/gsk.h>
#include <string.h>

#define ARROW_arrow_margin_top 3.0f
#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_ARROW (arrow_get_type ())
#define ARROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ARROW, Arrow))
#define ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ARROW, ArrowClass))
#define IS_ARROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ARROW))
#define IS_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ARROW))
#define ARROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ARROW, ArrowClass))

typedef struct _Arrow Arrow;
typedef struct _ArrowClass ArrowClass;
typedef struct _ArrowPrivate ArrowPrivate;
enum  {
	ARROW_0_PROPERTY,
	ARROW_NUM_PROPERTIES
};
static GParamSpec* arrow_properties[ARROW_NUM_PROPERTIES];
#define __vala_GskStroke_free0(var) ((var == NULL) ? NULL : (var = (_vala_GskStroke_free (var), NULL)))
#define _gsk_path_unref0(var) ((var == NULL) ? NULL : (var = (gsk_path_unref (var), NULL)))
#define _gsk_path_builder_unref0(var) ((var == NULL) ? NULL : (var = (gsk_path_builder_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _Arrow {
	GObject parent_instance;
	ArrowPrivate * priv;
};

struct _ArrowClass {
	GObjectClass parent_class;
};

static gpointer arrow_parent_class = NULL;
static GdkPaintableInterface * arrow_gdk_paintable_parent_iface = NULL;

VALA_EXTERN GType arrow_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Arrow, g_object_unref)
static void arrow_real_snapshot (GdkPaintable* base,
                          GdkSnapshot* gdk_snapshot,
                          gdouble width,
                          gdouble height);
static void _vala_GskStroke_free (GskStroke* self);
VALA_EXTERN Arrow* arrow_new (void);
VALA_EXTERN Arrow* arrow_construct (GType object_type);
static GType arrow_get_type_once (void);

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

static void
_vala_GskStroke_free (GskStroke* self)
{
	g_boxed_free (gsk_stroke_get_type (), self);
}

static void
arrow_real_snapshot (GdkPaintable* base,
                     GdkSnapshot* gdk_snapshot,
                     gdouble width,
                     gdouble height)
{
	Arrow * self;
	GtkSnapshot* snapshot = NULL;
	GtkSnapshot* _tmp0_;
	gfloat arrow_half_width = 0.0F;
	GskPathBuilder* builder = NULL;
	GskPathBuilder* _tmp1_;
	GskPath* path = NULL;
	GskPath* _tmp2_;
	GskStroke* stroke = NULL;
	GskStroke* _tmp3_;
	GdkRGBA _tmp4_ = {0};
	self = (Arrow*) base;
	g_return_if_fail (gdk_snapshot != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (gdk_snapshot, gtk_snapshot_get_type (), GtkSnapshot));
	snapshot = _tmp0_;
	gtk_snapshot_save (snapshot);
	arrow_half_width = ((gfloat) width) / 4.0f;
	_tmp1_ = gsk_path_builder_new ();
	builder = _tmp1_;
	gsk_path_builder_move_to (builder, arrow_half_width, ARROW_arrow_margin_top);
	gsk_path_builder_line_to (builder, 3.0f * arrow_half_width, ((gfloat) height) / 2.0f);
	gsk_path_builder_line_to (builder, arrow_half_width, ((gfloat) height) - ARROW_arrow_margin_top);
	_tmp2_ = gsk_path_builder_to_path (builder);
	path = _tmp2_;
	_tmp3_ = gsk_stroke_new ((gfloat) 2);
	stroke = _tmp3_;
	gsk_stroke_set_line_cap (stroke, GSK_LINE_CAP_ROUND);
	gsk_stroke_set_line_join (stroke, GSK_LINE_JOIN_ROUND);
	memset (&_tmp4_, 0, sizeof (GdkRGBA));
	_tmp4_.red = 0.5f;
	_tmp4_.green = 0.5f;
	_tmp4_.blue = 0.5f;
	_tmp4_.alpha = 1.0f;
	gtk_snapshot_append_stroke (snapshot, path, stroke, &_tmp4_);
	gtk_snapshot_restore (snapshot);
	__vala_GskStroke_free0 (stroke);
	_gsk_path_unref0 (path);
	_gsk_path_builder_unref0 (builder);
	_g_object_unref0 (snapshot);
}

Arrow*
arrow_construct (GType object_type)
{
	Arrow * self = NULL;
	self = (Arrow*) g_object_new (object_type, NULL);
	return self;
}

Arrow*
arrow_new (void)
{
	return arrow_construct (TYPE_ARROW);
}

static void
arrow_class_init (ArrowClass * klass,
                  gpointer klass_data)
{
	arrow_parent_class = g_type_class_peek_parent (klass);
}

static void
arrow_gdk_paintable_interface_init (GdkPaintableInterface * iface,
                                    gpointer iface_data)
{
	arrow_gdk_paintable_parent_iface = g_type_interface_peek_parent (iface);
	iface->snapshot = (void (*) (GdkPaintable*, GdkSnapshot*, gdouble, gdouble)) arrow_real_snapshot;
}

static void
arrow_instance_init (Arrow * self,
                     gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
arrow_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ArrowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) arrow_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Arrow), 0, (GInstanceInitFunc) arrow_instance_init, NULL };
	static const GInterfaceInfo gdk_paintable_info = { (GInterfaceInitFunc) arrow_gdk_paintable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType arrow_type_id;
	arrow_type_id = g_type_register_static (G_TYPE_OBJECT, "Arrow", &g_define_type_info, G_TYPE_FLAG_NONE);
	g_type_add_interface_static (arrow_type_id, gdk_paintable_get_type (), &gdk_paintable_info);
	return arrow_type_id;
}

GType
arrow_get_type (void)
{
	static gsize arrow_type_id__once = 0;
	if (g_once_init_enter (&arrow_type_id__once)) {
		GType arrow_type_id;
		arrow_type_id = arrow_get_type_once ();
		g_once_init_leave (&arrow_type_id__once, arrow_type_id);
	}
	return arrow_type_id__once;
}

