From 2bae5614d923644d71dfa5c278042c63ae80e72d Mon Sep 17 00:00:00 2001 From: werner Date: Wed, 12 Aug 2009 14:44:17 +0000 Subject: [PATCH] - when selecting an object via the item list, make its frame active - having variables and items on the screen at the same time was too much. We can now toggle with "/" while the canvas has the focus. (This needs better controls.) git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5425 99fdad57-331a-0410-800a-d7fa5415bdb3 --- README | 1 + gui_canvas.c | 7 +++++++ gui_frame.c | 49 ++++++++++++++++++++++++++++++------------------- gui_frame.h | 3 +++ inst.c | 4 ++++ 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/README b/README index 72e7561..6405124 100644 --- a/README +++ b/README @@ -402,6 +402,7 @@ Space reset user coordinates * zoom and center to extents # zoom and center to currently active frame instance U undelete the previously deleted object +/ Switch between variable and item display. Canvas diff --git a/gui_canvas.c b/gui_canvas.c index ac86b72..ed8ee29 100644 --- a/gui_canvas.c +++ b/gui_canvas.c @@ -349,6 +349,13 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event, if (undelete()) change_world(); break; + case '/': +{ +/* @@@ find a better place for this */ +extern int show_vars; + show_vars = !show_vars; +change_world(); +} } return TRUE; } diff --git a/gui_frame.c b/gui_frame.c index 61a4206..08cb426 100644 --- a/gui_frame.c +++ b/gui_frame.c @@ -30,6 +30,9 @@ #include "gui_frame.h" +int show_vars = 1; + + /* ----- popup dispatcher -------------------------------------------------- */ @@ -1003,7 +1006,7 @@ static GtkWidget *item_label(GtkWidget *tab, char *s, int col, int row, static GtkWidget *build_items(struct frame *frame) { - GtkWidget *hbox, *tab; + GtkWidget *vbox, *hbox, *tab; struct order *order, *item; struct vec *vec; struct obj *obj; @@ -1017,7 +1020,11 @@ static GtkWidget *build_items(struct frame *frame) if (obj->type != ot_meas) n++; + vbox = gtk_vbox_new(FALSE, 0); + add_sep(vbox, 3); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); tab = gtk_table_new(n, 2, FALSE); gtk_box_pack_start(GTK_BOX(hbox), tab, FALSE, FALSE, 0); @@ -1043,13 +1050,13 @@ static GtkWidget *build_items(struct frame *frame) } free(order); - return hbox; + return vbox; } static GtkWidget *build_meas(struct frame *frame) { - GtkWidget *hbox, *tab; + GtkWidget *vbox, *hbox, *tab; struct obj *obj; int n; char *s; @@ -1059,7 +1066,11 @@ static GtkWidget *build_meas(struct frame *frame) if (obj->type == ot_meas) n++; + vbox = gtk_vbox_new(FALSE, 0); + add_sep(vbox, 3); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); tab = gtk_table_new(n, 2, FALSE); gtk_box_pack_start(GTK_BOX(hbox), tab, FALSE, FALSE, 0); @@ -1074,7 +1085,7 @@ static GtkWidget *build_meas(struct frame *frame) n++; } - return hbox; + return vbox; } @@ -1277,7 +1288,7 @@ void build_frames(GtkWidget *vbox) hbox = gtk_hbox_new(FALSE, 0); - tab = gtk_table_new(n*2+3, 3, FALSE); + tab = gtk_table_new(n*2+3, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(tab), 1); gtk_table_set_col_spacings(GTK_TABLE(tab), 1); @@ -1297,24 +1308,24 @@ void build_frames(GtkWidget *vbox) gtk_table_attach_defaults(GTK_TABLE(tab), refs, 1, 2, n*2+1, n*2+2); - vars = build_vars(frame); - gtk_table_attach_defaults(GTK_TABLE(tab), vars, - 1, 2, n*2+2, n*2+3); - - items = build_items(frame); - gtk_table_attach_defaults(GTK_TABLE(tab), items, - 2, 3, n*2+2, n*2+3); + if (show_vars) { + vars = build_vars(frame); + gtk_table_attach_defaults(GTK_TABLE(tab), vars, + 1, 2, n*2+2, n*2+3); + } else { + items = build_items(frame); + gtk_table_attach_defaults(GTK_TABLE(tab), items, + 1, 2, n*2+2, n*2+3); + } n++; } - label = label_in_box_new(" "); - gtk_table_attach_defaults(GTK_TABLE(tab), box_of_label(label), - 2, 3, n*2+1, n*2+2); - - meas = build_meas(root_frame); - gtk_table_attach_defaults(GTK_TABLE(tab), meas, - 2, 3, n*2+2, n*2+3); + if (!show_vars) { + meas = build_meas(root_frame); + gtk_table_attach_defaults(GTK_TABLE(tab), meas, + 1, 2, n*2+2, n*2+3); + } gtk_widget_show_all(hbox); } diff --git a/gui_frame.h b/gui_frame.h index 239d5e8..1c8da9f 100644 --- a/gui_frame.h +++ b/gui_frame.h @@ -17,6 +17,9 @@ #include +extern int show_vars; + + void make_popups(void); void select_frame(struct frame *frame); diff --git a/inst.c b/inst.c index c79d6be..469b069 100644 --- a/inst.c +++ b/inst.c @@ -303,6 +303,8 @@ void inst_select_vec(const struct vec *vec) { struct inst *inst; + if (vec->frame != active_frame) + select_frame(vec->frame); for (inst = insts[ip_vec]; inst; inst = inst->next) if (inst->vec == vec && inst->active) { inst_deselect(); @@ -318,6 +320,8 @@ void inst_select_obj(const struct obj *obj) enum inst_prio prio; struct inst *inst; + if (obj->frame != active_frame) + select_frame(obj->frame); FOR_INSTS_DOWN(prio, inst) if (inst->obj && inst->obj == obj && inst->active) { inst_deselect();