/* Layout.c generated by valac 0.56.19, the Vala compiler
 * generated from Layout.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 <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.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_LAYOUT (layout_get_type ())
#define LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LAYOUT, Layout))
#define LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LAYOUT, LayoutClass))
#define IS_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LAYOUT))
#define IS_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LAYOUT))
#define LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LAYOUT, LayoutClass))

typedef struct _Layout Layout;
typedef struct _LayoutClass LayoutClass;
typedef struct _LayoutPrivate LayoutPrivate;
typedef enum  {
	NODE_SIDE_LEFT = 1,
	NODE_SIDE_TOP = 2,
	NODE_SIDE_RIGHT = 4,
	NODE_SIDE_BOTTOM = 8
} NodeSide;

#define TYPE_NODE_SIDE (node_side_get_type ())

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

#define TYPE_NODE_BOUNDS (node_bounds_get_type ())
#define NODE_BOUNDS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE_BOUNDS, NodeBounds))
#define NODE_BOUNDS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE_BOUNDS, NodeBoundsClass))
#define IS_NODE_BOUNDS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE_BOUNDS))
#define IS_NODE_BOUNDS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE_BOUNDS))
#define NODE_BOUNDS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE_BOUNDS, NodeBoundsClass))

typedef struct _NodeBounds NodeBounds;
typedef struct _NodeBoundsClass NodeBoundsClass;
enum  {
	LAYOUT_0_PROPERTY,
	LAYOUT_NAME_PROPERTY,
	LAYOUT_LIGHT_ICON_PROPERTY,
	LAYOUT_DARK_ICON_PROPERTY,
	LAYOUT_BALANCEABLE_PROPERTY,
	LAYOUT_NUM_PROPERTIES
};
static GParamSpec* layout_properties[LAYOUT_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block29Data Block29Data;
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

#define TYPE_MIND_MAP (mind_map_get_type ())
#define MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MIND_MAP, MindMap))
#define MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MIND_MAP, MindMapClass))
#define IS_MIND_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MIND_MAP))
#define IS_MIND_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MIND_MAP))
#define MIND_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MIND_MAP, MindMapClass))

typedef struct _MindMap MindMap;
typedef struct _MindMapClass MindMapClass;
#define _node_bounds_unref0(var) ((var == NULL) ? NULL : (var = (node_bounds_unref (var), NULL)))

#define TYPE_SUMMARY_NODE (summary_node_get_type ())
#define SUMMARY_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SUMMARY_NODE, SummaryNode))
#define SUMMARY_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SUMMARY_NODE, SummaryNodeClass))
#define IS_SUMMARY_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SUMMARY_NODE))
#define IS_SUMMARY_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SUMMARY_NODE))
#define SUMMARY_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SUMMARY_NODE, SummaryNodeClass))

typedef struct _SummaryNode SummaryNode;
typedef struct _SummaryNodeClass SummaryNodeClass;

#define TYPE_MAP_MODEL (map_model_get_type ())
#define MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAP_MODEL, MapModel))
#define MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAP_MODEL, MapModelClass))
#define IS_MAP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAP_MODEL))
#define IS_MAP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAP_MODEL))
#define MAP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAP_MODEL, MapModelClass))

typedef struct _MapModel MapModel;
typedef struct _MapModelClass MapModelClass;

#define TYPE_STYLE (style_get_type ())
#define STYLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_STYLE, Style))
#define STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_STYLE, StyleClass))
#define IS_STYLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_STYLE))
#define IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_STYLE))
#define STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_STYLE, StyleClass))

typedef struct _Style Style;
typedef struct _StyleClass StyleClass;

struct _Layout {
	GObject parent_instance;
	LayoutPrivate * priv;
	gdouble _rt_gap;
};

struct _LayoutClass {
	GObjectClass parent_class;
	gboolean (*is_manual) (Layout* self);
	NodeSide (*side_mapping) (Layout* self, NodeSide side);
	void (*initialize) (Layout* self, Node* parent);
	NodeBounds* (*bbox) (Layout* self, Node* parent, gint side_mask, const gchar* msg);
	void (*adjust_tree) (Layout* self, Node* parent, gint child_index, gint side_mask, gdouble amount);
	void (*adjust_tree_all) (Layout* self, Node* n, NodeBounds* p, gdouble amount, const gchar* msg);
	void (*propagate_side) (Layout* self, Node* parent, NodeSide side);
	NodeSide (*get_side) (Layout* self, Node* n);
	void (*set_side) (Layout* self, Node* current);
	void (*handle_update_by_edit) (Layout* self, Node* n, gdouble diffw, gdouble diffh);
	void (*handle_update_by_fold) (Layout* self, Node* n);
	gdouble (*get_insert_adjust) (Layout* self, Node* child);
	void (*handle_update_by_insert) (Layout* self, Node* parent, Node* child, gint pos);
	void (*handle_update_by_delete) (Layout* self, Node* parent, gint index, NodeSide side, gdouble size);
	void (*position_root) (Layout* self, Node* last, Node* n);
};

struct _LayoutPrivate {
	gchar* _name;
	gchar* _light_icon;
	gchar* _dark_icon;
	gboolean _balanceable;
};

struct _Block29Data {
	int _ref_count_;
	Layout* self;
	Node* parent;
};

static gint Layout_private_offset;
static gpointer layout_parent_class = NULL;

VALA_EXTERN GType layout_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Layout, g_object_unref)
VALA_EXTERN GType node_side_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Node, g_object_unref)
VALA_EXTERN gpointer node_bounds_ref (gpointer instance);
VALA_EXTERN void node_bounds_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_node_bounds (const gchar* name,
                                    const gchar* nick,
                                    const gchar* blurb,
                                    GType object_type,
                                    GParamFlags flags);
VALA_EXTERN void value_set_node_bounds (GValue* value,
                            gpointer v_object);
VALA_EXTERN void value_take_node_bounds (GValue* value,
                             gpointer v_object);
VALA_EXTERN gpointer value_get_node_bounds (const GValue* value);
VALA_EXTERN GType node_bounds_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NodeBounds, node_bounds_unref)
VALA_EXTERN gboolean layout_is_manual (Layout* self);
VALA_EXTERN NodeSide layout_side_mapping (Layout* self,
                              NodeSide side);
VALA_EXTERN void layout_initialize (Layout* self,
                        Node* parent);
VALA_EXTERN NodeBounds* layout_bbox (Layout* self,
                         Node* parent,
                         gint side_mask,
                         const gchar* msg);
VALA_EXTERN void layout_adjust_tree (Layout* self,
                         Node* parent,
                         gint child_index,
                         gint side_mask,
                         gdouble amount);
VALA_EXTERN void layout_adjust_tree_all (Layout* self,
                             Node* n,
                             NodeBounds* p,
                             gdouble amount,
                             const gchar* msg);
VALA_EXTERN void layout_propagate_side (Layout* self,
                            Node* parent,
                            NodeSide side);
VALA_EXTERN NodeSide layout_get_side (Layout* self,
                          Node* n);
VALA_EXTERN void layout_set_side (Layout* self,
                      Node* current);
VALA_EXTERN void layout_handle_update_by_edit (Layout* self,
                                   Node* n,
                                   gdouble diffw,
                                   gdouble diffh);
VALA_EXTERN void layout_handle_update_by_fold (Layout* self,
                                   Node* n);
VALA_EXTERN gdouble layout_get_insert_adjust (Layout* self,
                                  Node* child);
VALA_EXTERN void layout_handle_update_by_insert (Layout* self,
                                     Node* parent,
                                     Node* child,
                                     gint pos);
VALA_EXTERN void layout_handle_update_by_delete (Layout* self,
                                     Node* parent,
                                     gint index,
                                     NodeSide side,
                                     gdouble size);
VALA_EXTERN void layout_position_root (Layout* self,
                           Node* last,
                           Node* n);
VALA_EXTERN Layout* layout_new (void);
VALA_EXTERN Layout* layout_construct (GType object_type);
static gboolean layout_real_is_manual (Layout* self);
static NodeSide layout_real_side_mapping (Layout* self,
                                   NodeSide side);
static void layout_real_initialize (Layout* self,
                             Node* parent);
static Block29Data* block29_data_ref (Block29Data* _data29_);
static void block29_data_unref (void * _userdata_);
VALA_EXTERN NodeSide node_get_side (Node* self);
VALA_EXTERN void node_set_side (Node* self,
                    NodeSide value);
VALA_EXTERN gboolean node_traversable (Node* self);
VALA_EXTERN GArray* node_children (Node* self);
VALA_EXTERN gboolean node_is_summary (Node* self);
static void ___lambda5_ (Layout* self,
                  Node* item);
VALA_EXTERN void node_detach (Node* self,
                  NodeSide side);
static void ____lambda5__gfunc (gconstpointer data,
                         gpointer self);
static void ___lambda37_ (Block29Data* _data29_,
                   Node* item);
VALA_EXTERN void node_attach_init (Node* self,
                       Node* parent,
                       gint index);
static void ____lambda37__gfunc (gconstpointer data,
                          gpointer self);
static void _g_object_unref0_ (gpointer var);
static inline void _g_slist_free__g_object_unref0_ (GSList* self);
static NodeBounds* layout_real_bbox (Layout* self,
                              Node* parent,
                              gint side_mask,
                              const gchar* msg);
VALA_EXTERN void node_bbox (Node* self,
                gdouble* x,
                gdouble* y,
                gdouble* w,
                gdouble* h);
VALA_EXTERN gpointer mind_map_ref (gpointer instance);
VALA_EXTERN void mind_map_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_mind_map (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags);
VALA_EXTERN void value_set_mind_map (GValue* value,
                         gpointer v_object);
VALA_EXTERN void value_take_mind_map (GValue* value,
                          gpointer v_object);
VALA_EXTERN gpointer value_get_mind_map (const GValue* value);
VALA_EXTERN GType mind_map_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MindMap, mind_map_unref)
VALA_EXTERN MindMap* node_get_map (Node* self);
VALA_EXTERN NodeBounds* node_bounds_new_with_bounds (MindMap* map,
                                         gdouble x,
                                         gdouble y,
                                         gdouble w,
                                         gdouble h);
VALA_EXTERN NodeBounds* node_bounds_construct_with_bounds (GType object_type,
                                               MindMap* map,
                                               gdouble x,
                                               gdouble y,
                                               gdouble w,
                                               gdouble h);
VALA_EXTERN gdouble node_bounds_get_x (NodeBounds* self);
VALA_EXTERN gdouble node_bounds_get_width (NodeBounds* self);
VALA_EXTERN gdouble node_bounds_get_y (NodeBounds* self);
VALA_EXTERN gdouble node_bounds_get_height (NodeBounds* self);
VALA_EXTERN gboolean node_get_folded (Node* self);
VALA_EXTERN gboolean node_is_summarized (Node* self);
VALA_EXTERN Node* node_get_parent (Node* self);
VALA_EXTERN NodeBounds* node_get_tree_bbox (Node* self);
VALA_EXTERN void node_bounds_set_x (NodeBounds* self,
                        gdouble value);
VALA_EXTERN void node_bounds_set_y (NodeBounds* self,
                        gdouble value);
VALA_EXTERN GType summary_node_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SummaryNode, g_object_unref)
VALA_EXTERN SummaryNode* node_summary_node (Node* self);
VALA_EXTERN gboolean node_first_summarized (Node* self);
VALA_EXTERN gboolean node_side_vertical (NodeSide self);
VALA_EXTERN gboolean node_side_horizontal (NodeSide self);
VALA_EXTERN gboolean node_last_summarized (Node* self);
VALA_EXTERN void node_bounds_set_width (NodeBounds* self,
                            gdouble value);
VALA_EXTERN void node_bounds_set_height (NodeBounds* self,
                             gdouble value);
VALA_EXTERN void layout_update_tree_size (Layout* self,
                              Node* n);
VALA_EXTERN void node_set_tree_bbox (Node* self,
                         NodeBounds* value);
VALA_EXTERN void node_set_tree_size (Node* self,
                         gdouble value);
VALA_EXTERN gdouble layout_get_adjust (Layout* self,
                           Node* parent);
VALA_EXTERN void summary_node_get_extents (SummaryNode* self,
                               gdouble* xy1,
                               gdouble* xy2);
VALA_EXTERN gdouble node_get_tree_size (Node* self);
static void layout_real_adjust_tree (Layout* self,
                              Node* parent,
                              gint child_index,
                              gint side_mask,
                              gdouble amount);
VALA_EXTERN gdouble node_get_posy (Node* self);
VALA_EXTERN void node_set_posy (Node* self,
                    gdouble value);
VALA_EXTERN gdouble node_get_posx (Node* self);
VALA_EXTERN void node_set_posx (Node* self,
                    gdouble value);
static void layout_real_adjust_tree_all (Layout* self,
                                  Node* n,
                                  NodeBounds* p,
                                  gdouble amount,
                                  const gchar* msg);
VALA_EXTERN gint node_index (Node* self);
VALA_EXTERN GArray* mind_map_get_nodes (MindMap* self);
VALA_EXTERN NodeBounds* node_bounds_new_copy (NodeBounds* nb);
VALA_EXTERN NodeBounds* node_bounds_construct_copy (GType object_type,
                                        NodeBounds* nb);
VALA_EXTERN void node_bounds_copy_from (NodeBounds* self,
                            NodeBounds* nb);
VALA_EXTERN gpointer map_model_ref (gpointer instance);
VALA_EXTERN void map_model_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_map_model (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_map_model (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_map_model (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_map_model (const GValue* value);
VALA_EXTERN GType map_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MapModel, map_model_unref)
VALA_EXTERN MapModel* mind_map_get_model (MindMap* self);
VALA_EXTERN void map_model_handle_tree_overlap (MapModel* self,
                                    NodeBounds* prev);
static void layout_real_propagate_side (Layout* self,
                                 Node* parent,
                                 NodeSide side);
VALA_EXTERN gpointer style_ref (gpointer instance);
VALA_EXTERN void style_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_style (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags);
VALA_EXTERN void value_set_style (GValue* value,
                      gpointer v_object);
VALA_EXTERN void value_take_style (GValue* value,
                       gpointer v_object);
VALA_EXTERN gpointer value_get_style (const GValue* value);
VALA_EXTERN GType style_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Style, style_unref)
VALA_EXTERN Style* node_get_style (Node* self);
VALA_EXTERN gint* style_get_branch_margin (Style* self);
static gint* _int_dup (gint* self);
static NodeSide layout_real_get_side (Layout* self,
                               Node* n);
VALA_EXTERN gboolean node_is_root (Node* self);
VALA_EXTERN Node* node_get_root (Node* self);
static void layout_real_set_side (Layout* self,
                           Node* current);
VALA_EXTERN void layout_apply_margin (Layout* self,
                          Node* n);
static void layout_real_handle_update_by_edit (Layout* self,
                                        Node* n,
                                        gdouble diffw,
                                        gdouble diffh);
VALA_EXTERN void node_adjust_posy_only (Node* self,
                            gdouble value);
VALA_EXTERN void node_adjust_posx_only (Node* self,
                            gdouble value);
static void layout_real_handle_update_by_fold (Layout* self,
                                        Node* n);
static gdouble layout_real_get_insert_adjust (Layout* self,
                                       Node* child);
static void layout_real_handle_update_by_insert (Layout* self,
                                          Node* parent,
                                          Node* child,
                                          gint pos);
VALA_EXTERN gint node_side_count (Node* self,
                      NodeSide side);
static void layout_real_handle_update_by_delete (Layout* self,
                                          Node* parent,
                                          gint index,
                                          NodeSide side,
                                          gdouble size);
static void layout_real_position_root (Layout* self,
                                Node* last,
                                Node* n);
VALA_EXTERN const gchar* layout_get_name (Layout* self);
VALA_EXTERN void layout_set_name (Layout* self,
                      const gchar* value);
VALA_EXTERN const gchar* layout_get_light_icon (Layout* self);
VALA_EXTERN void layout_set_light_icon (Layout* self,
                            const gchar* value);
VALA_EXTERN const gchar* layout_get_dark_icon (Layout* self);
VALA_EXTERN void layout_set_dark_icon (Layout* self,
                           const gchar* value);
VALA_EXTERN gboolean layout_get_balanceable (Layout* self);
VALA_EXTERN void layout_set_balanceable (Layout* self,
                             gboolean value);
static void layout_finalize (GObject * obj);
static GType layout_get_type_once (void);
static void _vala_layout_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec);
static void _vala_layout_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
layout_get_instance_private (Layout* self)
{
	return G_STRUCT_MEMBER_P (self, Layout_private_offset);
}

Layout*
layout_construct (GType object_type)
{
	Layout * self = NULL;
	self = (Layout*) g_object_new (object_type, NULL);
	return self;
}

Layout*
layout_new (void)
{
	return layout_construct (TYPE_LAYOUT);
}

static gboolean
layout_real_is_manual (Layout* self)
{
	gboolean result;
	result = FALSE;
	return result;
}

gboolean
layout_is_manual (Layout* self)
{
	LayoutClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->is_manual) {
		return _klass_->is_manual (self);
	}
	return FALSE;
}

static NodeSide
layout_real_side_mapping (Layout* self,
                          NodeSide side)
{
	NodeSide result;
	switch (side) {
		case NODE_SIDE_LEFT:
		{
			result = NODE_SIDE_LEFT;
			return result;
		}
		case NODE_SIDE_RIGHT:
		{
			result = NODE_SIDE_RIGHT;
			return result;
		}
		case NODE_SIDE_TOP:
		{
			result = NODE_SIDE_LEFT;
			return result;
		}
		case NODE_SIDE_BOTTOM:
		{
			result = NODE_SIDE_RIGHT;
			return result;
		}
		default:
		break;
	}
	result = NODE_SIDE_RIGHT;
	return result;
}

NodeSide
layout_side_mapping (Layout* self,
                     NodeSide side)
{
	LayoutClass* _klass_;
	g_return_val_if_fail (self != NULL, 0);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->side_mapping) {
		return _klass_->side_mapping (self, side);
	}
	return 0;
}

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

static Block29Data*
block29_data_ref (Block29Data* _data29_)
{
	g_atomic_int_inc (&_data29_->_ref_count_);
	return _data29_;
}

static void
block29_data_unref (void * _userdata_)
{
	Block29Data* _data29_;
	_data29_ = (Block29Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data29_->_ref_count_)) {
		Layout* self;
		self = _data29_->self;
		_g_object_unref0 (_data29_->parent);
		_g_object_unref0 (self);
		g_slice_free (Block29Data, _data29_);
	}
}

static void
___lambda5_ (Layout* self,
             Node* item)
{
	NodeSide _tmp0_;
	NodeSide _tmp1_;
	g_return_if_fail (item != NULL);
	_tmp0_ = node_get_side (item);
	_tmp1_ = _tmp0_;
	node_detach (item, _tmp1_);
}

static void
____lambda5__gfunc (gconstpointer data,
                    gpointer self)
{
	___lambda5_ ((Layout*) self, (Node*) data);
}

static void
___lambda37_ (Block29Data* _data29_,
              Node* item)
{
	Layout* self;
	self = _data29_->self;
	g_return_if_fail (item != NULL);
	node_attach_init (item, _data29_->parent, -1);
}

static void
____lambda37__gfunc (gconstpointer data,
                     gpointer self)
{
	___lambda37_ (self, (Node*) data);
}

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

static inline void
_g_slist_free__g_object_unref0_ (GSList* self)
{
	g_slist_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

static void
layout_real_initialize (Layout* self,
                        Node* parent)
{
	Block29Data* _data29_;
	Node* _tmp0_;
	GSList* list = NULL;
	NodeSide _tmp1_;
	NodeSide _tmp2_;
	g_return_if_fail (parent != NULL);
	_data29_ = g_slice_new0 (Block29Data);
	_data29_->_ref_count_ = 1;
	_data29_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (parent);
	_g_object_unref0 (_data29_->parent);
	_data29_->parent = _tmp0_;
	list = NULL;
	_tmp1_ = node_get_side (_data29_->parent);
	_tmp2_ = _tmp1_;
	node_set_side (_data29_->parent, layout_side_mapping (self, _tmp2_));
	if (node_traversable (_data29_->parent)) {
		GSList* _tmp17_;
		GSList* _tmp18_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp3_ = FALSE;
				_tmp3_ = TRUE;
				while (TRUE) {
					GArray* _tmp5_;
					GArray* _tmp6_;
					gboolean _tmp7_;
					Node* n = NULL;
					GArray* _tmp8_;
					GArray* _tmp9_;
					Node* _tmp10_;
					Node* _tmp11_;
					Node* _tmp12_;
					Node* _tmp13_;
					Node* _tmp14_;
					if (!_tmp3_) {
						gint _tmp4_;
						_tmp4_ = i;
						i = _tmp4_ + 1;
					}
					_tmp3_ = FALSE;
					_tmp5_ = node_children (_data29_->parent);
					_tmp6_ = _tmp5_;
					_tmp7_ = !(((guint) i) < _tmp6_->len);
					_g_array_unref0 (_tmp6_);
					if (_tmp7_) {
						break;
					}
					_tmp8_ = node_children (_data29_->parent);
					_tmp9_ = _tmp8_;
					_tmp10_ = g_array_index (_tmp9_, Node*, (guint) i);
					_tmp11_ = _g_object_ref0 (_tmp10_);
					_tmp12_ = _tmp11_;
					_g_array_unref0 (_tmp9_);
					n = _tmp12_;
					_tmp13_ = n;
					layout_initialize (self, _tmp13_);
					_tmp14_ = n;
					if (!node_is_summary (_tmp14_)) {
						Node* _tmp15_;
						Node* _tmp16_;
						_tmp15_ = n;
						_tmp16_ = _g_object_ref0 (_tmp15_);
						list = g_slist_append (list, _tmp16_);
					}
					_g_object_unref0 (n);
				}
			}
		}
		_tmp17_ = list;
		g_slist_foreach (_tmp17_, ____lambda5__gfunc, self);
		_tmp18_ = list;
		g_slist_foreach (_tmp18_, ____lambda37__gfunc, _data29_);
	}
	(list == NULL) ? NULL : (list = (_g_slist_free__g_object_unref0_ (list), NULL));
	block29_data_unref (_data29_);
	_data29_ = NULL;
}

void
layout_initialize (Layout* self,
                   Node* parent)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->initialize) {
		_klass_->initialize (self, parent);
	}
}

static gpointer
_node_bounds_ref0 (gpointer self)
{
	return self ? node_bounds_ref (self) : NULL;
}

static NodeBounds*
layout_real_bbox (Layout* self,
                  Node* parent,
                  gint side_mask,
                  const gchar* msg)
{
	guint num_children = 0U;
	GArray* _tmp0_;
	GArray* _tmp1_;
	guint _tmp2_;
	gdouble px = 0.0;
	gdouble py = 0.0;
	gdouble pw = 0.0;
	gdouble ph = 0.0;
	gdouble _tmp3_ = 0.0;
	gdouble _tmp4_ = 0.0;
	gdouble _tmp5_ = 0.0;
	gdouble _tmp6_ = 0.0;
	NodeBounds* nb = NULL;
	MindMap* _tmp7_;
	MindMap* _tmp8_;
	NodeBounds* _tmp9_;
	gdouble x2 = 0.0;
	NodeBounds* _tmp10_;
	gdouble _tmp11_;
	gdouble _tmp12_;
	NodeBounds* _tmp13_;
	gdouble _tmp14_;
	gdouble _tmp15_;
	gdouble y2 = 0.0;
	NodeBounds* _tmp16_;
	gdouble _tmp17_;
	gdouble _tmp18_;
	NodeBounds* _tmp19_;
	gdouble _tmp20_;
	gdouble _tmp21_;
	gboolean _tmp22_ = FALSE;
	gboolean _tmp23_ = FALSE;
	NodeBounds* _tmp175_;
	NodeBounds* _tmp176_;
	gdouble _tmp177_;
	gdouble _tmp178_;
	NodeBounds* _tmp179_;
	NodeBounds* _tmp180_;
	gdouble _tmp181_;
	gdouble _tmp182_;
	NodeBounds* result;
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = node_children (parent);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_->len;
	_g_array_unref0 (_tmp1_);
	num_children = _tmp2_;
	node_bbox (parent, &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	px = _tmp3_;
	py = _tmp4_;
	pw = _tmp5_;
	ph = _tmp6_;
	_tmp7_ = node_get_map (parent);
	_tmp8_ = _tmp7_;
	_tmp9_ = node_bounds_new_with_bounds (_tmp8_, px, py, pw, ph);
	nb = _tmp9_;
	_tmp10_ = nb;
	_tmp11_ = node_bounds_get_x (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = nb;
	_tmp14_ = node_bounds_get_width (_tmp13_);
	_tmp15_ = _tmp14_;
	x2 = _tmp12_ + _tmp15_;
	_tmp16_ = nb;
	_tmp17_ = node_bounds_get_y (_tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = nb;
	_tmp20_ = node_bounds_get_height (_tmp19_);
	_tmp21_ = _tmp20_;
	y2 = _tmp18_ + _tmp21_;
	if (num_children != ((guint) 0)) {
		gboolean _tmp24_;
		gboolean _tmp25_;
		_tmp24_ = node_get_folded (parent);
		_tmp25_ = _tmp24_;
		_tmp23_ = !_tmp25_;
	} else {
		_tmp23_ = FALSE;
	}
	if (_tmp23_) {
		_tmp22_ = !node_is_summarized (parent);
	} else {
		_tmp22_ = FALSE;
	}
	if (_tmp22_) {
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp26_ = FALSE;
				_tmp26_ = TRUE;
				while (TRUE) {
					GArray* _tmp28_;
					GArray* _tmp29_;
					gboolean _tmp30_;
					Node* child = NULL;
					GArray* _tmp31_;
					GArray* _tmp32_;
					Node* _tmp33_;
					Node* _tmp34_;
					Node* _tmp35_;
					gboolean _tmp36_ = FALSE;
					Node* _tmp37_;
					Node* _tmp38_;
					Node* _tmp39_;
					if (!_tmp26_) {
						gint _tmp27_;
						_tmp27_ = i;
						i = _tmp27_ + 1;
					}
					_tmp26_ = FALSE;
					_tmp28_ = node_children (parent);
					_tmp29_ = _tmp28_;
					_tmp30_ = !(((guint) i) < _tmp29_->len);
					_g_array_unref0 (_tmp29_);
					if (_tmp30_) {
						break;
					}
					_tmp31_ = node_children (parent);
					_tmp32_ = _tmp31_;
					_tmp33_ = g_array_index (_tmp32_, Node*, (guint) i);
					_tmp34_ = _g_object_ref0 (_tmp33_);
					_tmp35_ = _tmp34_;
					_g_array_unref0 (_tmp32_);
					child = _tmp35_;
					_tmp37_ = child;
					_tmp38_ = node_get_parent (_tmp37_);
					_tmp39_ = _tmp38_;
					if (_tmp39_ == parent) {
						Node* _tmp40_;
						NodeSide _tmp41_;
						NodeSide _tmp42_;
						_tmp40_ = child;
						_tmp41_ = node_get_side (_tmp40_);
						_tmp42_ = _tmp41_;
						_tmp36_ = (_tmp42_ & side_mask) != 0;
					} else {
						_tmp36_ = FALSE;
					}
					if (_tmp36_) {
						NodeBounds* cb = NULL;
						GArray* _tmp43_;
						GArray* _tmp44_;
						Node* _tmp45_;
						NodeBounds* _tmp46_;
						NodeBounds* _tmp47_;
						NodeBounds* _tmp48_;
						NodeBounds* _tmp49_;
						gdouble _tmp50_ = 0.0;
						NodeBounds* _tmp51_;
						gdouble _tmp52_;
						gdouble _tmp53_;
						NodeBounds* _tmp54_;
						gdouble _tmp55_;
						gdouble _tmp56_;
						NodeBounds* _tmp63_;
						gdouble _tmp64_ = 0.0;
						NodeBounds* _tmp65_;
						gdouble _tmp66_;
						gdouble _tmp67_;
						NodeBounds* _tmp68_;
						gdouble _tmp69_;
						gdouble _tmp70_;
						NodeBounds* _tmp77_;
						gdouble _tmp78_ = 0.0;
						NodeBounds* _tmp79_;
						gdouble _tmp80_;
						gdouble _tmp81_;
						NodeBounds* _tmp82_;
						gdouble _tmp83_;
						gdouble _tmp84_;
						gdouble _tmp91_ = 0.0;
						NodeBounds* _tmp92_;
						gdouble _tmp93_;
						gdouble _tmp94_;
						NodeBounds* _tmp95_;
						gdouble _tmp96_;
						gdouble _tmp97_;
						_tmp43_ = node_children (parent);
						_tmp44_ = _tmp43_;
						_tmp45_ = g_array_index (_tmp44_, Node*, (guint) i);
						_tmp46_ = node_get_tree_bbox (_tmp45_);
						_tmp47_ = _tmp46_;
						_tmp48_ = _node_bounds_ref0 (_tmp47_);
						_tmp49_ = _tmp48_;
						_g_array_unref0 (_tmp44_);
						cb = _tmp49_;
						_tmp51_ = nb;
						_tmp52_ = node_bounds_get_x (_tmp51_);
						_tmp53_ = _tmp52_;
						_tmp54_ = cb;
						_tmp55_ = node_bounds_get_x (_tmp54_);
						_tmp56_ = _tmp55_;
						if (_tmp53_ < _tmp56_) {
							NodeBounds* _tmp57_;
							gdouble _tmp58_;
							gdouble _tmp59_;
							_tmp57_ = nb;
							_tmp58_ = node_bounds_get_x (_tmp57_);
							_tmp59_ = _tmp58_;
							_tmp50_ = _tmp59_;
						} else {
							NodeBounds* _tmp60_;
							gdouble _tmp61_;
							gdouble _tmp62_;
							_tmp60_ = cb;
							_tmp61_ = node_bounds_get_x (_tmp60_);
							_tmp62_ = _tmp61_;
							_tmp50_ = _tmp62_;
						}
						_tmp63_ = nb;
						node_bounds_set_x (_tmp63_, _tmp50_);
						_tmp65_ = nb;
						_tmp66_ = node_bounds_get_y (_tmp65_);
						_tmp67_ = _tmp66_;
						_tmp68_ = cb;
						_tmp69_ = node_bounds_get_y (_tmp68_);
						_tmp70_ = _tmp69_;
						if (_tmp67_ < _tmp70_) {
							NodeBounds* _tmp71_;
							gdouble _tmp72_;
							gdouble _tmp73_;
							_tmp71_ = nb;
							_tmp72_ = node_bounds_get_y (_tmp71_);
							_tmp73_ = _tmp72_;
							_tmp64_ = _tmp73_;
						} else {
							NodeBounds* _tmp74_;
							gdouble _tmp75_;
							gdouble _tmp76_;
							_tmp74_ = cb;
							_tmp75_ = node_bounds_get_y (_tmp74_);
							_tmp76_ = _tmp75_;
							_tmp64_ = _tmp76_;
						}
						_tmp77_ = nb;
						node_bounds_set_y (_tmp77_, _tmp64_);
						_tmp79_ = cb;
						_tmp80_ = node_bounds_get_x (_tmp79_);
						_tmp81_ = _tmp80_;
						_tmp82_ = cb;
						_tmp83_ = node_bounds_get_width (_tmp82_);
						_tmp84_ = _tmp83_;
						if (x2 < (_tmp81_ + _tmp84_)) {
							NodeBounds* _tmp85_;
							gdouble _tmp86_;
							gdouble _tmp87_;
							NodeBounds* _tmp88_;
							gdouble _tmp89_;
							gdouble _tmp90_;
							_tmp85_ = cb;
							_tmp86_ = node_bounds_get_x (_tmp85_);
							_tmp87_ = _tmp86_;
							_tmp88_ = cb;
							_tmp89_ = node_bounds_get_width (_tmp88_);
							_tmp90_ = _tmp89_;
							_tmp78_ = _tmp87_ + _tmp90_;
						} else {
							_tmp78_ = x2;
						}
						x2 = _tmp78_;
						_tmp92_ = cb;
						_tmp93_ = node_bounds_get_y (_tmp92_);
						_tmp94_ = _tmp93_;
						_tmp95_ = cb;
						_tmp96_ = node_bounds_get_height (_tmp95_);
						_tmp97_ = _tmp96_;
						if (y2 < (_tmp94_ + _tmp97_)) {
							NodeBounds* _tmp98_;
							gdouble _tmp99_;
							gdouble _tmp100_;
							NodeBounds* _tmp101_;
							gdouble _tmp102_;
							gdouble _tmp103_;
							_tmp98_ = cb;
							_tmp99_ = node_bounds_get_y (_tmp98_);
							_tmp100_ = _tmp99_;
							_tmp101_ = cb;
							_tmp102_ = node_bounds_get_height (_tmp101_);
							_tmp103_ = _tmp102_;
							_tmp91_ = _tmp100_ + _tmp103_;
						} else {
							_tmp91_ = y2;
						}
						y2 = _tmp91_;
						_node_bounds_unref0 (cb);
					}
					_g_object_unref0 (child);
				}
			}
		}
	}
	if (node_is_summarized (parent)) {
		SummaryNode* summary = NULL;
		SummaryNode* _tmp104_;
		NodeBounds* sb = NULL;
		SummaryNode* _tmp105_;
		NodeBounds* _tmp106_;
		NodeBounds* _tmp107_;
		NodeBounds* _tmp108_;
		_tmp104_ = node_summary_node (parent);
		summary = _tmp104_;
		_tmp105_ = summary;
		_tmp106_ = node_get_tree_bbox ((Node*) _tmp105_);
		_tmp107_ = _tmp106_;
		_tmp108_ = _node_bounds_ref0 (_tmp107_);
		sb = _tmp108_;
		if (node_first_summarized (parent)) {
			gdouble _tmp109_ = 0.0;
			gboolean _tmp110_ = FALSE;
			NodeSide _tmp111_;
			NodeSide _tmp112_;
			NodeBounds* _tmp125_;
			gdouble _tmp126_ = 0.0;
			gboolean _tmp127_ = FALSE;
			NodeSide _tmp128_;
			NodeSide _tmp129_;
			NodeBounds* _tmp142_;
			_tmp111_ = node_get_side (parent);
			_tmp112_ = _tmp111_;
			if (node_side_vertical (_tmp112_)) {
				NodeBounds* _tmp113_;
				gdouble _tmp114_;
				gdouble _tmp115_;
				NodeBounds* _tmp116_;
				gdouble _tmp117_;
				gdouble _tmp118_;
				_tmp113_ = nb;
				_tmp114_ = node_bounds_get_x (_tmp113_);
				_tmp115_ = _tmp114_;
				_tmp116_ = sb;
				_tmp117_ = node_bounds_get_x (_tmp116_);
				_tmp118_ = _tmp117_;
				_tmp110_ = _tmp115_ > _tmp118_;
			} else {
				_tmp110_ = FALSE;
			}
			if (_tmp110_) {
				NodeBounds* _tmp119_;
				gdouble _tmp120_;
				gdouble _tmp121_;
				_tmp119_ = sb;
				_tmp120_ = node_bounds_get_x (_tmp119_);
				_tmp121_ = _tmp120_;
				_tmp109_ = _tmp121_;
			} else {
				NodeBounds* _tmp122_;
				gdouble _tmp123_;
				gdouble _tmp124_;
				_tmp122_ = nb;
				_tmp123_ = node_bounds_get_x (_tmp122_);
				_tmp124_ = _tmp123_;
				_tmp109_ = _tmp124_;
			}
			_tmp125_ = nb;
			node_bounds_set_x (_tmp125_, _tmp109_);
			_tmp128_ = node_get_side (parent);
			_tmp129_ = _tmp128_;
			if (node_side_horizontal (_tmp129_)) {
				NodeBounds* _tmp130_;
				gdouble _tmp131_;
				gdouble _tmp132_;
				NodeBounds* _tmp133_;
				gdouble _tmp134_;
				gdouble _tmp135_;
				_tmp130_ = nb;
				_tmp131_ = node_bounds_get_y (_tmp130_);
				_tmp132_ = _tmp131_;
				_tmp133_ = sb;
				_tmp134_ = node_bounds_get_y (_tmp133_);
				_tmp135_ = _tmp134_;
				_tmp127_ = _tmp132_ > _tmp135_;
			} else {
				_tmp127_ = FALSE;
			}
			if (_tmp127_) {
				NodeBounds* _tmp136_;
				gdouble _tmp137_;
				gdouble _tmp138_;
				_tmp136_ = sb;
				_tmp137_ = node_bounds_get_y (_tmp136_);
				_tmp138_ = _tmp137_;
				_tmp126_ = _tmp138_;
			} else {
				NodeBounds* _tmp139_;
				gdouble _tmp140_;
				gdouble _tmp141_;
				_tmp139_ = nb;
				_tmp140_ = node_bounds_get_y (_tmp139_);
				_tmp141_ = _tmp140_;
				_tmp126_ = _tmp141_;
			}
			_tmp142_ = nb;
			node_bounds_set_y (_tmp142_, _tmp126_);
		} else {
			if (node_last_summarized (parent)) {
				gdouble _tmp143_ = 0.0;
				gboolean _tmp144_ = FALSE;
				NodeSide _tmp145_;
				NodeSide _tmp146_;
				gdouble _tmp159_ = 0.0;
				gboolean _tmp160_ = FALSE;
				NodeSide _tmp161_;
				NodeSide _tmp162_;
				_tmp145_ = node_get_side (parent);
				_tmp146_ = _tmp145_;
				if (node_side_vertical (_tmp146_)) {
					NodeBounds* _tmp147_;
					gdouble _tmp148_;
					gdouble _tmp149_;
					NodeBounds* _tmp150_;
					gdouble _tmp151_;
					gdouble _tmp152_;
					_tmp147_ = sb;
					_tmp148_ = node_bounds_get_x (_tmp147_);
					_tmp149_ = _tmp148_;
					_tmp150_ = sb;
					_tmp151_ = node_bounds_get_width (_tmp150_);
					_tmp152_ = _tmp151_;
					_tmp144_ = x2 < (_tmp149_ + _tmp152_);
				} else {
					_tmp144_ = FALSE;
				}
				if (_tmp144_) {
					NodeBounds* _tmp153_;
					gdouble _tmp154_;
					gdouble _tmp155_;
					NodeBounds* _tmp156_;
					gdouble _tmp157_;
					gdouble _tmp158_;
					_tmp153_ = sb;
					_tmp154_ = node_bounds_get_x (_tmp153_);
					_tmp155_ = _tmp154_;
					_tmp156_ = sb;
					_tmp157_ = node_bounds_get_width (_tmp156_);
					_tmp158_ = _tmp157_;
					_tmp143_ = _tmp155_ + _tmp158_;
				} else {
					_tmp143_ = x2;
				}
				x2 = _tmp143_;
				_tmp161_ = node_get_side (parent);
				_tmp162_ = _tmp161_;
				if (node_side_horizontal (_tmp162_)) {
					NodeBounds* _tmp163_;
					gdouble _tmp164_;
					gdouble _tmp165_;
					NodeBounds* _tmp166_;
					gdouble _tmp167_;
					gdouble _tmp168_;
					_tmp163_ = sb;
					_tmp164_ = node_bounds_get_y (_tmp163_);
					_tmp165_ = _tmp164_;
					_tmp166_ = sb;
					_tmp167_ = node_bounds_get_height (_tmp166_);
					_tmp168_ = _tmp167_;
					_tmp160_ = y2 < (_tmp165_ + _tmp168_);
				} else {
					_tmp160_ = FALSE;
				}
				if (_tmp160_) {
					NodeBounds* _tmp169_;
					gdouble _tmp170_;
					gdouble _tmp171_;
					NodeBounds* _tmp172_;
					gdouble _tmp173_;
					gdouble _tmp174_;
					_tmp169_ = sb;
					_tmp170_ = node_bounds_get_y (_tmp169_);
					_tmp171_ = _tmp170_;
					_tmp172_ = sb;
					_tmp173_ = node_bounds_get_height (_tmp172_);
					_tmp174_ = _tmp173_;
					_tmp159_ = _tmp171_ + _tmp174_;
				} else {
					_tmp159_ = y2;
				}
				y2 = _tmp159_;
			}
		}
		_node_bounds_unref0 (sb);
		_g_object_unref0 (summary);
	}
	_tmp175_ = nb;
	_tmp176_ = nb;
	_tmp177_ = node_bounds_get_x (_tmp176_);
	_tmp178_ = _tmp177_;
	node_bounds_set_width (_tmp175_, x2 - _tmp178_);
	_tmp179_ = nb;
	_tmp180_ = nb;
	_tmp181_ = node_bounds_get_y (_tmp180_);
	_tmp182_ = _tmp181_;
	node_bounds_set_height (_tmp179_, y2 - _tmp182_);
	result = nb;
	return result;
}

NodeBounds*
layout_bbox (Layout* self,
             Node* parent,
             gint side_mask,
             const gchar* msg)
{
	LayoutClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->bbox) {
		return _klass_->bbox (self, parent, side_mask, msg);
	}
	return NULL;
}

void
layout_update_tree_size (Layout* self,
                         Node* n)
{
	NodeBounds* nb = NULL;
	NodeBounds* _tmp0_;
	NodeBounds* _tmp1_;
	gdouble _tmp2_ = 0.0;
	NodeSide _tmp3_;
	NodeSide _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (n != NULL);
	_tmp0_ = layout_bbox (self, n, -1, "update_tree_size");
	nb = _tmp0_;
	_tmp1_ = nb;
	node_set_tree_bbox (n, _tmp1_);
	_tmp3_ = node_get_side (n);
	_tmp4_ = _tmp3_;
	if (node_side_horizontal (_tmp4_)) {
		NodeBounds* _tmp5_;
		gdouble _tmp6_;
		gdouble _tmp7_;
		_tmp5_ = nb;
		_tmp6_ = node_bounds_get_height (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp2_ = _tmp7_;
	} else {
		NodeBounds* _tmp8_;
		gdouble _tmp9_;
		gdouble _tmp10_;
		_tmp8_ = nb;
		_tmp9_ = node_bounds_get_width (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp2_ = _tmp10_;
	}
	node_set_tree_size (n, _tmp2_);
	_node_bounds_unref0 (nb);
}

gdouble
layout_get_adjust (Layout* self,
                   Node* parent)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	g_return_val_if_fail (parent != NULL, -1.0);
	if (node_is_summary (parent)) {
		gdouble xy1 = 0.0;
		gdouble xy2 = 0.0;
		gdouble _tmp0_ = 0.0;
		gdouble _tmp1_ = 0.0;
		gdouble extent_size = 0.0;
		gdouble _tmp2_ = 0.0;
		gdouble _tmp3_;
		gdouble _tmp4_;
		gdouble orig_tree_size = 0.0;
		gdouble _tmp7_ = 0.0;
		gdouble _tmp8_;
		gdouble _tmp9_;
		summary_node_get_extents (IS_SUMMARY_NODE (parent) ? ((SummaryNode*) parent) : NULL, &_tmp0_, &_tmp1_);
		xy1 = _tmp0_;
		xy2 = _tmp1_;
		extent_size = xy2 - xy1;
		_tmp3_ = node_get_tree_size (parent);
		_tmp4_ = _tmp3_;
		if (extent_size < _tmp4_) {
			gdouble _tmp5_;
			gdouble _tmp6_;
			_tmp5_ = node_get_tree_size (parent);
			_tmp6_ = _tmp5_;
			_tmp2_ = _tmp6_;
		} else {
			_tmp2_ = extent_size;
		}
		orig_tree_size = _tmp2_;
		layout_update_tree_size (self, parent);
		_tmp8_ = node_get_tree_size (parent);
		_tmp9_ = _tmp8_;
		if (extent_size < _tmp9_) {
			gdouble _tmp10_;
			gdouble _tmp11_;
			_tmp10_ = node_get_tree_size (parent);
			_tmp11_ = _tmp10_;
			_tmp7_ = _tmp11_ - orig_tree_size;
		} else {
			_tmp7_ = (gdouble) 0;
		}
		result = _tmp7_;
		return result;
	} else {
		gdouble orig_tree_size = 0.0;
		gdouble _tmp12_;
		gdouble _tmp13_;
		gdouble _tmp14_ = 0.0;
		_tmp12_ = node_get_tree_size (parent);
		_tmp13_ = _tmp12_;
		orig_tree_size = _tmp13_;
		layout_update_tree_size (self, parent);
		if (orig_tree_size == ((gdouble) 0)) {
			_tmp14_ = (gdouble) 0;
		} else {
			gdouble _tmp15_;
			gdouble _tmp16_;
			_tmp15_ = node_get_tree_size (parent);
			_tmp16_ = _tmp15_;
			_tmp14_ = _tmp16_ - orig_tree_size;
		}
		result = _tmp14_;
		return result;
	}
}

static void
layout_real_adjust_tree (Layout* self,
                         Node* parent,
                         gint child_index,
                         gint side_mask,
                         gdouble amount)
{
	g_return_if_fail (parent != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				GArray* _tmp3_;
				gboolean _tmp4_;
				Node* n = NULL;
				GArray* _tmp5_;
				GArray* _tmp6_;
				Node* _tmp7_;
				Node* _tmp8_;
				Node* _tmp9_;
				gboolean _tmp10_ = FALSE;
				gboolean _tmp11_ = FALSE;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = node_children (parent);
				_tmp3_ = _tmp2_;
				_tmp4_ = !(((guint) i) < _tmp3_->len);
				_g_array_unref0 (_tmp3_);
				if (_tmp4_) {
					break;
				}
				_tmp5_ = node_children (parent);
				_tmp6_ = _tmp5_;
				_tmp7_ = g_array_index (_tmp6_, Node*, (guint) i);
				_tmp8_ = _g_object_ref0 (_tmp7_);
				_tmp9_ = _tmp8_;
				_g_array_unref0 (_tmp6_);
				n = _tmp9_;
				if (i != child_index) {
					_tmp11_ = TRUE;
				} else {
					Node* _tmp12_;
					_tmp12_ = n;
					_tmp11_ = node_last_summarized (_tmp12_);
				}
				if (_tmp11_) {
					Node* _tmp13_;
					NodeSide _tmp14_;
					NodeSide _tmp15_;
					_tmp13_ = n;
					_tmp14_ = node_get_side (_tmp13_);
					_tmp15_ = _tmp14_;
					_tmp10_ = (_tmp15_ & side_mask) != 0;
				} else {
					_tmp10_ = FALSE;
				}
				if (_tmp10_) {
					Node* _tmp16_;
					NodeSide _tmp17_;
					NodeSide _tmp18_;
					_tmp16_ = n;
					_tmp17_ = node_get_side (_tmp16_);
					_tmp18_ = _tmp17_;
					if (node_side_horizontal (_tmp18_)) {
						Node* _tmp19_;
						Node* _tmp20_;
						gdouble _tmp21_;
						gdouble _tmp22_;
						_tmp19_ = n;
						_tmp20_ = n;
						_tmp21_ = node_get_posy (_tmp20_);
						_tmp22_ = _tmp21_;
						node_set_posy (_tmp20_, _tmp22_ + amount);
					} else {
						Node* _tmp23_;
						Node* _tmp24_;
						gdouble _tmp25_;
						gdouble _tmp26_;
						_tmp23_ = n;
						_tmp24_ = n;
						_tmp25_ = node_get_posx (_tmp24_);
						_tmp26_ = _tmp25_;
						node_set_posx (_tmp24_, _tmp26_ + amount);
					}
				}
				if (i == child_index) {
					amount = 0 - amount;
				}
				_g_object_unref0 (n);
			}
		}
	}
}

void
layout_adjust_tree (Layout* self,
                    Node* parent,
                    gint child_index,
                    gint side_mask,
                    gdouble amount)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->adjust_tree) {
		_klass_->adjust_tree (self, parent, child_index, side_mask, amount);
	}
}

static void
layout_real_adjust_tree_all (Layout* self,
                             Node* n,
                             NodeBounds* p,
                             gdouble amount,
                             const gchar* msg)
{
	Node* parent = NULL;
	Node* _tmp0_;
	Node* _tmp1_;
	Node* _tmp2_;
	Node* last = NULL;
	Node* _tmp3_;
	gint index = 0;
	GArray* nodes = NULL;
	MindMap* _tmp4_;
	MindMap* _tmp5_;
	GArray* _tmp6_;
	NodeBounds* prev = NULL;
	NodeBounds* _tmp7_;
	g_return_if_fail (n != NULL);
	g_return_if_fail (p != NULL);
	g_return_if_fail (msg != NULL);
	_tmp0_ = node_get_parent (n);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	parent = _tmp2_;
	_tmp3_ = _g_object_ref0 (n);
	last = _tmp3_;
	index = node_index (n);
	_tmp4_ = node_get_map (n);
	_tmp5_ = _tmp4_;
	_tmp6_ = mind_map_get_nodes (_tmp5_);
	nodes = _tmp6_;
	_tmp7_ = node_bounds_new_copy (p);
	prev = _tmp7_;
	while (TRUE) {
		Node* _tmp8_;
		Node* _tmp9_;
		NodeSide _tmp10_;
		NodeSide _tmp11_;
		NodeBounds* _tmp12_;
		Node* _tmp13_;
		NodeBounds* _tmp14_;
		NodeBounds* _tmp15_;
		Node* _tmp16_;
		Node* _tmp17_;
		Node* _tmp18_;
		Node* _tmp19_;
		Node* _tmp20_;
		Node* _tmp21_;
		Node* _tmp22_;
		Node* _tmp23_;
		_tmp8_ = parent;
		if (!(_tmp8_ != NULL)) {
			break;
		}
		_tmp9_ = parent;
		_tmp10_ = node_get_side (n);
		_tmp11_ = _tmp10_;
		layout_adjust_tree (self, _tmp9_, index, (gint) _tmp11_, amount);
		_tmp12_ = prev;
		_tmp13_ = parent;
		_tmp14_ = node_get_tree_bbox (_tmp13_);
		_tmp15_ = _tmp14_;
		node_bounds_copy_from (_tmp12_, _tmp15_);
		_tmp16_ = parent;
		amount = 0 - (layout_get_adjust (self, _tmp16_) / 2);
		_tmp17_ = parent;
		index = node_index (_tmp17_);
		_tmp18_ = parent;
		_tmp19_ = _g_object_ref0 (_tmp18_);
		_g_object_unref0 (last);
		last = _tmp19_;
		_tmp20_ = parent;
		_tmp21_ = node_get_parent (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = _g_object_ref0 (_tmp22_);
		_g_object_unref0 (parent);
		parent = _tmp23_;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp24_ = FALSE;
			_tmp24_ = TRUE;
			while (TRUE) {
				GArray* _tmp26_;
				GArray* _tmp27_;
				Node* _tmp28_;
				Node* _tmp29_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				_tmp26_ = nodes;
				if (!(((guint) i) < _tmp26_->len)) {
					break;
				}
				_tmp27_ = nodes;
				_tmp28_ = g_array_index (_tmp27_, Node*, (guint) i);
				_tmp29_ = last;
				if (_tmp28_ == _tmp29_) {
					MindMap* _tmp30_;
					MindMap* _tmp31_;
					MapModel* _tmp32_;
					MapModel* _tmp33_;
					NodeBounds* _tmp34_;
					_tmp30_ = node_get_map (n);
					_tmp31_ = _tmp30_;
					_tmp32_ = mind_map_get_model (_tmp31_);
					_tmp33_ = _tmp32_;
					_tmp34_ = prev;
					map_model_handle_tree_overlap (_tmp33_, _tmp34_);
				}
			}
		}
	}
	_node_bounds_unref0 (prev);
	_g_array_unref0 (nodes);
	_g_object_unref0 (last);
	_g_object_unref0 (parent);
}

void
layout_adjust_tree_all (Layout* self,
                        Node* n,
                        NodeBounds* p,
                        gdouble amount,
                        const gchar* msg)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->adjust_tree_all) {
		_klass_->adjust_tree_all (self, n, p, amount, msg);
	}
}

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

static gpointer
__int_dup0 (gpointer self)
{
	return self ? _int_dup (self) : NULL;
}

static void
layout_real_propagate_side (Layout* self,
                            Node* parent,
                            NodeSide side)
{
	gdouble px = 0.0;
	gdouble py = 0.0;
	gdouble pw = 0.0;
	gdouble ph = 0.0;
	gint* margin = NULL;
	Style* _tmp0_;
	Style* _tmp1_;
	gint* _tmp2_;
	gint* _tmp3_;
	gint* _tmp4_;
	gdouble _tmp5_ = 0.0;
	gdouble _tmp6_ = 0.0;
	gdouble _tmp7_ = 0.0;
	gdouble _tmp8_ = 0.0;
	g_return_if_fail (parent != NULL);
	if (!node_traversable (parent)) {
		return;
	}
	_tmp0_ = node_get_style (parent);
	_tmp1_ = _tmp0_;
	_tmp2_ = style_get_branch_margin (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = __int_dup0 (_tmp3_);
	margin = _tmp4_;
	node_bbox (parent, &_tmp5_, &_tmp6_, &_tmp7_, &_tmp8_);
	px = _tmp5_;
	py = _tmp6_;
	pw = _tmp7_;
	ph = _tmp8_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				GArray* _tmp11_;
				GArray* _tmp12_;
				gboolean _tmp13_;
				Node* n = NULL;
				GArray* _tmp14_;
				GArray* _tmp15_;
				Node* _tmp16_;
				Node* _tmp17_;
				Node* _tmp18_;
				Node* _tmp19_;
				NodeSide _tmp20_;
				NodeSide _tmp21_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = node_children (parent);
				_tmp12_ = _tmp11_;
				_tmp13_ = !(((guint) i) < _tmp12_->len);
				_g_array_unref0 (_tmp12_);
				if (_tmp13_) {
					break;
				}
				_tmp14_ = node_children (parent);
				_tmp15_ = _tmp14_;
				_tmp16_ = g_array_index (_tmp15_, Node*, (guint) i);
				_tmp17_ = _g_object_ref0 (_tmp16_);
				_tmp18_ = _tmp17_;
				_g_array_unref0 (_tmp15_);
				n = _tmp18_;
				_tmp19_ = n;
				_tmp20_ = node_get_side (_tmp19_);
				_tmp21_ = _tmp20_;
				if (_tmp21_ != side) {
					Node* _tmp22_;
					Node* _tmp41_;
					_tmp22_ = n;
					node_set_side (_tmp22_, side);
					switch (side) {
						case NODE_SIDE_LEFT:
						{
							gdouble cx = 0.0;
							gdouble cy = 0.0;
							gdouble cw = 0.0;
							gdouble ch = 0.0;
							Node* _tmp23_;
							gdouble _tmp24_ = 0.0;
							gdouble _tmp25_ = 0.0;
							gdouble _tmp26_ = 0.0;
							gdouble _tmp27_ = 0.0;
							Node* _tmp28_;
							gint* _tmp29_;
							_tmp23_ = n;
							node_bbox (_tmp23_, &_tmp24_, &_tmp25_, &_tmp26_, &_tmp27_);
							cx = _tmp24_;
							cy = _tmp25_;
							cw = _tmp26_;
							ch = _tmp27_;
							_tmp28_ = n;
							_tmp29_ = margin;
							node_set_posx (_tmp28_, (px - (*_tmp29_)) - cw);
							break;
						}
						case NODE_SIDE_RIGHT:
						{
							Node* _tmp30_;
							gint* _tmp31_;
							_tmp30_ = n;
							_tmp31_ = margin;
							node_set_posx (_tmp30_, (px + pw) + (*_tmp31_));
							break;
						}
						case NODE_SIDE_TOP:
						{
							gdouble cx = 0.0;
							gdouble cy = 0.0;
							gdouble cw = 0.0;
							gdouble ch = 0.0;
							Node* _tmp32_;
							gdouble _tmp33_ = 0.0;
							gdouble _tmp34_ = 0.0;
							gdouble _tmp35_ = 0.0;
							gdouble _tmp36_ = 0.0;
							Node* _tmp37_;
							gint* _tmp38_;
							_tmp32_ = n;
							node_bbox (_tmp32_, &_tmp33_, &_tmp34_, &_tmp35_, &_tmp36_);
							cx = _tmp33_;
							cy = _tmp34_;
							cw = _tmp35_;
							ch = _tmp36_;
							_tmp37_ = n;
							_tmp38_ = margin;
							node_set_posy (_tmp37_, (py - (*_tmp38_)) - ch);
							break;
						}
						case NODE_SIDE_BOTTOM:
						{
							Node* _tmp39_;
							gint* _tmp40_;
							_tmp39_ = n;
							_tmp40_ = margin;
							node_set_posy (_tmp39_, (py + ph) + (*_tmp40_));
							break;
						}
						default:
						break;
					}
					_tmp41_ = n;
					layout_propagate_side (self, _tmp41_, side);
				}
				_g_object_unref0 (n);
			}
		}
	}
	_g_free0 (margin);
}

void
layout_propagate_side (Layout* self,
                       Node* parent,
                       NodeSide side)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->propagate_side) {
		_klass_->propagate_side (self, parent, side);
	}
}

static NodeSide
layout_real_get_side (Layout* self,
                      Node* n)
{
	NodeSide result;
	g_return_val_if_fail (n != NULL, 0);
	if (node_is_root (n)) {
		NodeSide _tmp0_;
		NodeSide _tmp1_;
		_tmp0_ = node_get_side (n);
		_tmp1_ = _tmp0_;
		result = _tmp1_;
		return result;
	} else {
		gdouble rx = 0.0;
		gdouble ry = 0.0;
		gdouble rw = 0.0;
		gdouble rh = 0.0;
		gdouble nx = 0.0;
		gdouble ny = 0.0;
		gdouble nw = 0.0;
		gdouble nh = 0.0;
		Node* _tmp2_;
		Node* _tmp3_;
		gdouble _tmp4_ = 0.0;
		gdouble _tmp5_ = 0.0;
		gdouble _tmp6_ = 0.0;
		gdouble _tmp7_ = 0.0;
		gdouble _tmp8_ = 0.0;
		gdouble _tmp9_ = 0.0;
		gdouble _tmp10_ = 0.0;
		gdouble _tmp11_ = 0.0;
		NodeSide _tmp12_;
		NodeSide _tmp13_;
		_tmp2_ = node_get_root (n);
		_tmp3_ = _tmp2_;
		node_bbox (_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_);
		rx = _tmp4_;
		ry = _tmp5_;
		rw = _tmp6_;
		rh = _tmp7_;
		_g_object_unref0 (_tmp3_);
		node_bbox (n, &_tmp8_, &_tmp9_, &_tmp10_, &_tmp11_);
		nx = _tmp8_;
		ny = _tmp9_;
		nw = _tmp10_;
		nh = _tmp11_;
		_tmp12_ = node_get_side (n);
		_tmp13_ = _tmp12_;
		if (node_side_horizontal (_tmp13_)) {
			NodeSide _tmp14_ = 0;
			if ((nx + (nw / 2)) > (rx + (rw / 2))) {
				_tmp14_ = NODE_SIDE_RIGHT;
			} else {
				_tmp14_ = NODE_SIDE_LEFT;
			}
			result = _tmp14_;
			return result;
		} else {
			NodeSide _tmp15_ = 0;
			if ((ny + (nh / 2)) > (ry + (rh / 2))) {
				_tmp15_ = NODE_SIDE_BOTTOM;
			} else {
				_tmp15_ = NODE_SIDE_TOP;
			}
			result = _tmp15_;
			return result;
		}
	}
}

NodeSide
layout_get_side (Layout* self,
                 Node* n)
{
	LayoutClass* _klass_;
	g_return_val_if_fail (self != NULL, 0);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->get_side) {
		return _klass_->get_side (self, n);
	}
	return 0;
}

static void
layout_real_set_side (Layout* self,
                      Node* current)
{
	g_return_if_fail (current != NULL);
	if (!node_is_root (current)) {
		NodeSide side = 0;
		NodeSide _tmp0_;
		NodeSide _tmp1_;
		side = layout_get_side (self, current);
		_tmp0_ = node_get_side (current);
		_tmp1_ = _tmp0_;
		if (_tmp1_ != side) {
			node_set_side (current, side);
			layout_propagate_side (self, current, side);
		}
	}
}

void
layout_set_side (Layout* self,
                 Node* current)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->set_side) {
		_klass_->set_side (self, current);
	}
}

void
layout_apply_margin (Layout* self,
                     Node* n)
{
	Node* _tmp0_;
	Node* _tmp1_;
	gdouble px = 0.0;
	gdouble py = 0.0;
	gdouble pw = 0.0;
	gdouble ph = 0.0;
	gint* margin = NULL;
	Node* _tmp2_;
	Node* _tmp3_;
	Style* _tmp4_;
	Style* _tmp5_;
	gint* _tmp6_;
	gint* _tmp7_;
	gint* _tmp8_;
	Node* _tmp9_;
	Node* _tmp10_;
	gdouble _tmp11_ = 0.0;
	gdouble _tmp12_ = 0.0;
	gdouble _tmp13_ = 0.0;
	gdouble _tmp14_ = 0.0;
	NodeSide _tmp15_;
	NodeSide _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (n != NULL);
	_tmp0_ = node_get_parent (n);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		return;
	}
	_tmp2_ = node_get_parent (n);
	_tmp3_ = _tmp2_;
	_tmp4_ = node_get_style (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = style_get_branch_margin (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = __int_dup0 (_tmp7_);
	margin = _tmp8_;
	_tmp9_ = node_get_parent (n);
	_tmp10_ = _tmp9_;
	node_bbox (_tmp10_, &_tmp11_, &_tmp12_, &_tmp13_, &_tmp14_);
	px = _tmp11_;
	py = _tmp12_;
	pw = _tmp13_;
	ph = _tmp14_;
	_tmp15_ = node_get_side (n);
	_tmp16_ = _tmp15_;
	switch (_tmp16_) {
		case NODE_SIDE_LEFT:
		{
			gdouble cx = 0.0;
			gdouble cy = 0.0;
			gdouble cw = 0.0;
			gdouble ch = 0.0;
			gdouble _tmp17_ = 0.0;
			gdouble _tmp18_ = 0.0;
			gdouble _tmp19_ = 0.0;
			gdouble _tmp20_ = 0.0;
			gint* _tmp21_;
			node_bbox (n, &_tmp17_, &_tmp18_, &_tmp19_, &_tmp20_);
			cx = _tmp17_;
			cy = _tmp18_;
			cw = _tmp19_;
			ch = _tmp20_;
			_tmp21_ = margin;
			node_set_posx (n, px - (cw + (*_tmp21_)));
			break;
		}
		case NODE_SIDE_RIGHT:
		{
			gint* _tmp22_;
			_tmp22_ = margin;
			node_set_posx (n, px + (pw + (*_tmp22_)));
			break;
		}
		case NODE_SIDE_TOP:
		{
			gdouble cx = 0.0;
			gdouble cy = 0.0;
			gdouble cw = 0.0;
			gdouble ch = 0.0;
			gdouble _tmp23_ = 0.0;
			gdouble _tmp24_ = 0.0;
			gdouble _tmp25_ = 0.0;
			gdouble _tmp26_ = 0.0;
			gint* _tmp27_;
			node_bbox (n, &_tmp23_, &_tmp24_, &_tmp25_, &_tmp26_);
			cx = _tmp23_;
			cy = _tmp24_;
			cw = _tmp25_;
			ch = _tmp26_;
			_tmp27_ = margin;
			node_set_posy (n, py - (ch + (*_tmp27_)));
			break;
		}
		case NODE_SIDE_BOTTOM:
		{
			gint* _tmp28_;
			_tmp28_ = margin;
			node_set_posy (n, py + (ph + (*_tmp28_)));
			break;
		}
		default:
		break;
	}
	_g_free0 (margin);
}

static void
layout_real_handle_update_by_edit (Layout* self,
                                   Node* n,
                                   gdouble diffw,
                                   gdouble diffh)
{
	gdouble adjust = 0.0;
	NodeSide _tmp0_;
	NodeSide _tmp1_;
	NodeBounds* _tmp79_;
	NodeBounds* _tmp80_;
	g_return_if_fail (n != NULL);
	adjust = 0 - (layout_get_adjust (self, n) / 2);
	_tmp0_ = node_get_side (n);
	_tmp1_ = _tmp0_;
	if (node_side_horizontal (_tmp1_)) {
		if (diffh != ((gdouble) 0)) {
			node_adjust_posy_only (n, 0 - (diffh / 2));
		}
		if (diffw != ((gdouble) 0)) {
			if (node_is_root (n)) {
				node_adjust_posx_only (n, 0 - (diffw / 2));
				{
					gint i = 0;
					i = 0;
					{
						gboolean _tmp2_ = FALSE;
						_tmp2_ = TRUE;
						while (TRUE) {
							GArray* _tmp4_;
							GArray* _tmp5_;
							gboolean _tmp6_;
							Node* child = NULL;
							GArray* _tmp7_;
							GArray* _tmp8_;
							Node* _tmp9_;
							Node* _tmp10_;
							Node* _tmp11_;
							Node* _tmp12_;
							NodeSide _tmp13_;
							NodeSide _tmp14_;
							if (!_tmp2_) {
								gint _tmp3_;
								_tmp3_ = i;
								i = _tmp3_ + 1;
							}
							_tmp2_ = FALSE;
							_tmp4_ = node_children (n);
							_tmp5_ = _tmp4_;
							_tmp6_ = !(((guint) i) < _tmp5_->len);
							_g_array_unref0 (_tmp5_);
							if (_tmp6_) {
								break;
							}
							_tmp7_ = node_children (n);
							_tmp8_ = _tmp7_;
							_tmp9_ = g_array_index (_tmp8_, Node*, (guint) i);
							_tmp10_ = _g_object_ref0 (_tmp9_);
							_tmp11_ = _tmp10_;
							_g_array_unref0 (_tmp8_);
							child = _tmp11_;
							_tmp12_ = child;
							_tmp13_ = node_get_side (_tmp12_);
							_tmp14_ = _tmp13_;
							if (_tmp14_ == NODE_SIDE_LEFT) {
								Node* _tmp15_;
								Node* _tmp16_;
								gdouble _tmp17_;
								gdouble _tmp18_;
								_tmp15_ = child;
								_tmp16_ = child;
								_tmp17_ = node_get_posx (_tmp16_);
								_tmp18_ = _tmp17_;
								node_set_posx (_tmp16_, _tmp18_ - (diffw / 2));
							} else {
								Node* _tmp19_;
								Node* _tmp20_;
								gdouble _tmp21_;
								gdouble _tmp22_;
								_tmp19_ = child;
								_tmp20_ = child;
								_tmp21_ = node_get_posx (_tmp20_);
								_tmp22_ = _tmp21_;
								node_set_posx (_tmp20_, _tmp22_ + (diffw / 2));
							}
							_g_object_unref0 (child);
						}
					}
				}
			} else {
				NodeSide _tmp23_;
				NodeSide _tmp24_;
				_tmp23_ = node_get_side (n);
				_tmp24_ = _tmp23_;
				if (_tmp24_ == NODE_SIDE_LEFT) {
					gdouble _tmp25_;
					gdouble _tmp26_;
					_tmp25_ = node_get_posx (n);
					_tmp26_ = _tmp25_;
					node_set_posx (n, _tmp26_ - diffw);
				} else {
					{
						gint i = 0;
						i = 0;
						{
							gboolean _tmp27_ = FALSE;
							_tmp27_ = TRUE;
							while (TRUE) {
								GArray* _tmp29_;
								GArray* _tmp30_;
								gboolean _tmp31_;
								GArray* _tmp32_;
								GArray* _tmp33_;
								Node* _tmp34_;
								GArray* _tmp35_;
								GArray* _tmp36_;
								Node* _tmp37_;
								gdouble _tmp38_;
								gdouble _tmp39_;
								if (!_tmp27_) {
									gint _tmp28_;
									_tmp28_ = i;
									i = _tmp28_ + 1;
								}
								_tmp27_ = FALSE;
								_tmp29_ = node_children (n);
								_tmp30_ = _tmp29_;
								_tmp31_ = !(((guint) i) < _tmp30_->len);
								_g_array_unref0 (_tmp30_);
								if (_tmp31_) {
									break;
								}
								_tmp32_ = node_children (n);
								_tmp33_ = _tmp32_;
								_tmp34_ = g_array_index (_tmp33_, Node*, (guint) i);
								_tmp35_ = node_children (n);
								_tmp36_ = _tmp35_;
								_tmp37_ = g_array_index (_tmp36_, Node*, (guint) i);
								_tmp38_ = node_get_posx (_tmp37_);
								_tmp39_ = _tmp38_;
								node_set_posx (_tmp37_, _tmp39_ + diffw);
								_g_array_unref0 (_tmp36_);
								_g_array_unref0 (_tmp33_);
							}
						}
					}
				}
			}
		}
	} else {
		if (diffw != ((gdouble) 0)) {
			node_adjust_posx_only (n, 0 - (diffw / 2));
		}
		if (diffh != ((gdouble) 0)) {
			if (node_is_root (n)) {
				gdouble _tmp40_;
				gdouble _tmp41_;
				_tmp40_ = node_get_posy (n);
				_tmp41_ = _tmp40_;
				node_set_posy (n, _tmp41_ - (diffh / 2));
				{
					gint i = 0;
					i = 0;
					{
						gboolean _tmp42_ = FALSE;
						_tmp42_ = TRUE;
						while (TRUE) {
							GArray* _tmp44_;
							GArray* _tmp45_;
							gboolean _tmp46_;
							Node* child = NULL;
							GArray* _tmp47_;
							GArray* _tmp48_;
							Node* _tmp49_;
							Node* _tmp50_;
							Node* _tmp51_;
							NodeSide _tmp52_;
							NodeSide _tmp53_;
							if (!_tmp42_) {
								gint _tmp43_;
								_tmp43_ = i;
								i = _tmp43_ + 1;
							}
							_tmp42_ = FALSE;
							_tmp44_ = node_children (n);
							_tmp45_ = _tmp44_;
							_tmp46_ = !(((guint) i) < _tmp45_->len);
							_g_array_unref0 (_tmp45_);
							if (_tmp46_) {
								break;
							}
							_tmp47_ = node_children (n);
							_tmp48_ = _tmp47_;
							_tmp49_ = g_array_index (_tmp48_, Node*, (guint) i);
							_tmp50_ = _g_object_ref0 (_tmp49_);
							_tmp51_ = _tmp50_;
							_g_array_unref0 (_tmp48_);
							child = _tmp51_;
							_tmp52_ = node_get_side (n);
							_tmp53_ = _tmp52_;
							if (_tmp53_ == NODE_SIDE_TOP) {
								Node* _tmp54_;
								Node* _tmp55_;
								gdouble _tmp56_;
								gdouble _tmp57_;
								_tmp54_ = child;
								_tmp55_ = child;
								_tmp56_ = node_get_posy (_tmp55_);
								_tmp57_ = _tmp56_;
								node_set_posy (_tmp55_, _tmp57_ - (diffh / 2));
							} else {
								Node* _tmp58_;
								Node* _tmp59_;
								gdouble _tmp60_;
								gdouble _tmp61_;
								_tmp58_ = child;
								_tmp59_ = child;
								_tmp60_ = node_get_posy (_tmp59_);
								_tmp61_ = _tmp60_;
								node_set_posy (_tmp59_, _tmp61_ + (diffh / 2));
							}
							_g_object_unref0 (child);
						}
					}
				}
			} else {
				NodeSide _tmp62_;
				NodeSide _tmp63_;
				_tmp62_ = node_get_side (n);
				_tmp63_ = _tmp62_;
				if (_tmp63_ == NODE_SIDE_TOP) {
					gdouble _tmp64_;
					gdouble _tmp65_;
					_tmp64_ = node_get_posy (n);
					_tmp65_ = _tmp64_;
					node_set_posy (n, _tmp65_ - diffh);
				} else {
					{
						gint i = 0;
						i = 0;
						{
							gboolean _tmp66_ = FALSE;
							_tmp66_ = TRUE;
							while (TRUE) {
								GArray* _tmp68_;
								GArray* _tmp69_;
								gboolean _tmp70_;
								GArray* _tmp71_;
								GArray* _tmp72_;
								Node* _tmp73_;
								GArray* _tmp74_;
								GArray* _tmp75_;
								Node* _tmp76_;
								gdouble _tmp77_;
								gdouble _tmp78_;
								if (!_tmp66_) {
									gint _tmp67_;
									_tmp67_ = i;
									i = _tmp67_ + 1;
								}
								_tmp66_ = FALSE;
								_tmp68_ = node_children (n);
								_tmp69_ = _tmp68_;
								_tmp70_ = !(((guint) i) < _tmp69_->len);
								_g_array_unref0 (_tmp69_);
								if (_tmp70_) {
									break;
								}
								_tmp71_ = node_children (n);
								_tmp72_ = _tmp71_;
								_tmp73_ = g_array_index (_tmp72_, Node*, (guint) i);
								_tmp74_ = node_children (n);
								_tmp75_ = _tmp74_;
								_tmp76_ = g_array_index (_tmp75_, Node*, (guint) i);
								_tmp77_ = node_get_posy (_tmp76_);
								_tmp78_ = _tmp77_;
								node_set_posy (_tmp76_, _tmp78_ + diffh);
								_g_array_unref0 (_tmp75_);
								_g_array_unref0 (_tmp72_);
							}
						}
					}
				}
			}
		}
	}
	_tmp79_ = node_get_tree_bbox (n);
	_tmp80_ = _tmp79_;
	layout_adjust_tree_all (self, n, _tmp80_, adjust, "by_edit");
}

void
layout_handle_update_by_edit (Layout* self,
                              Node* n,
                              gdouble diffw,
                              gdouble diffh)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->handle_update_by_edit) {
		_klass_->handle_update_by_edit (self, n, diffw, diffh);
	}
}

static void
layout_real_handle_update_by_fold (Layout* self,
                                   Node* n)
{
	NodeBounds* _tmp0_;
	NodeBounds* _tmp1_;
	g_return_if_fail (n != NULL);
	_tmp0_ = node_get_tree_bbox (n);
	_tmp1_ = _tmp0_;
	layout_adjust_tree_all (self, n, _tmp1_, 0 - (layout_get_adjust (self, n) / 2), "by_fold");
}

void
layout_handle_update_by_fold (Layout* self,
                              Node* n)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->handle_update_by_fold) {
		_klass_->handle_update_by_fold (self, n);
	}
}

static gdouble
layout_real_get_insert_adjust (Layout* self,
                               Node* child)
{
	gdouble _tmp0_;
	gdouble _tmp1_;
	gdouble result;
	g_return_val_if_fail (child != NULL, -1.0);
	_tmp0_ = node_get_tree_size (child);
	_tmp1_ = _tmp0_;
	result = _tmp1_ / 2;
	return result;
}

gdouble
layout_get_insert_adjust (Layout* self,
                          Node* child)
{
	LayoutClass* _klass_;
	g_return_val_if_fail (self != NULL, -1.0);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->get_insert_adjust) {
		return _klass_->get_insert_adjust (self, child);
	}
	return -1.0;
}

static void
layout_real_handle_update_by_insert (Layout* self,
                                     Node* parent,
                                     Node* child,
                                     gint pos)
{
	gdouble ox = 0.0;
	gdouble oy = 0.0;
	gdouble ow = 0.0;
	gdouble oh = 0.0;
	gdouble adjust = 0.0;
	NodeBounds* cb = NULL;
	NodeBounds* _tmp0_;
	NodeBounds* _tmp1_;
	NodeBounds* _tmp2_;
	gdouble _tmp3_ = 0.0;
	gdouble _tmp4_ = 0.0;
	gdouble _tmp5_ = 0.0;
	gdouble _tmp6_ = 0.0;
	NodeBounds* _tmp78_;
	NodeBounds* _tmp79_;
	g_return_if_fail (parent != NULL);
	g_return_if_fail (child != NULL);
	layout_update_tree_size (self, child);
	_tmp0_ = node_get_tree_bbox (child);
	_tmp1_ = _tmp0_;
	_tmp2_ = _node_bounds_ref0 (_tmp1_);
	cb = _tmp2_;
	node_bbox (child, &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	ox = _tmp3_;
	oy = _tmp4_;
	ow = _tmp5_;
	oh = _tmp6_;
	layout_apply_margin (self, child);
	adjust = layout_get_insert_adjust (self, child);
	if (node_is_summary (child)) {
		gdouble xy1 = 0.0;
		gdouble xy2 = 0.0;
		gdouble _tmp7_ = 0.0;
		gdouble _tmp8_ = 0.0;
		NodeSide _tmp9_;
		NodeSide _tmp10_;
		summary_node_get_extents (IS_SUMMARY_NODE (child) ? ((SummaryNode*) child) : NULL, &_tmp7_, &_tmp8_);
		xy1 = _tmp7_;
		xy2 = _tmp8_;
		_tmp9_ = node_get_side (child);
		_tmp10_ = _tmp9_;
		if (node_side_horizontal (_tmp10_)) {
			node_set_posy (child, xy1 + (((xy2 - xy1) / 2) - (oh / 2)));
		} else {
			node_set_posx (child, xy1 + (((xy2 - xy1) / 2) - (ow / 2)));
		}
	} else {
		NodeSide _tmp11_;
		NodeSide _tmp12_;
		_tmp11_ = node_get_side (child);
		_tmp12_ = _tmp11_;
		if (node_side_count (parent, _tmp12_) == 1) {
			gdouble px = 0.0;
			gdouble py = 0.0;
			gdouble pw = 0.0;
			gdouble ph = 0.0;
			gdouble _tmp13_ = 0.0;
			gdouble _tmp14_ = 0.0;
			gdouble _tmp15_ = 0.0;
			gdouble _tmp16_ = 0.0;
			NodeSide _tmp17_;
			NodeSide _tmp18_;
			node_bbox (parent, &_tmp13_, &_tmp14_, &_tmp15_, &_tmp16_);
			px = _tmp13_;
			py = _tmp14_;
			pw = _tmp15_;
			ph = _tmp16_;
			_tmp17_ = node_get_side (child);
			_tmp18_ = _tmp17_;
			if (node_side_horizontal (_tmp18_)) {
				node_set_posy (child, py + ((ph / 2) - (oh / 2)));
			} else {
				node_set_posx (child, px + ((pw / 2) - (ow / 2)));
			}
		} else {
			gboolean _tmp19_ = FALSE;
			GArray* _tmp20_;
			GArray* _tmp21_;
			gboolean _tmp22_;
			_tmp20_ = node_children (parent);
			_tmp21_ = _tmp20_;
			_tmp22_ = ((guint) (pos + 1)) == _tmp21_->len;
			_g_array_unref0 (_tmp21_);
			if (_tmp22_) {
				_tmp19_ = TRUE;
			} else {
				GArray* _tmp23_;
				GArray* _tmp24_;
				Node* _tmp25_;
				NodeSide _tmp26_;
				NodeSide _tmp27_;
				NodeSide _tmp28_;
				NodeSide _tmp29_;
				_tmp23_ = node_children (parent);
				_tmp24_ = _tmp23_;
				_tmp25_ = g_array_index (_tmp24_, Node*, (guint) (pos + 1));
				_tmp26_ = node_get_side (_tmp25_);
				_tmp27_ = _tmp26_;
				_tmp28_ = node_get_side (child);
				_tmp29_ = _tmp28_;
				_tmp19_ = _tmp27_ != _tmp29_;
				_g_array_unref0 (_tmp24_);
			}
			if (_tmp19_) {
				NodeBounds* sb = NULL;
				GArray* _tmp30_;
				GArray* _tmp31_;
				Node* _tmp32_;
				NodeSide _tmp33_;
				NodeSide _tmp34_;
				NodeBounds* _tmp35_;
				NodeBounds* _tmp36_;
				NodeSide _tmp37_;
				NodeSide _tmp38_;
				_tmp30_ = node_children (parent);
				_tmp31_ = _tmp30_;
				_tmp32_ = g_array_index (_tmp31_, Node*, (guint) (pos - 1));
				_tmp33_ = node_get_side (child);
				_tmp34_ = _tmp33_;
				_tmp35_ = layout_bbox (self, _tmp32_, (gint) _tmp34_, "insert a");
				_tmp36_ = _tmp35_;
				_g_array_unref0 (_tmp31_);
				sb = _tmp36_;
				_tmp37_ = node_get_side (child);
				_tmp38_ = _tmp37_;
				if (node_side_horizontal (_tmp38_)) {
					NodeBounds* _tmp39_;
					gdouble _tmp40_;
					gdouble _tmp41_;
					NodeBounds* _tmp42_;
					gdouble _tmp43_;
					gdouble _tmp44_;
					NodeBounds* _tmp45_;
					gdouble _tmp46_;
					gdouble _tmp47_;
					_tmp39_ = sb;
					_tmp40_ = node_bounds_get_y (_tmp39_);
					_tmp41_ = _tmp40_;
					_tmp42_ = sb;
					_tmp43_ = node_bounds_get_height (_tmp42_);
					_tmp44_ = _tmp43_;
					_tmp45_ = cb;
					_tmp46_ = node_bounds_get_y (_tmp45_);
					_tmp47_ = _tmp46_;
					node_set_posy (child, ((_tmp41_ + _tmp44_) + (oy - _tmp47_)) - adjust);
				} else {
					NodeBounds* _tmp48_;
					gdouble _tmp49_;
					gdouble _tmp50_;
					NodeBounds* _tmp51_;
					gdouble _tmp52_;
					gdouble _tmp53_;
					NodeBounds* _tmp54_;
					gdouble _tmp55_;
					gdouble _tmp56_;
					_tmp48_ = sb;
					_tmp49_ = node_bounds_get_x (_tmp48_);
					_tmp50_ = _tmp49_;
					_tmp51_ = sb;
					_tmp52_ = node_bounds_get_width (_tmp51_);
					_tmp53_ = _tmp52_;
					_tmp54_ = cb;
					_tmp55_ = node_bounds_get_x (_tmp54_);
					_tmp56_ = _tmp55_;
					node_set_posx (child, ((_tmp50_ + _tmp53_) + (ox - _tmp56_)) - adjust);
				}
				_node_bounds_unref0 (sb);
			} else {
				NodeBounds* sb = NULL;
				GArray* _tmp57_;
				GArray* _tmp58_;
				Node* _tmp59_;
				NodeSide _tmp60_;
				NodeSide _tmp61_;
				NodeBounds* _tmp62_;
				NodeBounds* _tmp63_;
				NodeSide _tmp64_;
				NodeSide _tmp65_;
				_tmp57_ = node_children (parent);
				_tmp58_ = _tmp57_;
				_tmp59_ = g_array_index (_tmp58_, Node*, (guint) (pos + 1));
				_tmp60_ = node_get_side (child);
				_tmp61_ = _tmp60_;
				_tmp62_ = layout_bbox (self, _tmp59_, (gint) _tmp61_, "insert b");
				_tmp63_ = _tmp62_;
				_g_array_unref0 (_tmp58_);
				sb = _tmp63_;
				_tmp64_ = node_get_side (child);
				_tmp65_ = _tmp64_;
				if (node_side_horizontal (_tmp65_)) {
					NodeBounds* _tmp66_;
					gdouble _tmp67_;
					gdouble _tmp68_;
					NodeBounds* _tmp69_;
					gdouble _tmp70_;
					gdouble _tmp71_;
					_tmp66_ = sb;
					_tmp67_ = node_bounds_get_y (_tmp66_);
					_tmp68_ = _tmp67_;
					_tmp69_ = cb;
					_tmp70_ = node_bounds_get_y (_tmp69_);
					_tmp71_ = _tmp70_;
					node_set_posy (child, (_tmp68_ + (oy - _tmp71_)) - adjust);
				} else {
					NodeBounds* _tmp72_;
					gdouble _tmp73_;
					gdouble _tmp74_;
					NodeBounds* _tmp75_;
					gdouble _tmp76_;
					gdouble _tmp77_;
					_tmp72_ = sb;
					_tmp73_ = node_bounds_get_x (_tmp72_);
					_tmp74_ = _tmp73_;
					_tmp75_ = cb;
					_tmp76_ = node_bounds_get_x (_tmp75_);
					_tmp77_ = _tmp76_;
					node_set_posx (child, (_tmp74_ + (ox - _tmp77_)) - adjust);
				}
				_node_bounds_unref0 (sb);
			}
		}
	}
	_tmp78_ = node_get_tree_bbox (child);
	_tmp79_ = _tmp78_;
	layout_adjust_tree_all (self, child, _tmp79_, 0 - adjust, "by_insert");
	_node_bounds_unref0 (cb);
}

void
layout_handle_update_by_insert (Layout* self,
                                Node* parent,
                                Node* child,
                                gint pos)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->handle_update_by_insert) {
		_klass_->handle_update_by_insert (self, parent, child, pos);
	}
}

static void
layout_real_handle_update_by_delete (Layout* self,
                                     Node* parent,
                                     gint index,
                                     NodeSide side,
                                     gdouble size)
{
	gdouble adjust = 0.0;
	NodeBounds* _tmp25_;
	NodeBounds* _tmp26_;
	g_return_if_fail (parent != NULL);
	adjust = size / 2;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				GArray* _tmp3_;
				gboolean _tmp4_;
				Node* n = NULL;
				GArray* _tmp5_;
				GArray* _tmp6_;
				Node* _tmp7_;
				Node* _tmp8_;
				Node* _tmp9_;
				Node* _tmp10_;
				NodeSide _tmp11_;
				NodeSide _tmp12_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = node_children (parent);
				_tmp3_ = _tmp2_;
				_tmp4_ = !(((guint) i) < _tmp3_->len);
				_g_array_unref0 (_tmp3_);
				if (_tmp4_) {
					break;
				}
				_tmp5_ = node_children (parent);
				_tmp6_ = _tmp5_;
				_tmp7_ = g_array_index (_tmp6_, Node*, (guint) i);
				_tmp8_ = _g_object_ref0 (_tmp7_);
				_tmp9_ = _tmp8_;
				_g_array_unref0 (_tmp6_);
				n = _tmp9_;
				_tmp10_ = n;
				_tmp11_ = node_get_side (_tmp10_);
				_tmp12_ = _tmp11_;
				if (_tmp12_ == side) {
					gdouble _tmp13_ = 0.0;
					gdouble current_adjust = 0.0;
					Node* _tmp14_;
					NodeSide _tmp15_;
					NodeSide _tmp16_;
					if (i >= index) {
						_tmp13_ = 0 - adjust;
					} else {
						_tmp13_ = adjust;
					}
					current_adjust = _tmp13_;
					_tmp14_ = n;
					_tmp15_ = node_get_side (_tmp14_);
					_tmp16_ = _tmp15_;
					if (node_side_horizontal (_tmp16_)) {
						Node* _tmp17_;
						Node* _tmp18_;
						gdouble _tmp19_;
						gdouble _tmp20_;
						_tmp17_ = n;
						_tmp18_ = n;
						_tmp19_ = node_get_posy (_tmp18_);
						_tmp20_ = _tmp19_;
						node_set_posy (_tmp18_, _tmp20_ + current_adjust);
					} else {
						Node* _tmp21_;
						Node* _tmp22_;
						gdouble _tmp23_;
						gdouble _tmp24_;
						_tmp21_ = n;
						_tmp22_ = n;
						_tmp23_ = node_get_posx (_tmp22_);
						_tmp24_ = _tmp23_;
						node_set_posx (_tmp22_, _tmp24_ + current_adjust);
					}
				}
				_g_object_unref0 (n);
			}
		}
	}
	_tmp25_ = node_get_tree_bbox (parent);
	_tmp26_ = _tmp25_;
	layout_adjust_tree_all (self, parent, _tmp26_, 0 - (layout_get_adjust (self, parent) / 2), "by_delete");
}

void
layout_handle_update_by_delete (Layout* self,
                                Node* parent,
                                gint index,
                                NodeSide side,
                                gdouble size)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->handle_update_by_delete) {
		_klass_->handle_update_by_delete (self, parent, index, side, size);
	}
}

static void
layout_real_position_root (Layout* self,
                           Node* last,
                           Node* n)
{
	NodeBounds* nb = NULL;
	NodeBounds* _tmp0_;
	NodeBounds* _tmp1_;
	NodeBounds* _tmp2_;
	gdouble _tmp3_;
	gdouble _tmp4_;
	gdouble _tmp5_;
	gdouble _tmp6_;
	gdouble _tmp7_;
	gdouble _tmp8_;
	g_return_if_fail (last != NULL);
	g_return_if_fail (n != NULL);
	_tmp0_ = node_get_tree_bbox (last);
	_tmp1_ = _tmp0_;
	_tmp2_ = _node_bounds_ref0 (_tmp1_);
	nb = _tmp2_;
	_tmp3_ = node_get_posx (last);
	_tmp4_ = _tmp3_;
	node_set_posx (n, _tmp4_);
	_tmp5_ = node_bounds_get_y (nb);
	_tmp6_ = _tmp5_;
	_tmp7_ = node_bounds_get_height (nb);
	_tmp8_ = _tmp7_;
	node_set_posy (n, (_tmp6_ + _tmp8_) + self->_rt_gap);
	_node_bounds_unref0 (nb);
}

void
layout_position_root (Layout* self,
                      Node* last,
                      Node* n)
{
	LayoutClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = LAYOUT_GET_CLASS (self);
	if (_klass_->position_root) {
		_klass_->position_root (self, last, n);
	}
}

const gchar*
layout_get_name (Layout* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
layout_set_name (Layout* self,
                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = layout_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, layout_properties[LAYOUT_NAME_PROPERTY]);
	}
}

const gchar*
layout_get_light_icon (Layout* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_light_icon;
	result = _tmp0_;
	return result;
}

void
layout_set_light_icon (Layout* self,
                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = layout_get_light_icon (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_light_icon);
		self->priv->_light_icon = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, layout_properties[LAYOUT_LIGHT_ICON_PROPERTY]);
	}
}

const gchar*
layout_get_dark_icon (Layout* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_dark_icon;
	result = _tmp0_;
	return result;
}

void
layout_set_dark_icon (Layout* self,
                      const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = layout_get_dark_icon (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_dark_icon);
		self->priv->_dark_icon = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, layout_properties[LAYOUT_DARK_ICON_PROPERTY]);
	}
}

gboolean
layout_get_balanceable (Layout* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_balanceable;
	return result;
}

void
layout_set_balanceable (Layout* self,
                        gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = layout_get_balanceable (self);
	if (old_value != value) {
		self->priv->_balanceable = value;
		g_object_notify_by_pspec ((GObject *) self, layout_properties[LAYOUT_BALANCEABLE_PROPERTY]);
	}
}

static void
layout_class_init (LayoutClass * klass,
                   gpointer klass_data)
{
	layout_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &Layout_private_offset);
	((LayoutClass *) klass)->is_manual = (gboolean (*) (Layout*)) layout_real_is_manual;
	((LayoutClass *) klass)->side_mapping = (NodeSide (*) (Layout*, NodeSide)) layout_real_side_mapping;
	((LayoutClass *) klass)->initialize = (void (*) (Layout*, Node*)) layout_real_initialize;
	((LayoutClass *) klass)->bbox = (NodeBounds* (*) (Layout*, Node*, gint, const gchar*)) layout_real_bbox;
	((LayoutClass *) klass)->adjust_tree = (void (*) (Layout*, Node*, gint, gint, gdouble)) layout_real_adjust_tree;
	((LayoutClass *) klass)->adjust_tree_all = (void (*) (Layout*, Node*, NodeBounds*, gdouble, const gchar*)) layout_real_adjust_tree_all;
	((LayoutClass *) klass)->propagate_side = (void (*) (Layout*, Node*, NodeSide)) layout_real_propagate_side;
	((LayoutClass *) klass)->get_side = (NodeSide (*) (Layout*, Node*)) layout_real_get_side;
	((LayoutClass *) klass)->set_side = (void (*) (Layout*, Node*)) layout_real_set_side;
	((LayoutClass *) klass)->handle_update_by_edit = (void (*) (Layout*, Node*, gdouble, gdouble)) layout_real_handle_update_by_edit;
	((LayoutClass *) klass)->handle_update_by_fold = (void (*) (Layout*, Node*)) layout_real_handle_update_by_fold;
	((LayoutClass *) klass)->get_insert_adjust = (gdouble (*) (Layout*, Node*)) layout_real_get_insert_adjust;
	((LayoutClass *) klass)->handle_update_by_insert = (void (*) (Layout*, Node*, Node*, gint)) layout_real_handle_update_by_insert;
	((LayoutClass *) klass)->handle_update_by_delete = (void (*) (Layout*, Node*, gint, NodeSide, gdouble)) layout_real_handle_update_by_delete;
	((LayoutClass *) klass)->position_root = (void (*) (Layout*, Node*, Node*)) layout_real_position_root;
	G_OBJECT_CLASS (klass)->get_property = _vala_layout_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_layout_set_property;
	G_OBJECT_CLASS (klass)->finalize = layout_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAYOUT_NAME_PROPERTY, layout_properties[LAYOUT_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAYOUT_LIGHT_ICON_PROPERTY, layout_properties[LAYOUT_LIGHT_ICON_PROPERTY] = g_param_spec_string ("light-icon", "light-icon", "light-icon", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAYOUT_DARK_ICON_PROPERTY, layout_properties[LAYOUT_DARK_ICON_PROPERTY] = g_param_spec_string ("dark-icon", "dark-icon", "dark-icon", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), LAYOUT_BALANCEABLE_PROPERTY, layout_properties[LAYOUT_BALANCEABLE_PROPERTY] = g_param_spec_boolean ("balanceable", "balanceable", "balanceable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
layout_instance_init (Layout * self,
                      gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	self->priv = layout_get_instance_private (self);
	self->_rt_gap = (gdouble) 100;
	_tmp0_ = g_strdup ("");
	self->priv->_name = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_light_icon = _tmp1_;
	_tmp2_ = g_strdup ("");
	self->priv->_dark_icon = _tmp2_;
	self->priv->_balanceable = FALSE;
}

static void
layout_finalize (GObject * obj)
{
	Layout * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_LAYOUT, Layout);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_light_icon);
	_g_free0 (self->priv->_dark_icon);
	G_OBJECT_CLASS (layout_parent_class)->finalize (obj);
}

static GType
layout_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LayoutClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) layout_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Layout), 0, (GInstanceInitFunc) layout_instance_init, NULL };
	GType layout_type_id;
	layout_type_id = g_type_register_static (G_TYPE_OBJECT, "Layout", &g_define_type_info, 0);
	Layout_private_offset = g_type_add_instance_private (layout_type_id, sizeof (LayoutPrivate));
	return layout_type_id;
}

GType
layout_get_type (void)
{
	static volatile gsize layout_type_id__once = 0;
	if (g_once_init_enter (&layout_type_id__once)) {
		GType layout_type_id;
		layout_type_id = layout_get_type_once ();
		g_once_init_leave (&layout_type_id__once, layout_type_id);
	}
	return layout_type_id__once;
}

static void
_vala_layout_get_property (GObject * object,
                           guint property_id,
                           GValue * value,
                           GParamSpec * pspec)
{
	Layout * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_LAYOUT, Layout);
	switch (property_id) {
		case LAYOUT_NAME_PROPERTY:
		g_value_set_string (value, layout_get_name (self));
		break;
		case LAYOUT_LIGHT_ICON_PROPERTY:
		g_value_set_string (value, layout_get_light_icon (self));
		break;
		case LAYOUT_DARK_ICON_PROPERTY:
		g_value_set_string (value, layout_get_dark_icon (self));
		break;
		case LAYOUT_BALANCEABLE_PROPERTY:
		g_value_set_boolean (value, layout_get_balanceable (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_layout_set_property (GObject * object,
                           guint property_id,
                           const GValue * value,
                           GParamSpec * pspec)
{
	Layout * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_LAYOUT, Layout);
	switch (property_id) {
		case LAYOUT_NAME_PROPERTY:
		layout_set_name (self, g_value_get_string (value));
		break;
		case LAYOUT_LIGHT_ICON_PROPERTY:
		layout_set_light_icon (self, g_value_get_string (value));
		break;
		case LAYOUT_DARK_ICON_PROPERTY:
		layout_set_dark_icon (self, g_value_get_string (value));
		break;
		case LAYOUT_BALANCEABLE_PROPERTY:
		layout_set_balanceable (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

