From ceeaa1172fad4634e4d57c812e7c82f883eed29c Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 7 Jan 2019 23:13:57 +0100 Subject: Drawn nicer loop links. --- src/gtkext/graph/cluster.c | 106 +++++---------------------------------------- 1 file changed, 12 insertions(+), 94 deletions(-) diff --git a/src/gtkext/graph/cluster.c b/src/gtkext/graph/cluster.c index 8053e54..70d58fa 100644 --- a/src/gtkext/graph/cluster.c +++ b/src/gtkext/graph/cluster.c @@ -216,13 +216,13 @@ static void exit_vspace_manager(vspace_manager_t *); static void extend_vspace_manager(vspace_manager_t *, leaving_link_t *, incoming_link_t *, GdkPoint *); /* Détermine l'emplacement requis pour les espaces latéraux. */ -static void compute_vspace_manager_needed_alloc(const vspace_manager_t *, bool, bool, GtkAllocation *); +static void compute_vspace_manager_needed_alloc(const vspace_manager_t *, GtkAllocation *); /* Réorganise au besoin les liens de boucle entre blocs. */ static void sort_incoming_links_for_vspace_manager(vspace_manager_t *); /* Détermine les abscisses de tous les liens en place. */ -static void compute_loop_link_x_with_vspace_manager(vspace_manager_t *, bool, GGraphCluster *); +static void compute_loop_link_x_with_vspace_manager(vspace_manager_t *, GGraphCluster *); /* Détermine les ordonnées de tous les liens en place. */ static void compute_loop_link_y_with_vspace_manager(vspace_manager_t *, GGraphCluster *); @@ -981,39 +981,6 @@ static void compute_graph_rank_needed_alloc(const graph_rank_t *grank, bool last /****************************************************************************** * * -* Paramètres : grank = ensemble de descendants d'un même rang. * -* * -* Description : Indique si un espace horizontal final est prévu en bas. * -* * -* Retour : true si l'étage comporte une zone pour liens de boucle. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool has_graph_rank_ending_vspace(const graph_rank_t *grank) -{ - bool result; /* Bilan à retourner */ - size_t i; /* Boucle de parcours */ - GGraphCluster *cluster; /* Bloc à analyser */ - - result = false; - - for (i = 0; i < grank->count && !result; i++) - { - cluster = grank->clusters[i]; - - result = (cluster->vspaces.pending_count > 0); - - } - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : iter = début de la boucle de parcours. * * loop = nombre d'itérations à mener. * * base = position de base sur l'axe des abscisses. * @@ -1311,8 +1278,6 @@ static void extend_vspace_manager(vspace_manager_t *manager, leaving_link_t *fro /****************************************************************************** * * * Paramètres : manager = gestion des espaces latéraux à consulter. * -* top = le bloc courant est-il le principal ? * -* concat = la zone inférieuse s'ajoute à une similaire ? * * alloc = emplacement idéal pour l'affichage. [OUT] * * * * Description : Détermine l'emplacement requis pour les espaces latéraux. * @@ -1323,7 +1288,7 @@ static void extend_vspace_manager(vspace_manager_t *manager, leaving_link_t *fro * * ******************************************************************************/ -static void compute_vspace_manager_needed_alloc(const vspace_manager_t *manager, bool top, bool concat, GtkAllocation *alloc) +static void compute_vspace_manager_needed_alloc(const vspace_manager_t *manager, GtkAllocation *alloc) { gint width; /* Largeur supplémentaire */ @@ -1331,43 +1296,16 @@ static void compute_vspace_manager_needed_alloc(const vspace_manager_t *manager, width = 0; - if (manager->left_count > 0) - { - if (!top) - width += HORIZONTAL_MARGIN; - - width += (manager->left_count - 1) * LINK_MARGIN; + width += manager->left_count * LINK_MARGIN; - width += HORIZONTAL_MARGIN; - - } - - if (manager->right_count > 0) - { - width += HORIZONTAL_MARGIN; - - width += (manager->right_count - 1) * LINK_MARGIN; - - if (!top) - width += HORIZONTAL_MARGIN; - - } + width += manager->right_count * LINK_MARGIN; alloc->x -= width / 2; alloc->width += width; /* Extension de la hauteur */ - if (manager->pending_count > 0) - { - if (!concat) - alloc->height += VERTICAL_MARGIN; - - alloc->height += (manager->pending_count - 1) * LINK_MARGIN; - - alloc->height += VERTICAL_MARGIN; - - } + alloc->height += manager->pending_count * VERTICAL_MARGIN; } @@ -1421,7 +1359,6 @@ static void sort_incoming_links_for_vspace_manager(vspace_manager_t *manager) /****************************************************************************** * * * Paramètres : manager = structure à consulter. * -* top = le bloc courant est-il le principal ? * * cluster = graphique de blocs sur lequel s'appuyer. * * * * Description : Détermine les abscisses de tous les liens en place. * @@ -1432,7 +1369,7 @@ static void sort_incoming_links_for_vspace_manager(vspace_manager_t *manager) * * ******************************************************************************/ -static void compute_loop_link_x_with_vspace_manager(vspace_manager_t *manager, bool top, GGraphCluster *cluster) +static void compute_loop_link_x_with_vspace_manager(vspace_manager_t *manager, GGraphCluster *cluster) { GtkAllocation needed; /* Espace nécessaire et alloué */ size_t i; /* Boucle de parcours */ @@ -1447,9 +1384,6 @@ static void compute_loop_link_x_with_vspace_manager(vspace_manager_t *manager, b x = i * LINK_MARGIN; - if (!top) - x += HORIZONTAL_MARGIN; - booking->pts[0].x = needed.x + x; booking->pts[1].x = needed.x + x; @@ -1457,14 +1391,7 @@ static void compute_loop_link_x_with_vspace_manager(vspace_manager_t *manager, b if (manager->left_count > 0) { - if (!top) - x = HORIZONTAL_MARGIN; - else - x = 0; - - x += (manager->left_count - 1) * LINK_MARGIN; - - x += HORIZONTAL_MARGIN; + x = manager->left_count * LINK_MARGIN; /** * Si la routine est une boucle sans fin, @@ -1479,7 +1406,7 @@ static void compute_loop_link_x_with_vspace_manager(vspace_manager_t *manager, b { booking = manager->right[i]; - x = HORIZONTAL_MARGIN + i * LINK_MARGIN; + x = (i + 1) * LINK_MARGIN; booking->pts[0].x = x; booking->pts[1].x = x; @@ -1519,7 +1446,7 @@ static void compute_loop_link_y_with_vspace_manager(vspace_manager_t *manager, G * la fonction g_graph_cluster_compute_link_y_positions(). */ - booking->from->start[1].y = needed.y + needed.height - VERTICAL_MARGIN; + booking->from->start[1].y = needed.y + needed.height; /* Définition de l'ordonnée des points du lien */ @@ -2197,22 +2124,13 @@ static void g_graph_cluster_set_y(GGraphCluster *cluster, gint base) void g_graph_cluster_compute_needed_alloc(const GGraphCluster *cluster, GtkAllocation *alloc) { size_t i; /* Boucle de parcours */ - size_t level; /* Niveau du nouvel ensemble */ - bool concat; /* Redondance des espaces ? */ *alloc = cluster->alloc; for (i = 0; i < cluster->ranks_count; i++) compute_graph_rank_needed_alloc(&cluster->ranks[i], (i + 1) == cluster->ranks_count, alloc); - level = g_code_block_get_rank(cluster->block); - - if (cluster->ranks_count == 0) - concat = false; - else - concat = has_graph_rank_ending_vspace(&cluster->ranks[cluster->ranks_count - 1]); - - compute_vspace_manager_needed_alloc(&cluster->vspaces, level == 0, concat, alloc); + compute_vspace_manager_needed_alloc(&cluster->vspaces, alloc); } @@ -2409,7 +2327,7 @@ static void g_graph_cluster_compute_loop_link_x_positions(GGraphCluster *cluster /* Liens de boucle */ - compute_loop_link_x_with_vspace_manager(&cluster->vspaces, false /* FIXME */, cluster); + compute_loop_link_x_with_vspace_manager(&cluster->vspaces, cluster); /* Propagation des déterminations */ -- cgit v0.11.2-87-g4458