From 054d2d76f1951c20822286bce0128e60c26c4b9b Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 11 Apr 2015 22:34:59 +0000 Subject: Drawn a selection line on buffer views. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@510 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 11 +++++++++++ src/core/params.c | 3 +++ src/core/params.h | 1 + src/glibext/gcodebuffer.c | 38 ++++++++++++++++++++++++++------------ src/glibext/gcodebuffer.h | 2 +- src/gtkext/gtkbufferview.c | 19 +++++++++++++++---- 6 files changed, 57 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55e8dde..d08796b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +15-04-12 Cyrille Bagard + + * src/core/params.c: + * src/core/params.h: + Allow to configure the drawing of the selection line. + + * src/glibext/gcodebuffer.c: + * src/glibext/gcodebuffer.h: + * src/gtkext/gtkbufferview.c: + Draw a selection line on buffer views. + 15-04-11 Cyrille Bagard * src/glibext/gbufferline.c: diff --git a/src/core/params.c b/src/core/params.c index 75722b6..779bb38 100644 --- a/src/core/params.c +++ b/src/core/params.c @@ -156,6 +156,9 @@ bool load_main_config_parameters(void) param = g_generic_config_create_param(config, MPK_DISPLAY_ON_SEL, CPT_BOOLEAN, false); if (param == NULL) return false; + param = g_generic_config_create_param(config, MPK_SELECTION_LINE, CPT_BOOLEAN, true); + if (param == NULL) return false; + param = g_generic_config_create_param(config, MPK_KEYBINDINGS_EDIT, CPT_STRING, "F2"); if (param == NULL) return false; diff --git a/src/core/params.h b/src/core/params.h index 9eac629..6598c00 100644 --- a/src/core/params.h +++ b/src/core/params.h @@ -46,6 +46,7 @@ #define MPK_ELLIPSIS_HEADER "gui.editor.panels.ellipsis_header" #define MPK_ELLIPSIS_TAB "gui.editor.panels.ellipsis_tab" #define MPK_DISPLAY_ON_SEL "gui.editor.panels.display_on_selection" +#define MPK_SELECTION_LINE "gui.editor.views.selection_line" #define MPK_KEYBINDINGS_EDIT "gui.key_bindings.global.edit" #define MPK_AUTO_SAVE "project.autosave" diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c index f7c7cd6..fd1330b 100644 --- a/src/glibext/gcodebuffer.c +++ b/src/glibext/gcodebuffer.c @@ -1772,12 +1772,13 @@ void g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y) /****************************************************************************** * * -* Paramètres : view = visualisation à représenter. * -* cr = contexte graphique dédié à la procédure. * -* fake_x = abscisse réelle du point 0 à l'écran. * -* fake_y = ordonnée réelle du point 0 à l'écran. * -* area = position et surface à traiter. * -* display = règles d'affichage des colonnes modulables. * +* Paramètres : view = visualisation à représenter. * +* cr = contexte graphique dédié à la procédure. * +* fake_x = abscisse réelle du point 0 à l'écran. * +* fake_y = ordonnée réelle du point 0 à l'écran. * +* area = position et surface à traiter. * +* display = règles d'affichage des colonnes modulables. * +* selected = ordonnée d'une ligne sélectionnée ou NULL. * * * * Description : Imprime la visualisation du tampon de code désassemblé. * * * @@ -1787,7 +1788,7 @@ void g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y) * * ******************************************************************************/ -void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint fake_x, gint fake_y, const cairo_rectangle_int_t *area, const bool *display) +void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint fake_x, gint fake_y, const cairo_rectangle_int_t *area, const bool *display, const gint *selected) { gint real_x; /* Abscisse réelle pour tampon */ gint real_y; /* Ordonnée réelle pour tampon */ @@ -1796,6 +1797,8 @@ void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint fake_x, gint size_t last; /* Dernière ligne visée + 1 */ gint y; /* Point de départ + décallage */ GBufferLine **lines; /* Liste des lignes à traiter */ + bool wait_selection; /* Sélection déjà passée ? */ + gint rel_selected; /* Position relative de sélect°*/ size_t i; /* Boucle de parcours */ real_x = fake_x + view->left_text; @@ -1814,14 +1817,25 @@ void g_buffer_view_draw(const GBufferView *view, cairo_t *cr, gint fake_x, gint lines = view->buffer->lines; + wait_selection = true; + + if (selected != NULL) + rel_selected = *selected - fake_y; + if (view->buffer->used > 0) for (i = first; i <= last; i++) { - /* TODO : skip if... */ - /* - if (view->drawing_extra != NULL) - view->drawing_extra(lines[i], drawable, gc, fake_x, y, view->drawing_data); - */ + /* Si sélection, on sousligne la ligne concernée */ + if (wait_selection && selected != NULL && rel_selected == y) + { + cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.05); + + cairo_rectangle(cr, area->x, y, area->width, view->line_height); + cairo_fill(cr); + + wait_selection = false; + + } g_buffer_line_draw(lines[i], cr, view->max_widths, real_x, y, display); diff --git a/src/glibext/gcodebuffer.h b/src/glibext/gcodebuffer.h index 0877ce8..339e0a0 100644 --- a/src/glibext/gcodebuffer.h +++ b/src/glibext/gcodebuffer.h @@ -147,7 +147,7 @@ bool g_buffer_view_unhighlight_segments(GBufferView *); void g_buffer_view_highlight_segments(GBufferView *, gint, gint); /* Imprime la visualisation du tampon de code désassemblé. */ -void g_buffer_view_draw(const GBufferView *, cairo_t *, gint, gint, const cairo_rectangle_int_t *, const bool *); +void g_buffer_view_draw(const GBufferView *, cairo_t *, gint, gint, const cairo_rectangle_int_t *, const bool *, const gint *); /* Exporte le contenu du tampon de code désassemblé. */ void g_buffer_view_export(const GBufferView *, buffer_export_context *, BufferExportType, const bool *); diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index ef5aac6..1c2c7a9 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -27,6 +27,7 @@ #include +#include "../core/params.h" #include "../glibext/chrysamarshal.h" @@ -127,7 +128,6 @@ static void gtk_buffer_view_class_init(GtkBufferViewClass *class) panel_class->get_position = (get_view_position_fc)gtk_buffer_view_get_position; panel_class->cache_glance = (cache_glance_fc)gtk_buffer_view_cache_glance; - g_signal_new("caret-moved", GTK_TYPE_BUFFER_VIEW, G_SIGNAL_RUN_LAST, @@ -341,6 +341,8 @@ static gboolean gtk_buffer_view_draw(GtkWidget *widget, cairo_t *cr) GtkStyleContext *context; /* Contexte du thème actuel */ gint fake_x; /* Abscisse virtuelle */ gint fake_y; /* Ordonnée virtuelle */ + bool sel_line; /* Souslignage de la sélection */ + gint *selected; /* Ordonnée d'une sélection */ view = GTK_BUFFER_VIEW(widget); pview = GTK_VIEW_PANEL(widget); @@ -379,7 +381,14 @@ static gboolean gtk_buffer_view_draw(GtkWidget *widget, cairo_t *cr) fake_y = 0; gtk_buffer_view_compute_fake_coord(view, &fake_x, &fake_y); - g_buffer_view_draw(view->buffer_view, cr, fake_x, fake_y, &area, pview->display); + g_generic_config_get_value(get_main_configuration(), MPK_SELECTION_LINE, &sel_line); + + if (!sel_line || view->caret_addr == NULL) + selected = NULL; + else + selected = &view->caret.y; + + g_buffer_view_draw(view->buffer_view, cr, fake_x, fake_y, &area, pview->display, selected); } @@ -796,8 +805,6 @@ void gtk_buffer_view_compute_relative_coords(GtkBufferView *view, gint *x, gint - - /* ---------------------------------------------------------------------------------- */ /* ANIMATION DU CURSEUR */ /* ---------------------------------------------------------------------------------- */ @@ -823,8 +830,12 @@ static void gtk_buffer_view_relocate_caret(GtkBufferView *view, const GdkRectang { gtk_buffer_view_compute_relative_coords(view, &view->caret.x, &view->caret.y); + /* gtk_widget_queue_draw_area(GTK_WIDGET(view), view->caret.x, view->caret.y, view->caret.width, view->caret.height); + */ + + gtk_widget_queue_draw(GTK_WIDGET(view)); } -- cgit v0.11.2-87-g4458