From dcd03173f71b09f38238f50dfcf4c1db0c014c4c Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 6 Jan 2013 02:35:37 +0000 Subject: Transferred the scale computing to the rendered view. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@319 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 17 +++++++++++++++++ src/gtkext/gtkbufferview.c | 21 ++++++++------------- src/gtkext/gtkgraphview.c | 23 ++++++++++++----------- src/gtkext/gtklinkrenderer.c | 6 +++--- src/gtkext/gtkviewpanel-int.h | 4 ++-- src/gtkext/gtkviewpanel.c | 8 +++++--- src/gtkext/gtkviewpanel.h | 4 ++-- src/gui/panels/glance.c | 14 +++++++++----- 8 files changed, 58 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 783657e..13973d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +13-01-06 Cyrille Bagard + + * src/gtkext/gtkbufferview.c: + * src/gtkext/gtkgraphview.c: + Update code. + + * src/gtkext/gtklinkrenderer.c: + Try to get single-pixel-wide line for links. + + * src/gtkext/gtkviewpanel.c: + * src/gtkext/gtkviewpanel.h: + * src/gtkext/gtkviewpanel-int.h: + Update wrapper code. + + * src/gui/panels/glance.c: + Transfer the scale computing to the rendered view. + 13-01-05 Cyrille Bagard * src/gtkext/graph/dot.c: diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index 027ae5c..62a861a 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * gtkbufferview.c - affichage de tampons de lignes * - * Copyright (C) 2010-2012 Cyrille Bagard + * Copyright (C) 2010-2013 Cyrille Bagard * * This file is part of OpenIDA. * @@ -50,7 +50,7 @@ static bool gtk_buffer_view_get_address_coordinates(const GtkBufferView *, vmpa_ static void gtk_buffer_view_scroll(GtkBufferView *); /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ -static void gtk_buffer_view_cache_glance(GtkBufferView *, cairo_t *); +static void gtk_buffer_view_cache_glance(GtkBufferView *, cairo_t *, const GtkAllocation *, double); @@ -384,6 +384,8 @@ static void gtk_buffer_view_scroll(GtkBufferView *view) * * * Paramètres : view = composant GTK à manipuler. * * cairo = assistant pour la création de rendus. * +* area = taille de la surface réduite à disposition. * +* scale = échelle vis à vis de la taille réelle. * * * * Description : Place en cache un rendu destiné à l'aperçu graphique rapide. * * * @@ -393,19 +395,12 @@ static void gtk_buffer_view_scroll(GtkBufferView *view) * * ******************************************************************************/ -static void gtk_buffer_view_cache_glance(GtkBufferView *view, cairo_t *cairo) +static void gtk_buffer_view_cache_glance(GtkBufferView *view, cairo_t *cairo, const GtkAllocation *area, double scale) { - GtkRequisition req; /* Pleine taille de la source */ + cairo_set_line_width(cairo, 1); + cairo_set_source_rgb(cairo, 0.4, 0.4, 0.4); - gtk_widget_size_request(GTK_WIDGET(view), &req); - gtk_buffer_view_compute_real_coord(view, &req.width, &req.height); - - /* FIXME : hardcoded 20 */ - - cairo_set_line_width(cairo, 20); - cairo_set_source_rgb(cairo, 0, 0, 0); - - cairo_rectangle(cairo, 0, 0, req.width - 20, req.height - 20); + cairo_rectangle(cairo, area->x + 0.5, area->y + 0.5, area->width - 1, area->height - 1); cairo_stroke(cairo); diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 6aedf26..aeb66ae 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -89,7 +89,7 @@ static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, vmpa_t, static void gtk_graph_view_scroll(GtkGraphView *); /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ -static void gtk_graph_view_cache_glance(GtkGraphView *, cairo_t *); +static void gtk_graph_view_cache_glance(GtkGraphView *, cairo_t *, const GtkAllocation *, double); /* Supprime tout contenu de l'afficheur de code en graphique. */ static void gtk_graph_view_reset(GtkGraphView *); @@ -490,6 +490,8 @@ static void gtk_graph_view_scroll(GtkGraphView *view) * * * Paramètres : view = composant GTK à manipuler. * * cairo = assistant pour la création de rendus. * +* area = taille de la surface réduite à disposition. * +* scale = échelle vis à vis de la taille réelle. * * * * Description : Place en cache un rendu destiné à l'aperçu graphique rapide. * * * @@ -499,25 +501,24 @@ static void gtk_graph_view_scroll(GtkGraphView *view) * * ******************************************************************************/ -static void gtk_graph_view_cache_glance(GtkGraphView *view, cairo_t *cairo) +static void gtk_graph_view_cache_glance(GtkGraphView *view, cairo_t *cairo, const GtkAllocation *area, double scale) { size_t i; /* Boucle de parcours */ - GtkAllocation *alloc; /* Emplacement d'un bloc */ - - cairo_set_line_width(cairo, 2); - cairo_set_source_rgb(cairo, 0, 0, 0); + GtkAllocation sub_area; /* Emplacement réservé */ for (i = 0; i < view->children_count; i++) { - alloc = &view->allocs[i]; - - cairo_rectangle(cairo, alloc->x, alloc->y, - alloc->width, alloc->height); + sub_area.x = view->allocs[i].x * scale; + sub_area.y = view->allocs[i].y * scale; + sub_area.width = view->allocs[i].width * scale + 1; + sub_area.height = view->allocs[i].height * scale + 1; - cairo_stroke(cairo); + gtk_view_panel_cache_glance(view->children[i], cairo, &sub_area, scale); } + cairo_scale(cairo, scale, scale); + for (i = 0; i < view->links_count; i++) _gtk_link_renderer_draw(view->links[i], cairo, false); diff --git a/src/gtkext/gtklinkrenderer.c b/src/gtkext/gtklinkrenderer.c index e37a5f1..0dbdb25 100644 --- a/src/gtkext/gtklinkrenderer.c +++ b/src/gtkext/gtklinkrenderer.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * gtklinkrenderer.c - liens graphiques entre différents morceaux de code * - * Copyright (C) 2009 Cyrille Bagard + * Copyright (C) 2009-2013 Cyrille Bagard * * This file is part of OpenIDA. * @@ -239,10 +239,10 @@ void _gtk_link_renderer_draw(const GtkLinkRenderer *renderer, cairo_t *cairo, bo */ cairo_set_line_width(cairo, arrow ? 1 : 2); - cairo_move_to(cairo, renderer->points[0].x, renderer->points[0].y); + cairo_move_to(cairo, renderer->points[0].x + 0.5, renderer->points[0].y); for (i = 1; i < renderer->count; i++) - cairo_line_to(cairo, renderer->points[i].x, renderer->points[i].y); + cairo_line_to(cairo, renderer->points[i].x + 0.5, renderer->points[i].y); cairo_stroke(cairo); diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index b859f99..ee69673 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * gtkviewpanel-int.h - définitions internes propre à l'affichage de contenu de binaire * - * Copyright (C) 2010-2012 Cyrille Bagard + * Copyright (C) 2010-2013 Cyrille Bagard * * This file is part of OpenIDA. * @@ -49,7 +49,7 @@ typedef bool (* get_addr_coordinates_fc) (const GtkViewPanel *, vmpa_t, gint *, typedef void (* scroll_fc) (GtkViewPanel *); /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ -typedef void (* cache_glance_fc) (GtkViewPanel *, cairo_t *); +typedef void (* cache_glance_fc) (GtkViewPanel *, cairo_t *, const GtkAllocation *, double); diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index 97897a8..6d10009 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * gtkviewpanel.c - affichage de contenu de binaire * - * Copyright (C) 2010-2012 Cyrille Bagard + * Copyright (C) 2010-2013 Cyrille Bagard * * This file is part of OpenIDA. * @@ -567,6 +567,8 @@ void gtk_view_panel_scroll_to_address(GtkViewPanel *panel, vmpa_t addr) * * * Paramètres : panel = composant GTK à manipuler. * * cairo = assistant pour la création de rendus. * +* area = taille de la surface réduite à disposition. * +* scale = échelle vis à vis de la taille réelle. * * * * Description : Place en cache un rendu destiné à l'aperçu graphique rapide. * * * @@ -576,9 +578,9 @@ void gtk_view_panel_scroll_to_address(GtkViewPanel *panel, vmpa_t addr) * * ******************************************************************************/ -void gtk_view_panel_cache_glance(GtkViewPanel *panel, cairo_t *cairo) +void gtk_view_panel_cache_glance(GtkViewPanel *panel, cairo_t *cairo, const GtkAllocation *area, double scale) { if (panel->cache_glance != NULL) - panel->cache_glance(panel, cairo); + panel->cache_glance(panel, cairo, area, scale); } diff --git a/src/gtkext/gtkviewpanel.h b/src/gtkext/gtkviewpanel.h index 61df60f..59220e6 100644 --- a/src/gtkext/gtkviewpanel.h +++ b/src/gtkext/gtkviewpanel.h @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * gtkviewpanel.h - prototypes pour l'affichage de contenu de binaire * - * Copyright (C) 2010-2012 Cyrille Bagard + * Copyright (C) 2010-2013 Cyrille Bagard * * This file is part of OpenIDA. * @@ -78,7 +78,7 @@ bool gtk_view_panel_contain_address(const GtkViewPanel *, vmpa_t); void gtk_view_panel_scroll_to_address(GtkViewPanel *, vmpa_t); /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ -void gtk_view_panel_cache_glance(GtkViewPanel *, cairo_t *); +void gtk_view_panel_cache_glance(GtkViewPanel *, cairo_t *, const GtkAllocation *, double); diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c index da386f4..542cd74 100644 --- a/src/gui/panels/glance.c +++ b/src/gui/panels/glance.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * glance.c - panneau d'aperçu rapide * - * Copyright (C) 2009-2012 Cyrille Bagard + * Copyright (C) 2009-2013 Cyrille Bagard * * This file is part of OpenIDA. * @@ -477,6 +477,7 @@ static void compute_glance_scale(GGlancePanel *panel) static void update_glance_panel_for_view_content(GGlancePanel *panel, GtkViewPanel *view) { cairo_t *cairo; /* Assistant pour le dessin */ + GtkAllocation area; /* Dimension de la surface */ /* Mise en place d'un cache adapté */ @@ -487,13 +488,16 @@ static void update_glance_panel_for_view_content(GGlancePanel *panel, GtkViewPan panel->painting.width, panel->painting.height); - cairo = cairo_create(panel->cache); + /* Dessin de l'aperçu représentatif */ - cairo_scale(cairo, panel->scale, panel->scale); + cairo = cairo_create(panel->cache); - /* Dessin de l'aperçu représentatif */ + area.x = 0; + area.y = 0; + area.width = panel->painting.width; + area.height = panel->painting.height; - gtk_view_panel_cache_glance(view, cairo); + gtk_view_panel_cache_glance(view, cairo, &area, panel->scale); cairo_destroy(cairo); -- cgit v0.11.2-87-g4458