summaryrefslogtreecommitdiff
path: root/src/gtkext/graph/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/graph/nodes')
-rw-r--r--src/gtkext/graph/nodes/flow.c28
-rw-r--r--src/gtkext/graph/nodes/virtual.c34
2 files changed, 57 insertions, 5 deletions
diff --git a/src/gtkext/graph/nodes/flow.c b/src/gtkext/graph/nodes/flow.c
index ca5dceb..2f822bd 100644
--- a/src/gtkext/graph/nodes/flow.c
+++ b/src/gtkext/graph/nodes/flow.c
@@ -351,6 +351,8 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
pos.direct_x -= (G_GRAPH_NODE(target)->alloc.width - G_GRAPH_NODE(node)->alloc.width) / 2;
+ pos.relative_ref = base;
+
size_t count_and_skip_loop(GFlowNode *n)
{
size_t counter;
@@ -364,7 +366,7 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
}
if (count_and_skip_loop(target) == 1)
- g_graph_node_set_pending_position(G_GRAPH_NODE(target), PPF_DIRECT_X, pos, base);
+ g_graph_node_set_pending_position(G_GRAPH_NODE(target), PPF_DIRECT_X, pos);
break;
@@ -377,8 +379,18 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
rank_b = g_flow_node_get_rank(target_b);
if (rank_a == rank_b)
+ {
+ /* On s'assure que le père est centré par rapport aux deux fils */
+
+ pos.left_node = G_GRAPH_NODE(target_a);
+ pos.right_node = G_GRAPH_NODE(target_b);
+
+ g_graph_node_set_pending_position(base, PPF_MIDDLE_OF, pos);
+
break;
+ }
+
/* Alignement d'un bloc lié */
if (rank_a > rank_b)
@@ -392,7 +404,8 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
if (container == NULL) container = G_GRAPH_NODE(target_b);
pos.left_margin = g_flow_node_get_slot_offset(node, false, &node->exits[0]);
- g_graph_node_set_pending_position(container, PPF_LEFT_MARGIN, pos, base);
+ pos.relative_ref = base;
+ g_graph_node_set_pending_position(container, PPF_LEFT_MARGIN, pos);
/* Trait vertical de l'autre côté... */
@@ -403,7 +416,9 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
pos.direct_x -= g_flow_node_get_slot_offset(target_a, true, dest_slot);
- g_graph_node_set_pending_position(G_GRAPH_NODE(target_a), PPF_DIRECT_X, pos, base);
+ pos.relative_ref = base;
+
+ g_graph_node_set_pending_position(G_GRAPH_NODE(target_a), PPF_DIRECT_X, pos);
}
else
@@ -417,7 +432,8 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
if (container == NULL) container = G_GRAPH_NODE(target_a);
pos.right_margin = g_flow_node_get_slot_offset(node, false, &node->exits[1]);
- g_graph_node_set_pending_position(container, PPF_RIGHT_MARGIN, pos, base);
+ pos.relative_ref = base;
+ g_graph_node_set_pending_position(container, PPF_RIGHT_MARGIN, pos);
/* Trait vertical de l'autre côté... */
@@ -428,7 +444,9 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
pos.direct_x -= g_flow_node_get_slot_offset(target_b, true, dest_slot);
- g_graph_node_set_pending_position(G_GRAPH_NODE(target_b), PPF_DIRECT_X, pos, base);
+ pos.relative_ref = base;
+
+ g_graph_node_set_pending_position(G_GRAPH_NODE(target_b), PPF_DIRECT_X, pos);
}
diff --git a/src/gtkext/graph/nodes/virtual.c b/src/gtkext/graph/nodes/virtual.c
index 894c6b6..62f5b42 100644
--- a/src/gtkext/graph/nodes/virtual.c
+++ b/src/gtkext/graph/nodes/virtual.c
@@ -528,6 +528,8 @@ static void g_virtual_node_apply_x_line(GVirtualNode *node)
size_t j; /* Boucle de parcours #2 */
gint width_sum; /* Largeur d'un étage traité */
gint x_pos; /* Abscisse à attribuer */
+ GGraphNode *ref_a; /* Accès rapide #1 */
+ GGraphNode *ref_b; /* Accès rapide #2 */
for (i = 0; i < node->lcount; i++)
{
@@ -559,6 +561,9 @@ static void g_virtual_node_apply_x_line(GVirtualNode *node)
}
+ else if (level->children[0]->pending_flag == PPF_MIDDLE_OF)
+ continue;
+
/* On traite les noeuds individuellement */
else
{
@@ -593,6 +598,35 @@ static void g_virtual_node_apply_x_line(GVirtualNode *node)
}
+ for (i = 0; i < node->lcount; i++)
+ {
+ level = &node->levels[i];
+
+ /* Si l'ensemble de l'étage doit être centré */
+ if (level->children[0]->pending_flag == PPF_MIDDLE_OF)
+ {
+ ref_a = level->children[0]->pending_pos.left_node;
+ ref_b = level->children[0]->pending_pos.right_node;
+
+ assert(g_graph_node_has_x_position(ref_a));
+ assert(g_graph_node_has_x_position(ref_b));
+
+ if (ref_a->alloc.x < ref_b->alloc.x)
+ {
+ ref_b = level->children[0]->pending_pos.left_node;
+ ref_a = level->children[0]->pending_pos.right_node;
+ }
+
+ x_pos = ref_a->alloc.x;
+ x_pos += (ref_b->alloc.x + ref_b->alloc.width - ref_a->alloc.x) / 2;
+ x_pos -= level->children[0]->alloc.width / 2;
+
+ g_graph_node_set_x_position(level->children[0], x_pos);
+
+ }
+
+ }
+
}