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

#include "livechart.h"
#include <glib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gobject/gvaluecollector.h>

#define _live_chart_coord_free0(var) ((var == NULL) ? NULL : (var = (live_chart_coord_free (var), NULL)))
typedef struct _LiveChartParamSpecRegion LiveChartParamSpecRegion;

struct _LiveChartRegionPrivate {
	gdouble ceil;
	gdouble floor;
	GdkRGBA _line_color;
	GdkRGBA _area_color;
};

struct _LiveChartParamSpecRegion {
	GParamSpec parent_instance;
};

static gint LiveChartRegion_private_offset;
static gpointer live_chart_region_parent_class = NULL;

static gboolean live_chart_region_enter_by_the_bottom (LiveChartRegion* self,
                                                LiveChartPoint* previous,
                                                LiveChartPoint* current);
static gboolean live_chart_region_enter_by_the_top (LiveChartRegion* self,
                                             LiveChartPoint* previous,
                                             LiveChartPoint* current);
static gboolean live_chart_region_leaving_by_the_top (LiveChartRegion* self,
                                               LiveChartPoint* previous,
                                               LiveChartPoint* current);
static gboolean live_chart_region_leaving_by_the_bottom (LiveChartRegion* self,
                                                  LiveChartPoint* previous,
                                                  LiveChartPoint* current);
static gboolean live_chart_region_is_within (LiveChartRegion* self,
                                      LiveChartPoint* previous,
                                      LiveChartPoint* current);
static void live_chart_region_finalize (LiveChartRegion * obj);
static GType live_chart_region_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
live_chart_region_handle_status_get_type_once (void)
{
	static const GEnumValue values[] = {{LIVE_CHART_REGION_HANDLE_STATUS_ENTER, "LIVE_CHART_REGION_HANDLE_STATUS_ENTER", "enter"}, {LIVE_CHART_REGION_HANDLE_STATUS_EXIT, "LIVE_CHART_REGION_HANDLE_STATUS_EXIT", "exit"}, {LIVE_CHART_REGION_HANDLE_STATUS_WITHIN, "LIVE_CHART_REGION_HANDLE_STATUS_WITHIN", "within"}, {LIVE_CHART_REGION_HANDLE_STATUS_OUT, "LIVE_CHART_REGION_HANDLE_STATUS_OUT", "out"}, {0, NULL, NULL}};
	GType live_chart_region_handle_status_type_id;
	live_chart_region_handle_status_type_id = g_enum_register_static ("LiveChartRegionHandleStatus", values);
	return live_chart_region_handle_status_type_id;
}

GType
live_chart_region_handle_status_get_type (void)
{
	static volatile gsize live_chart_region_handle_status_type_id__once = 0;
	if (g_once_init_enter (&live_chart_region_handle_status_type_id__once)) {
		GType live_chart_region_handle_status_type_id;
		live_chart_region_handle_status_type_id = live_chart_region_handle_status_get_type_once ();
		g_once_init_leave (&live_chart_region_handle_status_type_id__once, live_chart_region_handle_status_type_id);
	}
	return live_chart_region_handle_status_type_id__once;
}

LiveChartRegionHandleResult*
live_chart_region_handle_result_dup (const LiveChartRegionHandleResult* self)
{
	LiveChartRegionHandleResult* dup;
#line 11 "../src/region.vala"
	dup = g_new0 (LiveChartRegionHandleResult, 1);
#line 11 "../src/region.vala"
	memcpy (dup, self, sizeof (LiveChartRegionHandleResult));
#line 11 "../src/region.vala"
	return dup;
#line 81 "region.c"
}

void
live_chart_region_handle_result_free (LiveChartRegionHandleResult* self)
{
#line 11 "../src/region.vala"
	g_free (self);
#line 89 "region.c"
}

static GType
live_chart_region_handle_result_get_type_once (void)
{
	GType live_chart_region_handle_result_type_id;
	live_chart_region_handle_result_type_id = g_boxed_type_register_static ("LiveChartRegionHandleResult", (GBoxedCopyFunc) live_chart_region_handle_result_dup, (GBoxedFreeFunc) live_chart_region_handle_result_free);
	return live_chart_region_handle_result_type_id;
}

GType
live_chart_region_handle_result_get_type (void)
{
	static volatile gsize live_chart_region_handle_result_type_id__once = 0;
	if (g_once_init_enter (&live_chart_region_handle_result_type_id__once)) {
		GType live_chart_region_handle_result_type_id;
		live_chart_region_handle_result_type_id = live_chart_region_handle_result_get_type_once ();
		g_once_init_leave (&live_chart_region_handle_result_type_id__once, live_chart_region_handle_result_type_id);
	}
	return live_chart_region_handle_result_type_id__once;
}

static inline gpointer
live_chart_region_get_instance_private (LiveChartRegion* self)
{
	return G_STRUCT_MEMBER_P (self, LiveChartRegion_private_offset);
}

LiveChartRegion*
live_chart_region_construct (GType object_type,
                             gdouble floor,
                             gdouble ceil)
{
	LiveChartRegion* self = NULL;
#line 25 "../src/region.vala"
	self = (LiveChartRegion*) g_type_create_instance (object_type);
#line 26 "../src/region.vala"
	self->priv->floor = floor;
#line 27 "../src/region.vala"
	self->priv->ceil = ceil;
#line 25 "../src/region.vala"
	return self;
#line 132 "region.c"
}

LiveChartRegion*
live_chart_region_new (gdouble floor,
                       gdouble ceil)
{
#line 25 "../src/region.vala"
	return live_chart_region_construct (LIVE_CHART_TYPE_REGION, floor, ceil);
#line 141 "region.c"
}

LiveChartRegion*
live_chart_region_construct_between (GType object_type,
                                     gdouble above,
                                     gdouble below)
{
	LiveChartRegion* self = NULL;
#line 38 "../src/region.vala"
	self = (LiveChartRegion*) live_chart_region_construct (object_type, above, below);
#line 37 "../src/region.vala"
	return self;
#line 154 "region.c"
}

LiveChartRegion*
live_chart_region_new_between (gdouble above,
                               gdouble below)
{
#line 37 "../src/region.vala"
	return live_chart_region_construct_between (LIVE_CHART_TYPE_REGION, above, below);
#line 163 "region.c"
}

static gpointer
_live_chart_region_ref0 (gpointer self)
{
#line 43 "../src/region.vala"
	return self ? live_chart_region_ref (self) : NULL;
#line 171 "region.c"
}

LiveChartRegion*
live_chart_region_with_line_color (LiveChartRegion* self,
                                   GdkRGBA* color)
{
	GdkRGBA _tmp0_;
	LiveChartRegion* _tmp1_;
	LiveChartRegion* result;
#line 41 "../src/region.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 41 "../src/region.vala"
	g_return_val_if_fail (color != NULL, NULL);
#line 42 "../src/region.vala"
	_tmp0_ = *color;
#line 42 "../src/region.vala"
	live_chart_region_set_line_color (self, &_tmp0_);
#line 43 "../src/region.vala"
	_tmp1_ = _live_chart_region_ref0 (self);
#line 43 "../src/region.vala"
	result = _tmp1_;
#line 43 "../src/region.vala"
	return result;
#line 195 "region.c"
}

LiveChartRegion*
live_chart_region_with_area_color (LiveChartRegion* self,
                                   GdkRGBA* color)
{
	GdkRGBA _tmp0_;
	LiveChartRegion* _tmp1_;
	LiveChartRegion* result;
#line 45 "../src/region.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 45 "../src/region.vala"
	g_return_val_if_fail (color != NULL, NULL);
#line 46 "../src/region.vala"
	_tmp0_ = *color;
#line 46 "../src/region.vala"
	live_chart_region_set_area_color (self, &_tmp0_);
#line 47 "../src/region.vala"
	_tmp1_ = _live_chart_region_ref0 (self);
#line 47 "../src/region.vala"
	result = _tmp1_;
#line 47 "../src/region.vala"
	return result;
#line 219 "region.c"
}

gboolean
live_chart_region_has_at_least_one_point_within (LiveChartRegion* self,
                                                 LiveChartPoint* previous,
                                                 LiveChartPoint* current)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	LiveChartPoint _tmp2_;
	LiveChartTimestampedValue _tmp3_;
	gboolean result;
#line 50 "../src/region.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 50 "../src/region.vala"
	g_return_val_if_fail (previous != NULL, FALSE);
#line 50 "../src/region.vala"
	g_return_val_if_fail (current != NULL, FALSE);
#line 51 "../src/region.vala"
	_tmp2_ = *previous;
#line 51 "../src/region.vala"
	_tmp3_ = _tmp2_.data;
#line 51 "../src/region.vala"
	if (_tmp3_.value > self->priv->floor) {
#line 244 "region.c"
		LiveChartPoint _tmp4_;
		LiveChartTimestampedValue _tmp5_;
#line 51 "../src/region.vala"
		_tmp4_ = *previous;
#line 51 "../src/region.vala"
		_tmp5_ = _tmp4_.data;
#line 51 "../src/region.vala"
		_tmp1_ = _tmp5_.value <= self->priv->ceil;
#line 253 "region.c"
	} else {
#line 51 "../src/region.vala"
		_tmp1_ = FALSE;
#line 257 "region.c"
	}
#line 51 "../src/region.vala"
	if (_tmp1_) {
#line 51 "../src/region.vala"
		_tmp0_ = TRUE;
#line 263 "region.c"
	} else {
		gboolean _tmp6_ = FALSE;
		LiveChartPoint _tmp7_;
		LiveChartTimestampedValue _tmp8_;
#line 51 "../src/region.vala"
		_tmp7_ = *current;
#line 51 "../src/region.vala"
		_tmp8_ = _tmp7_.data;
#line 51 "../src/region.vala"
		if (_tmp8_.value > self->priv->floor) {
#line 274 "region.c"
			LiveChartPoint _tmp9_;
			LiveChartTimestampedValue _tmp10_;
#line 51 "../src/region.vala"
			_tmp9_ = *current;
#line 51 "../src/region.vala"
			_tmp10_ = _tmp9_.data;
#line 51 "../src/region.vala"
			_tmp6_ = _tmp10_.value <= self->priv->ceil;
#line 283 "region.c"
		} else {
#line 51 "../src/region.vala"
			_tmp6_ = FALSE;
#line 287 "region.c"
		}
#line 51 "../src/region.vala"
		_tmp0_ = _tmp6_;
#line 291 "region.c"
	}
#line 51 "../src/region.vala"
	result = _tmp0_;
#line 51 "../src/region.vala"
	return result;
#line 297 "region.c"
}

void
live_chart_region_handle (LiveChartRegion* self,
                          LiveChartIntersections* intersections,
                          LiveChartPoint* previous,
                          LiveChartPoint* current,
                          LiveChartGetIntersection get_intersection,
                          gpointer get_intersection_target)
{
	LiveChartPoint _tmp0_;
	LiveChartPoint _tmp1_;
#line 54 "../src/region.vala"
	g_return_if_fail (self != NULL);
#line 54 "../src/region.vala"
	g_return_if_fail (intersections != NULL);
#line 54 "../src/region.vala"
	g_return_if_fail (previous != NULL);
#line 54 "../src/region.vala"
	g_return_if_fail (current != NULL);
#line 55 "../src/region.vala"
	_tmp0_ = *previous;
#line 55 "../src/region.vala"
	_tmp1_ = *current;
#line 55 "../src/region.vala"
	if (live_chart_region_has_at_least_one_point_within (self, &_tmp0_, &_tmp1_)) {
#line 324 "region.c"
		LiveChartPoint _tmp2_;
		LiveChartPoint _tmp3_;
		LiveChartPoint _tmp7_;
		LiveChartPoint _tmp8_;
		LiveChartPoint _tmp12_;
		LiveChartPoint _tmp13_;
		LiveChartPoint _tmp18_;
		LiveChartPoint _tmp19_;
		LiveChartPoint _tmp24_;
		LiveChartPoint _tmp25_;
#line 56 "../src/region.vala"
		_tmp2_ = *previous;
#line 56 "../src/region.vala"
		_tmp3_ = *current;
#line 56 "../src/region.vala"
		if (live_chart_region_enter_by_the_bottom (self, &_tmp2_, &_tmp3_)) {
#line 341 "region.c"
			gdouble entered_at = 0.0;
			LiveChartCoord* coords = NULL;
			LiveChartCoord* _tmp4_;
#line 57 "../src/region.vala"
			entered_at = self->priv->floor;
#line 58 "../src/region.vala"
			_tmp4_ = get_intersection (entered_at, get_intersection_target);
#line 58 "../src/region.vala"
			coords = _tmp4_;
#line 59 "../src/region.vala"
			if (live_chart_intersections_has_an_opened_intersection (intersections)) {
#line 353 "region.c"
				LiveChartPoint _tmp5_;
#line 60 "../src/region.vala"
				_tmp5_ = *current;
#line 60 "../src/region.vala"
				live_chart_intersections_update (intersections, _tmp5_.x);
#line 359 "region.c"
			} else {
				LiveChartCoord* _tmp6_;
#line 62 "../src/region.vala"
				_tmp6_ = coords;
#line 62 "../src/region.vala"
				live_chart_intersections_open (intersections, self, (*_tmp6_).x, entered_at);
#line 366 "region.c"
			}
#line 56 "../src/region.vala"
			_live_chart_coord_free0 (coords);
#line 370 "region.c"
		}
#line 65 "../src/region.vala"
		_tmp7_ = *previous;
#line 65 "../src/region.vala"
		_tmp8_ = *current;
#line 65 "../src/region.vala"
		if (live_chart_region_enter_by_the_top (self, &_tmp7_, &_tmp8_)) {
#line 378 "region.c"
			gdouble entered_at = 0.0;
			LiveChartCoord* coords = NULL;
			LiveChartCoord* _tmp9_;
#line 67 "../src/region.vala"
			entered_at = self->priv->ceil;
#line 68 "../src/region.vala"
			_tmp9_ = get_intersection (entered_at, get_intersection_target);
#line 68 "../src/region.vala"
			coords = _tmp9_;
#line 70 "../src/region.vala"
			if (live_chart_intersections_has_an_opened_intersection (intersections)) {
#line 390 "region.c"
				LiveChartPoint _tmp10_;
#line 71 "../src/region.vala"
				_tmp10_ = *current;
#line 71 "../src/region.vala"
				live_chart_intersections_update (intersections, _tmp10_.x);
#line 396 "region.c"
			} else {
				LiveChartCoord* _tmp11_;
#line 73 "../src/region.vala"
				_tmp11_ = coords;
#line 73 "../src/region.vala"
				live_chart_intersections_open (intersections, self, (*_tmp11_).x, entered_at);
#line 403 "region.c"
			}
#line 65 "../src/region.vala"
			_live_chart_coord_free0 (coords);
#line 407 "region.c"
		}
#line 77 "../src/region.vala"
		_tmp12_ = *previous;
#line 77 "../src/region.vala"
		_tmp13_ = *current;
#line 77 "../src/region.vala"
		if (live_chart_region_leaving_by_the_top (self, &_tmp12_, &_tmp13_)) {
#line 415 "region.c"
			gdouble exited_at = 0.0;
			LiveChartCoord* coords = NULL;
			LiveChartCoord* _tmp14_;
#line 78 "../src/region.vala"
			exited_at = self->priv->ceil;
#line 79 "../src/region.vala"
			_tmp14_ = get_intersection (exited_at, get_intersection_target);
#line 79 "../src/region.vala"
			coords = _tmp14_;
#line 81 "../src/region.vala"
			if (live_chart_intersections_has_an_opened_intersection (intersections)) {
#line 427 "region.c"
				LiveChartCoord* _tmp15_;
#line 82 "../src/region.vala"
				_tmp15_ = coords;
#line 82 "../src/region.vala"
				live_chart_intersections_close (intersections, (*_tmp15_).x, exited_at);
#line 433 "region.c"
			} else {
				LiveChartPoint _tmp16_;
				LiveChartCoord* _tmp17_;
#line 84 "../src/region.vala"
				_tmp16_ = *previous;
#line 84 "../src/region.vala"
				live_chart_intersections_open_without_entrypoint (intersections, self, _tmp16_.x);
#line 85 "../src/region.vala"
				_tmp17_ = coords;
#line 85 "../src/region.vala"
				live_chart_intersections_close (intersections, (*_tmp17_).x, exited_at);
#line 445 "region.c"
			}
#line 77 "../src/region.vala"
			_live_chart_coord_free0 (coords);
#line 449 "region.c"
		}
#line 88 "../src/region.vala"
		_tmp18_ = *previous;
#line 88 "../src/region.vala"
		_tmp19_ = *current;
#line 88 "../src/region.vala"
		if (live_chart_region_leaving_by_the_bottom (self, &_tmp18_, &_tmp19_)) {
#line 457 "region.c"
			gdouble exited_at = 0.0;
			LiveChartCoord* coords = NULL;
			LiveChartCoord* _tmp20_;
#line 89 "../src/region.vala"
			exited_at = self->priv->floor;
#line 90 "../src/region.vala"
			_tmp20_ = get_intersection (exited_at, get_intersection_target);
#line 90 "../src/region.vala"
			coords = _tmp20_;
#line 92 "../src/region.vala"
			if (live_chart_intersections_has_an_opened_intersection (intersections)) {
#line 469 "region.c"
				LiveChartCoord* _tmp21_;
#line 93 "../src/region.vala"
				_tmp21_ = coords;
#line 93 "../src/region.vala"
				live_chart_intersections_close (intersections, (*_tmp21_).x, exited_at);
#line 475 "region.c"
			} else {
				LiveChartPoint _tmp22_;
				LiveChartCoord* _tmp23_;
#line 95 "../src/region.vala"
				_tmp22_ = *previous;
#line 95 "../src/region.vala"
				live_chart_intersections_open_without_entrypoint (intersections, self, _tmp22_.x);
#line 96 "../src/region.vala"
				_tmp23_ = coords;
#line 96 "../src/region.vala"
				live_chart_intersections_close (intersections, (*_tmp23_).x, exited_at);
#line 487 "region.c"
			}
#line 88 "../src/region.vala"
			_live_chart_coord_free0 (coords);
#line 491 "region.c"
		}
#line 99 "../src/region.vala"
		_tmp24_ = *previous;
#line 99 "../src/region.vala"
		_tmp25_ = *current;
#line 99 "../src/region.vala"
		if (live_chart_region_is_within (self, &_tmp24_, &_tmp25_)) {
#line 100 "../src/region.vala"
			if (!live_chart_intersections_has_an_opened_intersection (intersections)) {
#line 501 "region.c"
				LiveChartPoint _tmp26_;
#line 101 "../src/region.vala"
				_tmp26_ = *previous;
#line 101 "../src/region.vala"
				live_chart_intersections_open_without_entrypoint (intersections, self, _tmp26_.x);
#line 507 "region.c"
			} else {
				LiveChartPoint _tmp27_;
#line 103 "../src/region.vala"
				_tmp27_ = *current;
#line 103 "../src/region.vala"
				live_chart_intersections_update (intersections, _tmp27_.x);
#line 514 "region.c"
			}
		}
	}
}

static gboolean
live_chart_region_enter_by_the_bottom (LiveChartRegion* self,
                                       LiveChartPoint* previous,
                                       LiveChartPoint* current)
{
	gboolean _tmp0_ = FALSE;
	LiveChartPoint _tmp1_;
	LiveChartTimestampedValue _tmp2_;
	gboolean result;
#line 109 "../src/region.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 109 "../src/region.vala"
	g_return_val_if_fail (previous != NULL, FALSE);
#line 109 "../src/region.vala"
	g_return_val_if_fail (current != NULL, FALSE);
#line 110 "../src/region.vala"
	_tmp1_ = *previous;
#line 110 "../src/region.vala"
	_tmp2_ = _tmp1_.data;
#line 110 "../src/region.vala"
	if (_tmp2_.value <= self->priv->floor) {
#line 541 "region.c"
		LiveChartPoint _tmp3_;
		LiveChartTimestampedValue _tmp4_;
#line 110 "../src/region.vala"
		_tmp3_ = *current;
#line 110 "../src/region.vala"
		_tmp4_ = _tmp3_.data;
#line 110 "../src/region.vala"
		_tmp0_ = _tmp4_.value > self->priv->floor;
#line 550 "region.c"
	} else {
#line 110 "../src/region.vala"
		_tmp0_ = FALSE;
#line 554 "region.c"
	}
#line 110 "../src/region.vala"
	result = _tmp0_;
#line 110 "../src/region.vala"
	return result;
#line 560 "region.c"
}

static gboolean
live_chart_region_enter_by_the_top (LiveChartRegion* self,
                                    LiveChartPoint* previous,
                                    LiveChartPoint* current)
{
	gboolean _tmp0_ = FALSE;
	LiveChartPoint _tmp1_;
	LiveChartTimestampedValue _tmp2_;
	gboolean result;
#line 113 "../src/region.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 113 "../src/region.vala"
	g_return_val_if_fail (previous != NULL, FALSE);
#line 113 "../src/region.vala"
	g_return_val_if_fail (current != NULL, FALSE);
#line 114 "../src/region.vala"
	_tmp1_ = *previous;
#line 114 "../src/region.vala"
	_tmp2_ = _tmp1_.data;
#line 114 "../src/region.vala"
	if (_tmp2_.value >= self->priv->ceil) {
#line 584 "region.c"
		LiveChartPoint _tmp3_;
		LiveChartTimestampedValue _tmp4_;
#line 114 "../src/region.vala"
		_tmp3_ = *current;
#line 114 "../src/region.vala"
		_tmp4_ = _tmp3_.data;
#line 114 "../src/region.vala"
		_tmp0_ = _tmp4_.value < self->priv->ceil;
#line 593 "region.c"
	} else {
#line 114 "../src/region.vala"
		_tmp0_ = FALSE;
#line 597 "region.c"
	}
#line 114 "../src/region.vala"
	result = _tmp0_;
#line 114 "../src/region.vala"
	return result;
#line 603 "region.c"
}

static gboolean
live_chart_region_leaving_by_the_top (LiveChartRegion* self,
                                      LiveChartPoint* previous,
                                      LiveChartPoint* current)
{
	gboolean _tmp0_ = FALSE;
	LiveChartPoint _tmp1_;
	LiveChartTimestampedValue _tmp2_;
	gboolean result;
#line 117 "../src/region.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 117 "../src/region.vala"
	g_return_val_if_fail (previous != NULL, FALSE);
#line 117 "../src/region.vala"
	g_return_val_if_fail (current != NULL, FALSE);
#line 118 "../src/region.vala"
	_tmp1_ = *previous;
#line 118 "../src/region.vala"
	_tmp2_ = _tmp1_.data;
#line 118 "../src/region.vala"
	if (_tmp2_.value >= self->priv->floor) {
#line 627 "region.c"
		LiveChartPoint _tmp3_;
		LiveChartTimestampedValue _tmp4_;
#line 118 "../src/region.vala"
		_tmp3_ = *current;
#line 118 "../src/region.vala"
		_tmp4_ = _tmp3_.data;
#line 118 "../src/region.vala"
		_tmp0_ = _tmp4_.value > self->priv->ceil;
#line 636 "region.c"
	} else {
#line 118 "../src/region.vala"
		_tmp0_ = FALSE;
#line 640 "region.c"
	}
#line 118 "../src/region.vala"
	result = _tmp0_;
#line 118 "../src/region.vala"
	return result;
#line 646 "region.c"
}

static gboolean
live_chart_region_leaving_by_the_bottom (LiveChartRegion* self,
                                         LiveChartPoint* previous,
                                         LiveChartPoint* current)
{
	gboolean _tmp0_ = FALSE;
	LiveChartPoint _tmp1_;
	LiveChartTimestampedValue _tmp2_;
	gboolean result;
#line 121 "../src/region.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 121 "../src/region.vala"
	g_return_val_if_fail (previous != NULL, FALSE);
#line 121 "../src/region.vala"
	g_return_val_if_fail (current != NULL, FALSE);
#line 122 "../src/region.vala"
	_tmp1_ = *previous;
#line 122 "../src/region.vala"
	_tmp2_ = _tmp1_.data;
#line 122 "../src/region.vala"
	if (_tmp2_.value >= self->priv->floor) {
#line 670 "region.c"
		LiveChartPoint _tmp3_;
		LiveChartTimestampedValue _tmp4_;
#line 122 "../src/region.vala"
		_tmp3_ = *current;
#line 122 "../src/region.vala"
		_tmp4_ = _tmp3_.data;
#line 122 "../src/region.vala"
		_tmp0_ = _tmp4_.value < self->priv->floor;
#line 679 "region.c"
	} else {
#line 122 "../src/region.vala"
		_tmp0_ = FALSE;
#line 683 "region.c"
	}
#line 122 "../src/region.vala"
	result = _tmp0_;
#line 122 "../src/region.vala"
	return result;
#line 689 "region.c"
}

static gboolean
live_chart_region_is_within (LiveChartRegion* self,
                             LiveChartPoint* previous,
                             LiveChartPoint* current)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	LiveChartPoint _tmp3_;
	LiveChartTimestampedValue _tmp4_;
	gboolean result;
#line 125 "../src/region.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 125 "../src/region.vala"
	g_return_val_if_fail (previous != NULL, FALSE);
#line 125 "../src/region.vala"
	g_return_val_if_fail (current != NULL, FALSE);
#line 126 "../src/region.vala"
	_tmp3_ = *previous;
#line 126 "../src/region.vala"
	_tmp4_ = _tmp3_.data;
#line 126 "../src/region.vala"
	if (_tmp4_.value >= self->priv->floor) {
#line 715 "region.c"
		LiveChartPoint _tmp5_;
		LiveChartTimestampedValue _tmp6_;
#line 126 "../src/region.vala"
		_tmp5_ = *current;
#line 126 "../src/region.vala"
		_tmp6_ = _tmp5_.data;
#line 126 "../src/region.vala"
		_tmp2_ = _tmp6_.value > self->priv->floor;
#line 724 "region.c"
	} else {
#line 126 "../src/region.vala"
		_tmp2_ = FALSE;
#line 728 "region.c"
	}
#line 126 "../src/region.vala"
	if (_tmp2_) {
#line 732 "region.c"
		LiveChartPoint _tmp7_;
		LiveChartTimestampedValue _tmp8_;
#line 126 "../src/region.vala"
		_tmp7_ = *previous;
#line 126 "../src/region.vala"
		_tmp8_ = _tmp7_.data;
#line 126 "../src/region.vala"
		_tmp1_ = _tmp8_.value < self->priv->ceil;
#line 741 "region.c"
	} else {
#line 126 "../src/region.vala"
		_tmp1_ = FALSE;
#line 745 "region.c"
	}
#line 126 "../src/region.vala"
	if (_tmp1_) {
#line 749 "region.c"
		LiveChartPoint _tmp9_;
		LiveChartTimestampedValue _tmp10_;
#line 126 "../src/region.vala"
		_tmp9_ = *current;
#line 126 "../src/region.vala"
		_tmp10_ = _tmp9_.data;
#line 126 "../src/region.vala"
		_tmp0_ = _tmp10_.value < self->priv->ceil;
#line 758 "region.c"
	} else {
#line 126 "../src/region.vala"
		_tmp0_ = FALSE;
#line 762 "region.c"
	}
#line 126 "../src/region.vala"
	result = _tmp0_;
#line 126 "../src/region.vala"
	return result;
#line 768 "region.c"
}

void
live_chart_region_get_line_color (LiveChartRegion* self,
                                  GdkRGBA * result)
{
	GdkRGBA _tmp0_;
#line 22 "../src/region.vala"
	g_return_if_fail (self != NULL);
#line 22 "../src/region.vala"
	_tmp0_ = self->priv->_line_color;
#line 22 "../src/region.vala"
	*result = _tmp0_;
#line 22 "../src/region.vala"
	return;
#line 784 "region.c"
}

void
live_chart_region_set_line_color (LiveChartRegion* self,
                                  GdkRGBA * value)
{
	GdkRGBA _tmp0_;
#line 22 "../src/region.vala"
	g_return_if_fail (self != NULL);
#line 22 "../src/region.vala"
	_tmp0_ = *value;
#line 22 "../src/region.vala"
	self->priv->_line_color = _tmp0_;
#line 798 "region.c"
}

void
live_chart_region_get_area_color (LiveChartRegion* self,
                                  GdkRGBA * result)
{
	GdkRGBA _tmp0_;
#line 23 "../src/region.vala"
	g_return_if_fail (self != NULL);
#line 23 "../src/region.vala"
	_tmp0_ = self->priv->_area_color;
#line 23 "../src/region.vala"
	*result = _tmp0_;
#line 23 "../src/region.vala"
	return;
#line 814 "region.c"
}

void
live_chart_region_set_area_color (LiveChartRegion* self,
                                  GdkRGBA * value)
{
	GdkRGBA _tmp0_;
#line 23 "../src/region.vala"
	g_return_if_fail (self != NULL);
#line 23 "../src/region.vala"
	_tmp0_ = *value;
#line 23 "../src/region.vala"
	self->priv->_area_color = _tmp0_;
#line 828 "region.c"
}

static void
live_chart_value_region_init (GValue* value)
{
#line 18 "../src/region.vala"
	value->data[0].v_pointer = NULL;
#line 836 "region.c"
}

static void
live_chart_value_region_free_value (GValue* value)
{
#line 18 "../src/region.vala"
	if (value->data[0].v_pointer) {
#line 18 "../src/region.vala"
		live_chart_region_unref (value->data[0].v_pointer);
#line 846 "region.c"
	}
}

static void
live_chart_value_region_copy_value (const GValue* src_value,
                                    GValue* dest_value)
{
#line 18 "../src/region.vala"
	if (src_value->data[0].v_pointer) {
#line 18 "../src/region.vala"
		dest_value->data[0].v_pointer = live_chart_region_ref (src_value->data[0].v_pointer);
#line 858 "region.c"
	} else {
#line 18 "../src/region.vala"
		dest_value->data[0].v_pointer = NULL;
#line 862 "region.c"
	}
}

static gpointer
live_chart_value_region_peek_pointer (const GValue* value)
{
#line 18 "../src/region.vala"
	return value->data[0].v_pointer;
#line 871 "region.c"
}

static gchar*
live_chart_value_region_collect_value (GValue* value,
                                       guint n_collect_values,
                                       GTypeCValue* collect_values,
                                       guint collect_flags)
{
#line 18 "../src/region.vala"
	if (collect_values[0].v_pointer) {
#line 882 "region.c"
		LiveChartRegion * object;
		object = collect_values[0].v_pointer;
#line 18 "../src/region.vala"
		if (object->parent_instance.g_class == NULL) {
#line 18 "../src/region.vala"
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 889 "region.c"
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
#line 18 "../src/region.vala"
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 893 "region.c"
		}
#line 18 "../src/region.vala"
		value->data[0].v_pointer = live_chart_region_ref (object);
#line 897 "region.c"
	} else {
#line 18 "../src/region.vala"
		value->data[0].v_pointer = NULL;
#line 901 "region.c"
	}
#line 18 "../src/region.vala"
	return NULL;
#line 905 "region.c"
}

static gchar*
live_chart_value_region_lcopy_value (const GValue* value,
                                     guint n_collect_values,
                                     GTypeCValue* collect_values,
                                     guint collect_flags)
{
	LiveChartRegion ** object_p;
	object_p = collect_values[0].v_pointer;
#line 18 "../src/region.vala"
	if (!object_p) {
#line 18 "../src/region.vala"
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
#line 920 "region.c"
	}
#line 18 "../src/region.vala"
	if (!value->data[0].v_pointer) {
#line 18 "../src/region.vala"
		*object_p = NULL;
#line 926 "region.c"
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
#line 18 "../src/region.vala"
		*object_p = value->data[0].v_pointer;
#line 930 "region.c"
	} else {
#line 18 "../src/region.vala"
		*object_p = live_chart_region_ref (value->data[0].v_pointer);
#line 934 "region.c"
	}
#line 18 "../src/region.vala"
	return NULL;
#line 938 "region.c"
}

GParamSpec*
live_chart_param_spec_region (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags)
{
	LiveChartParamSpecRegion* spec;
#line 18 "../src/region.vala"
	g_return_val_if_fail (g_type_is_a (object_type, LIVE_CHART_TYPE_REGION), NULL);
#line 18 "../src/region.vala"
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
#line 18 "../src/region.vala"
	G_PARAM_SPEC (spec)->value_type = object_type;
#line 18 "../src/region.vala"
	return G_PARAM_SPEC (spec);
#line 957 "region.c"
}

gpointer
live_chart_value_get_region (const GValue* value)
{
#line 18 "../src/region.vala"
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, LIVE_CHART_TYPE_REGION), NULL);
#line 18 "../src/region.vala"
	return value->data[0].v_pointer;
#line 967 "region.c"
}

void
live_chart_value_set_region (GValue* value,
                             gpointer v_object)
{
	LiveChartRegion * old;
#line 18 "../src/region.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, LIVE_CHART_TYPE_REGION));
#line 18 "../src/region.vala"
	old = value->data[0].v_pointer;
#line 18 "../src/region.vala"
	if (v_object) {
#line 18 "../src/region.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, LIVE_CHART_TYPE_REGION));
#line 18 "../src/region.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 18 "../src/region.vala"
		value->data[0].v_pointer = v_object;
#line 18 "../src/region.vala"
		live_chart_region_ref (value->data[0].v_pointer);
#line 989 "region.c"
	} else {
#line 18 "../src/region.vala"
		value->data[0].v_pointer = NULL;
#line 993 "region.c"
	}
#line 18 "../src/region.vala"
	if (old) {
#line 18 "../src/region.vala"
		live_chart_region_unref (old);
#line 999 "region.c"
	}
}

void
live_chart_value_take_region (GValue* value,
                              gpointer v_object)
{
	LiveChartRegion * old;
#line 18 "../src/region.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, LIVE_CHART_TYPE_REGION));
#line 18 "../src/region.vala"
	old = value->data[0].v_pointer;
#line 18 "../src/region.vala"
	if (v_object) {
#line 18 "../src/region.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, LIVE_CHART_TYPE_REGION));
#line 18 "../src/region.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 18 "../src/region.vala"
		value->data[0].v_pointer = v_object;
#line 1020 "region.c"
	} else {
#line 18 "../src/region.vala"
		value->data[0].v_pointer = NULL;
#line 1024 "region.c"
	}
#line 18 "../src/region.vala"
	if (old) {
#line 18 "../src/region.vala"
		live_chart_region_unref (old);
#line 1030 "region.c"
	}
}

static void
live_chart_region_class_init (LiveChartRegionClass * klass,
                              gpointer klass_data)
{
#line 18 "../src/region.vala"
	live_chart_region_parent_class = g_type_class_peek_parent (klass);
#line 18 "../src/region.vala"
	((LiveChartRegionClass *) klass)->finalize = live_chart_region_finalize;
#line 18 "../src/region.vala"
	g_type_class_adjust_private_offset (klass, &LiveChartRegion_private_offset);
#line 1044 "region.c"
}

static void
live_chart_region_instance_init (LiveChartRegion * self,
                                 gpointer klass)
{
	GdkRGBA _tmp0_ = {0};
	GdkRGBA _tmp1_ = {0};
#line 18 "../src/region.vala"
	self->priv = live_chart_region_get_instance_private (self);
#line 22 "../src/region.vala"
	memset (&_tmp0_, 0, sizeof (GdkRGBA));
#line 22 "../src/region.vala"
	_tmp0_.red = (gdouble) 1;
#line 22 "../src/region.vala"
	_tmp0_.green = (gdouble) 1;
#line 22 "../src/region.vala"
	_tmp0_.blue = (gdouble) 1;
#line 22 "../src/region.vala"
	_tmp0_.alpha = (gdouble) 1;
#line 22 "../src/region.vala"
	self->priv->_line_color = _tmp0_;
#line 23 "../src/region.vala"
	memset (&_tmp1_, 0, sizeof (GdkRGBA));
#line 23 "../src/region.vala"
	_tmp1_.red = (gdouble) 1;
#line 23 "../src/region.vala"
	_tmp1_.green = (gdouble) 1;
#line 23 "../src/region.vala"
	_tmp1_.blue = (gdouble) 1;
#line 23 "../src/region.vala"
	_tmp1_.alpha = 0.5;
#line 23 "../src/region.vala"
	self->priv->_area_color = _tmp1_;
#line 18 "../src/region.vala"
	self->ref_count = 1;
#line 1081 "region.c"
}

static void
live_chart_region_finalize (LiveChartRegion * obj)
{
	LiveChartRegion * self;
#line 18 "../src/region.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, LIVE_CHART_TYPE_REGION, LiveChartRegion);
#line 18 "../src/region.vala"
	g_signal_handlers_destroy (self);
#line 1092 "region.c"
}

static GType
live_chart_region_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { live_chart_value_region_init, live_chart_value_region_free_value, live_chart_value_region_copy_value, live_chart_value_region_peek_pointer, "p", live_chart_value_region_collect_value, "p", live_chart_value_region_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (LiveChartRegionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) live_chart_region_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LiveChartRegion), 0, (GInstanceInitFunc) live_chart_region_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType live_chart_region_type_id;
	live_chart_region_type_id = g_type_register_fundamental (g_type_fundamental_next (), "LiveChartRegion", &g_define_type_info, &g_define_type_fundamental_info, 0);
	LiveChartRegion_private_offset = g_type_add_instance_private (live_chart_region_type_id, sizeof (LiveChartRegionPrivate));
	return live_chart_region_type_id;
}

GType
live_chart_region_get_type (void)
{
	static volatile gsize live_chart_region_type_id__once = 0;
	if (g_once_init_enter (&live_chart_region_type_id__once)) {
		GType live_chart_region_type_id;
		live_chart_region_type_id = live_chart_region_get_type_once ();
		g_once_init_leave (&live_chart_region_type_id__once, live_chart_region_type_id);
	}
	return live_chart_region_type_id__once;
}

gpointer
live_chart_region_ref (gpointer instance)
{
	LiveChartRegion * self;
	self = instance;
#line 18 "../src/region.vala"
	g_atomic_int_inc (&self->ref_count);
#line 18 "../src/region.vala"
	return instance;
#line 1128 "region.c"
}

void
live_chart_region_unref (gpointer instance)
{
	LiveChartRegion * self;
	self = instance;
#line 18 "../src/region.vala"
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
#line 18 "../src/region.vala"
		LIVE_CHART_REGION_GET_CLASS (self)->finalize (self);
#line 18 "../src/region.vala"
		g_type_free_instance ((GTypeInstance *) self);
#line 1142 "region.c"
	}
}

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

