From bd8c461d2dcdc14fd9b2969cc832c33792fd38cd Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 17 Jul 2010 13:17:19 +0000 Subject: Restored the breakpoints in the GUI. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@173 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 7 +++++++ src/glibext/gcodebuffer.c | 27 ++++++++++++++++++++++++ src/glibext/gcodebuffer.h | 3 +++ src/gtkext/gtkblockview.c | 52 +++++++++++++++++++++++++++++------------------ 4 files changed, 69 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 395a95b..3ecbcc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +10-07-17 Cyrille Bagard + + * src/glibext/gcodebuffer.c: + * src/glibext/gcodebuffer.h: + * src/gtkext/gtkblockview.c: + Restore the breakpoints in the GUI. + 10-06-28 Cyrille Bagard * configure.ac: diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c index 75c2e94..3f9af35 100644 --- a/src/glibext/gcodebuffer.c +++ b/src/glibext/gcodebuffer.c @@ -483,3 +483,30 @@ void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, Gd } } + + +/****************************************************************************** +* * +* Paramètres : view = visualisation à consulter. * +* y = ordonnée comprise dans la ligne recherchée. * +* * +* Description : Fournit la ligne présente à une ordonnée donnée. * +* * +* Retour : Ligne retrouvée ou NULL si aucune. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GBufferLine *g_buffer_view_find_line_at(GBufferView *view, gint y) +{ + gint lheight; /* Hauteur d'une ligne */ + size_t index; /* Indice attendu */ + + lheight = g_buffer_view_get_line_height(view); + index = y / lheight; + + /* FIXME : à placer côté tampon ? */ + return (index < view->buffer->used ? view->buffer->lines[index] : NULL); + +} diff --git a/src/glibext/gcodebuffer.h b/src/glibext/gcodebuffer.h index 9460530..49b954d 100644 --- a/src/glibext/gcodebuffer.h +++ b/src/glibext/gcodebuffer.h @@ -97,6 +97,9 @@ void g_buffer_view_define_extra_drawing(GBufferView *, buffer_line_draw_fc, void /* Imprime la visualisation du tempon de code désassemblé. */ void g_buffer_view_draw(const GBufferView *, const GdkEventExpose *, GdkGC *, gint, gint); +/* Fournit la ligne présente à une ordonnée donnée. */ +GBufferLine *g_buffer_view_find_line_at(GBufferView *, gint); + #endif /* _GLIBEXT_GCODEBUFFER_H */ diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index 70cd8ea..5c5d0f6 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -43,6 +43,9 @@ #endif +static void gtk_block_view_compute_real_coord(GtkBlockView *view, gint *x, gint *y); + + /* -------------------------- INSERTION DIFFEREE DE LIGNES -------------------------- */ @@ -638,26 +641,35 @@ static gboolean gtk_block_view_button_press(GtkWidget *widget, GdkEventButton *e { gboolean result; /* Décision à retourner */ GtkBlockView *view; /* Composant GTK réel */ - GtkTextIter iter; /* Point d'insertion */ - GtkTextMark *mark; /* Marquage de ligne associée */ - GRenderingLine *line; /* Ligne de rendu */ + gint real_x; /* Abscisse réelle du point */ + gint real_y; /* Ordonnée réelle du point */ + GBufferLine *bline; /* Ligne intégrée au tampon */ + GRenderingLine *line; /* Ligne de rendu interne */ result = FALSE; -#if 0 - view = GTK_BLOCK_VIEW(widget); - gtk_text_layout_get_line_at_y(view->layout, &iter, event->y, NULL); - mark = gtk_text_iter_get_marks(&iter)->data; + view = GTK_BLOCK_VIEW(widget); - line = g_object_get_data(G_OBJECT(mark), "line"); + real_x = event->x; + real_y = event->y; + gtk_block_view_compute_real_coord(view, &real_x, &real_y); /* Clic dans la marge */ - if (event->type == GDK_BUTTON_PRESS && event->x < view->left_margin) + if (event->type == GDK_BUTTON_PRESS && real_x < view->left_margin) { - result = TRUE; - g_rendering_line_toggle_flag(line, RLF_BREAK_POINT); + bline = g_buffer_view_find_line_at(view->buffer_view, real_y); + + if (bline != NULL) + { + line = G_RENDERING_LINE(g_object_get_data(G_OBJECT(bline), "line")); + + result = TRUE; + g_rendering_line_toggle_flag(line, RLF_BREAK_POINT); + + } + } -#endif + return result; } @@ -733,11 +745,11 @@ static void gtk_block_view_compute_fake_coord(GtkBlockView *view, gint *x, gint static void gtk_block_view_compute_real_coord(GtkBlockView *view, gint *x, gint *y) { - if (GTK_BIN_VIEW(view)->hadjustment != NULL) + if (x != NULL && GTK_BIN_VIEW(view)->hadjustment != NULL) *x += gtk_adjustment_get_value(GTK_BIN_VIEW(view)->hadjustment); - if (GTK_BIN_VIEW(view)->vadjustment != NULL) - *y -= gtk_adjustment_get_value(GTK_BIN_VIEW(view)->vadjustment); + if (y != NULL && GTK_BIN_VIEW(view)->vadjustment != NULL) + *y += gtk_adjustment_get_value(GTK_BIN_VIEW(view)->vadjustment); } @@ -1039,11 +1051,11 @@ static void gtk_block_view_complete_building_content(GDelayedInsertion *insertio gdk_threads_enter(); /* Taille des marges */ -#if 0 - view->line_height = rect.height; - view->left_margin = 2 * rect.height; - view->left_text = -2.5 * rect.height; -#endif + + view->line_height = g_buffer_view_get_line_height(view->buffer_view); + view->left_margin = 2 * view->line_height; + view->left_text = -2.5 * view->line_height; + /* Validation finale */ gtk_block_view_recompute_size_request(view); -- cgit v0.11.2-87-g4458