summaryrefslogtreecommitdiff
path: root/src/gtkext/graph/nodes/virtual.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/graph/nodes/virtual.c')
-rw-r--r--src/gtkext/graph/nodes/virtual.c95
1 files changed, 63 insertions, 32 deletions
diff --git a/src/gtkext/graph/nodes/virtual.c b/src/gtkext/graph/nodes/virtual.c
index e13dfc8..05a7063 100644
--- a/src/gtkext/graph/nodes/virtual.c
+++ b/src/gtkext/graph/nodes/virtual.c
@@ -129,7 +129,7 @@ static bool g_virtual_node_visit_flow_nodes(GVirtualNode *, graph_node_visitor_c
static GGraphNode *g_virtual_node_find_container(GVirtualNode *, GGraphNode *);
/* Définit les abscisses relatives du contenu d'un noeud. */
-static void g_virtual_node_setup_x_line(GVirtualNode *);
+static void g_virtual_node_setup_x_line(GVirtualNode *, GGraphNode *);
@@ -432,9 +432,46 @@ static void g_virtual_node_reset_position(GVirtualNode *node)
static void g_virtual_node_set_position(GVirtualNode *node, gint *x, gint *y)
{
+ gint old_x; /* Sauvegarde des abscisses */
+ gint old_y; /* Sauvegarde des ordonnées */
+ gint off_x; /* Décallage sur les abscisses */
+ gint off_y; /* Décallage sur les ordonnées */
+ gint pos_x; /* Nouvelle position #1 */
+ gint pos_y; /* Nouvelle position #2 */
+ size_t i; /* Boucle de parcours */
+
+
+ //if (x != NULL) printf("-- setX -- %p -> %d (old=%d)\n", node, *x, node->x);
+
+ old_x = node->x;
+ old_y = node->y;
+
+
+
if (x != NULL) node->x = *x;
if (y != NULL) node->y = *y;
+ off_x = (old_x != UNINITIALIZED_NODE_POS && node->x != UNINITIALIZED_NODE_POS ? node->x - old_x : 0);
+ off_y = (old_y != UNINITIALIZED_NODE_POS ? node->y - old_y : node->y);
+
+ //printf("offx = %d\n", off_x);
+
+
+ for (i = 0; i < node->count; i++)
+ {
+ g_graph_node_get_position(node->children[i], &pos_x, &pos_y);
+
+
+ if (x != NULL) pos_x += off_x;
+
+
+ g_graph_node_set_position(node->children[i], &pos_x, &pos_y);
+
+
+ }
+
+
+
}
@@ -477,7 +514,6 @@ static GtkAllocation g_virtual_node_get_allocation(const GVirtualNode *node)
GtkAllocation result; /* Valeurs à retourner */
gint margins; /* Bordures gauche et droite */
unsigned int last_rank; /* Détection de saut de rangs */
- size_t horiz_count; /* Quantité à l'horizontale */
size_t vert_count; /* Quantité à la verticale */
gint rank_width; /* Largeur d'un rang donné */
gint rank_height; /* Hauteur d'un rang donné */
@@ -503,7 +539,6 @@ static GtkAllocation g_virtual_node_get_allocation(const GVirtualNode *node)
last_rank = -1;
- horiz_count = 0;
vert_count = 0;
rank_width = 0;
@@ -513,41 +548,36 @@ static GtkAllocation g_virtual_node_get_allocation(const GVirtualNode *node)
{
alloc = g_graph_node_get_allocation(node->children[i]);
+ /* Prise en compte de l'étage précédent */
if (last_rank != g_graph_node_get_rank(node->children[i]))
{
last_rank = g_graph_node_get_rank(node->children[i]);
result.width = MAX(result.width, rank_width);
-
- /*
- if (horiz_count > 0)
- result.width = MAX(result.width, rank_width + (horiz_count - 1) * NODE_LEFT_MARGIN);
- */
-
result.height += rank_height;
rank_width = 0;
rank_height = 0;
- horiz_count = 0;
vert_count++;
}
- //rank_width += alloc.width;
- if (rank_width > 0) rank_width += NODE_LEFT_MARGIN;
- rank_width += alloc.width;
- rank_height = MAX(rank_height, alloc.height);
+ /* Mise à jour de l'étage courant */
+
+ if (node->x == UNINITIALIZED_NODE_POS)
+ {
+ rank_width += alloc.width;
+ if (rank_width > 0) rank_width += NODE_LEFT_MARGIN;
+ }
+ else
+ rank_width = MAX(alloc.x + alloc.width - node->x, rank_width);
- horiz_count++;
+ rank_height = MAX(rank_height, alloc.height);
}
result.width = MAX(result.width, rank_width);
- /*
- if (horiz_count > 0)
- result.width = MAX(result.width, rank_width + (horiz_count - 1) * NODE_LEFT_MARGIN);
- */
result.width += margins;
@@ -747,7 +777,8 @@ vspan_slot_t g_virtual_node_reserve_span(GVirtualNode *node, unsigned int r1, un
/******************************************************************************
* *
-* Paramètres : node = noeud d'encapsulation à traiter. *
+* Paramètres : node = noeud d'encapsulation à traiter. *
+* nodes = ensemble des noeuds en place. *
* *
* Description : Organise le contenu du noeud selon l'axe des abscisses. *
* *
@@ -757,13 +788,13 @@ vspan_slot_t g_virtual_node_reserve_span(GVirtualNode *node, unsigned int r1, un
* *
******************************************************************************/
-void g_virtual_node_organize_x_line(GVirtualNode *node)
+void g_virtual_node_organize_x_line(GVirtualNode *node, GGraphNode *nodes)
{
size_t i; /* Boucle de parcours */
gint min; /* Valeur minimale rencontrée */
gint x; /* Position d'un sous-noeud */
- g_virtual_node_setup_x_line(node);
+ g_virtual_node_setup_x_line(node, nodes);
min = 0;
@@ -783,7 +814,8 @@ void g_virtual_node_organize_x_line(GVirtualNode *node)
/******************************************************************************
* *
-* Paramètres : node = noeud d'encapsulation à traiter. *
+* Paramètres : node = noeud d'encapsulation à traiter. *
+* nodes = ensemble des noeuds en place. *
* *
* Description : Définit les abscisses relatives du contenu d'un noeud. *
* *
@@ -793,7 +825,7 @@ void g_virtual_node_organize_x_line(GVirtualNode *node)
* *
******************************************************************************/
-static void g_virtual_node_setup_x_line(GVirtualNode *node)
+static void g_virtual_node_setup_x_line(GVirtualNode *node, GGraphNode *nodes)
{
unsigned int rank_0; /* Rang du premier sous-noeud */
unsigned int rank_1; /* Rang du second sous-noeud */
@@ -852,15 +884,10 @@ static void g_virtual_node_setup_x_line(GVirtualNode *node)
/* Définitions éventuelles des emplacements liés */
if (G_IS_FLOW_NODE(child))
- {
-
+ g_flow_node_organize_x_line(G_FLOW_NODE(child), nodes);
- ;
-
-
- }
else if (G_IS_VIRTUAL_NODE(child))
- g_virtual_node_organize_x_line(G_VIRTUAL_NODE(child));
+ g_virtual_node_organize_x_line(G_VIRTUAL_NODE(child), nodes);
/*else BUG_ON(1); */
@@ -904,7 +931,11 @@ void g_virtual_node_offset_x_line(GVirtualNode *node, gint xoffset)
g_graph_node_get_position(child, &x, NULL);
- x += xoffset + padding;
+ printf("+++ [%p-%d/%p] offsetting %d(%d) + (%d / %d)\n",
+ node, g_graph_node_get_rank(G_GRAPH_NODE(node)), child,
+ node->x, G_GRAPH_NODE(node)->pending_x, x, x + xoffset + padding);
+
+ x += node->x + xoffset + padding;
g_graph_node_set_position(child, &x, NULL);
}