From dae8c208e24d03c7bf5314a86cb366a4e84a53c2 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 12 Dec 2012 21:25:32 +0000 Subject: Updated display of graphical views on option change and fixed size bugs. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@301 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 22 +++++++++++++++ src/analysis/binary.c | 2 +- src/gtkext/gtkgraphview.c | 66 +++++++++++++++++++++++++++++++++++-------- src/gtkext/gtkviewpanel-int.h | 4 +++ src/gtkext/gtkviewpanel.c | 18 ++++++++++-- src/gtkext/gtkviewpanel.h | 4 +-- src/gui/panels/glance.c | 3 -- src/project.c | 8 ++++-- 8 files changed, 106 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34bf9e4..9cf8d7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +12-12-12 Cyrille Bagard + + * src/analysis/binary.c: + Remove addresses in graphical views by default. + + * src/gtkext/gtkgraphview.c: + Update code, remove the (now) useless 'requisition' field and fix bugs: + sizes are updated when selected other routines and the values provided + to the glance panel produce no truncated display anymore. + + * src/gtkext/gtkviewpanel.c: + * src/gtkext/gtkviewpanel.h: + * src/gtkext/gtkviewpanel-int.h: + Provide a way to update views when rendering options are updated. + + * src/gui/panels/glance.c: + Do not use scroll bar values when computing required dimensions anymore, + as they are already added in the got requisition values. + + * src/project.c: + Use the right rendering options when loading graphical views. + 12-12-11 Cyrille Bagard * src/decomp/output.c: diff --git a/src/analysis/binary.c b/src/analysis/binary.c index b9292aa..54beba7 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -124,7 +124,7 @@ static void g_loaded_binary_init(GLoadedBinary *binary) { binary->text_display[BDT_ASM][0] = true; binary->text_display[BDT_ASM][1] = true; - binary->text_display[BDT_GRAPH][0] = true; + binary->text_display[BDT_GRAPH][0] = false; binary->text_display[BDT_GRAPH][1] = false; binary->lines_display = true; diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 1a48680..88210f5 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -38,8 +38,6 @@ struct _GtkGraphView GtkViewPanel parent; /* A laisser en premier */ GtkFixed *support; /* Support des vues en bloc */ - GtkRequisition requisition; /* Espace requis d'affichage */ /* A garder ?? */ - vmpa_t start; /* Début de la portion vue */ vmpa_t end; /* Fin de la portion affichée */ @@ -79,6 +77,9 @@ static gboolean gtk_graph_view_expose(GtkWidget *, GdkEventExpose *, GtkGraphVie /* Réagit à la sélection externe d'une adresse. */ static void gtk_graph_view_define_main_address(GtkGraphView *, vmpa_t); +/* Actualise les besoins internes avant un redimensionnement. */ +static void gtk_graph_view_prepare_resize(GtkGraphView *); + /* Indique la position d'affichage d'une adresse donnée. */ static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, vmpa_t, gint *, gint *); @@ -145,6 +146,7 @@ static void gtk_graph_view_init(GtkGraphView *view) viewpanel = GTK_VIEW_PANEL(view); viewpanel->define = (define_address_fc)gtk_graph_view_define_main_address; + viewpanel->resize = (prepare_resize_fc)gtk_graph_view_prepare_resize; viewpanel->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates; viewpanel->scroll = (scroll_fc)gtk_graph_view_scroll; viewpanel->cache_glance = (cache_glance_fc)gtk_graph_view_cache_glance; @@ -213,8 +215,8 @@ static void gtk_graph_view_size_request(GtkWidget *widget, GtkRequisition *requi if (left_corner != G_MAXINT) requisition->width += left_corner; if (top_corner != G_MAXINT) requisition->height += top_corner; - if (view->requisition.width == 0 && view->requisition.height == 0) - view->requisition = *requisition; + requisition->width += GTK_VIEW_PANEL(widget)->hadjustment->value; + requisition->height += GTK_VIEW_PANEL(widget)->vadjustment->value; } @@ -237,6 +239,7 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc gpointer fixed_class; /* Classe parente */ GtkViewPanel *panel; /* Autre version du composant */ GtkAllocation valloc; /* Surface utilisable */ + GtkRequisition req; /* Taille demandée */ gboolean changed; /* Changement de valeur ? */ /* Mise à jour GTK */ @@ -253,13 +256,15 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc gtk_view_panel_compute_allocation(panel, &valloc); + gtk_widget_size_request(widget, &req); + /* Défilement horizontal */ panel->hadjustment->page_size = valloc.width; panel->hadjustment->step_increment = valloc.width * 0.1; panel->hadjustment->page_increment = valloc.width * 0.9; - panel->hadjustment->upper = MAX(GTK_GRAPH_VIEW(widget)->requisition.width, valloc.width); + panel->hadjustment->upper = MAX(req.width, valloc.width); gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed); @@ -274,7 +279,7 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc panel->vadjustment->step_increment = valloc.width * 0.1; panel->vadjustment->page_increment = valloc.width * 0.9; - panel->vadjustment->upper = MAX(GTK_GRAPH_VIEW(widget)->requisition.height, valloc.height); + panel->vadjustment->upper = MAX(req.height, valloc.height); gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed); @@ -376,6 +381,36 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) /****************************************************************************** * * +* Paramètres : view = composant GTK à mettre à jour. * +* * +* Description : Actualise les besoins internes avant un redimensionnement. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_graph_view_prepare_resize(GtkGraphView *view) +{ + size_t i; /* Boucle de parcours */ + + if (view->children_count > 0) + { + for (i = 0; i < view->children_count; i++) + gtk_widget_queue_resize(GTK_WIDGET(view->children[i])); + + build_graph_view(view, view->children, view->children_count); + + change_editor_items_current_view_content(GTK_VIEW_PANEL(view)); + + } + +} + + +/****************************************************************************** +* * * Paramètres : view = composant GTK à consulter. * * addr = adresse à présenter à l'écran. * * x = position horizontale au sein du composant. [OUT] * @@ -496,6 +531,7 @@ GtkWidget *gtk_graph_view_new(void) void gtk_graph_view_put(GtkGraphView *view, GtkWidget *widget, const GtkAllocation *alloc) { size_t i; /* Boucle de parcours */ + GtkWidget *parent; /* Parent en cas de réajustemt.*/ for (i = 0; i < view->children_count; i++) if (GTK_WIDGET(view->children[i]) == widget) @@ -504,8 +540,19 @@ void gtk_graph_view_put(GtkGraphView *view, GtkWidget *widget, const GtkAllocati break; } + parent = gtk_widget_get_parent(widget); + + if (parent != NULL) + { + g_object_ref(G_OBJECT(widget)); + gtk_container_remove(GTK_CONTAINER(parent), widget); + } + gtk_fixed_put(view->support, widget, alloc->x, alloc->y); + if (parent != NULL) + g_object_unref(G_OBJECT(widget)); + } @@ -547,9 +594,6 @@ static void gtk_graph_view_reset(GtkGraphView *view) { size_t i; /* Boucle de parcours */ - view->requisition.width = 0; - view->requisition.height = 0; - view->start = VMPA_MAX; view->end = VMPA_MAX; @@ -618,8 +662,8 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinar list = g_loaded_binary_get_instructions(binary); buffer = g_loaded_binary_get_disassembled_buffer(binary); - addr = g_loaded_binary_display_addresses_in_text(binary, BDT_GRAPH); - code = g_loaded_binary_display_code_in_text(binary, BDT_GRAPH); + addr = GTK_VIEW_PANEL(view)->display_addr; + code = GTK_VIEW_PANEL(view)->display_code; first = start; last = first; diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index ee14067..b859f99 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -39,6 +39,9 @@ typedef void (* attach_binary_fc) (GtkViewPanel *, GLoadedBinary *, bool *, bool /* Réagit à la sélection externe d'une adresse. */ typedef void (* define_address_fc) (GtkViewPanel *, vmpa_t); +/* Actualise les besoins internes avant un redimensionnement. */ +typedef void (* prepare_resize_fc) (GtkViewPanel *); + /* Indique la position d'affichage d'une adresse donnée. */ typedef bool (* get_addr_coordinates_fc) (const GtkViewPanel *, vmpa_t, gint *, gint *); @@ -65,6 +68,7 @@ struct _GtkViewPanel attach_binary_fc attach; /* Association avec un binaire */ define_address_fc define; /* Centrage sur une partie */ + prepare_resize_fc resize; /* Prépare une nouvelle taille */ get_addr_coordinates_fc get_coordinates;/* Conversion adresse <-> pos. */ scroll_fc scroll; /* Défilement du contenu */ cache_glance_fc cache_glance; /* Cache de la mignature */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index a3bf747..ab0f237 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -410,12 +410,19 @@ bool gtk_view_panel_get_addresses_display(const GtkViewPanel *panel) * * ******************************************************************************/ -void gtk_view_panel_set_addresses_display(const GtkViewPanel *panel, bool state) +void gtk_view_panel_set_addresses_display(GtkViewPanel *panel, bool state) { if (*panel->display_addr != state) { *panel->display_addr = state; + + if (panel->resize != NULL) + panel->resize(panel); + + gtk_widget_queue_resize(gtk_widget_get_parent(GTK_WIDGET(panel))); + gtk_widget_queue_resize(GTK_WIDGET(panel)); gtk_widget_queue_draw(GTK_WIDGET(panel)); + } } @@ -453,12 +460,19 @@ bool gtk_view_panel_get_code_display(const GtkViewPanel *panel) * * ******************************************************************************/ -void gtk_view_panel_set_code_display(const GtkViewPanel *panel, bool state) +void gtk_view_panel_set_code_display(GtkViewPanel *panel, bool state) { if (*panel->display_code != state) { *panel->display_code = state; + + if (panel->resize != NULL) + panel->resize(panel); + + gtk_widget_queue_resize(gtk_widget_get_parent(GTK_WIDGET(panel))); + gtk_widget_queue_resize(GTK_WIDGET(panel)); gtk_widget_queue_draw(GTK_WIDGET(panel)); + } } diff --git a/src/gtkext/gtkviewpanel.h b/src/gtkext/gtkviewpanel.h index 3de5fab..61df60f 100644 --- a/src/gtkext/gtkviewpanel.h +++ b/src/gtkext/gtkviewpanel.h @@ -60,13 +60,13 @@ void gtk_view_panel_attach_binary(GtkViewPanel *, GLoadedBinary *, bool *, bool bool gtk_view_panel_get_addresses_display(const GtkViewPanel *); /* Définit si les adresses doivent apparaître dans le rendu. */ -void gtk_view_panel_set_addresses_display(const GtkViewPanel *, bool); +void gtk_view_panel_set_addresses_display(GtkViewPanel *, bool); /* Indique si le code doit apparaître dans le rendu. */ bool gtk_view_panel_get_code_display(const GtkViewPanel *); /* Définit si le code doit apparaître dans le rendu. */ -void gtk_view_panel_set_code_display(const GtkViewPanel *, bool); +void gtk_view_panel_set_code_display(GtkViewPanel *, bool); /* Fournit le binaire associé à la représentation. */ GLoadedBinary *gtk_view_panel_get_binary(const GtkViewPanel *); diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c index abbe6a1..da386f4 100644 --- a/src/gui/panels/glance.c +++ b/src/gui/panels/glance.c @@ -336,9 +336,6 @@ static void on_view_scroll_setup(GtkAdjustment *adj, GGlancePanel *panel) gtk_widget_size_request(GTK_WIDGET(panel->view), &panel->req); - panel->req.width += hadj->value; - panel->req.height += vadj->value; - update_glance_panel_for_view_content(panel, panel->view); } diff --git a/src/project.c b/src/project.c index 106bf3a..ca49954 100644 --- a/src/project.c +++ b/src/project.c @@ -354,6 +354,7 @@ size_t g_study_project_attach_binary(GStudyProject *project, GLoadedBinary *bina loaded_binary *loaded; /* Structure à renvoyer */ BinaryView i; /* Boucle de parcours */ GtkWidget *view; /* Affichage du binaire */ + BinaryDisplayType type; /* Options d'affichage */ GtkWidget *scroll; /* Surface d'exposition */ const char *title; /* Titre associé au binaire */ @@ -371,12 +372,15 @@ size_t g_study_project_attach_binary(GStudyProject *project, GLoadedBinary *bina { case BVW_BLOCK: view = gtk_block_view_new(/*MRD_BLOCK*/); + type = BDT_ASM; break; case BVW_GRAPH: view = gtk_graph_view_new(); + type = BDT_GRAPH; break; case BVW_SOURCE: view = gtk_source_view_new(); + type = BDT_ASM; /* FIXME */ break; default: /* GCC ! */ break; @@ -390,8 +394,8 @@ size_t g_study_project_attach_binary(GStudyProject *project, GLoadedBinary *bina loaded->views[i] = GTK_VIEW_PANEL(view); gtk_view_panel_attach_binary(loaded->views[i], binary, - g_loaded_binary_display_addresses_in_text(binary, BDT_ASM), - g_loaded_binary_display_code_in_text(binary, BDT_ASM)); + g_loaded_binary_display_addresses_in_text(binary, type), + g_loaded_binary_display_code_in_text(binary, type)); /* Intégration finale dans un support défilant */ -- cgit v0.11.2-87-g4458