mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-22 07:30:16 +02:00
- moved building of an activator into new function add_activator
- added loop value selection (quick and dirty) git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5379 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
3c026696d4
commit
96d41a37ab
76
gui.c
76
gui.c
@ -140,6 +140,33 @@ static void edit_value(struct value *value)
|
||||
}
|
||||
|
||||
|
||||
/* ----- activator --------------------------------------------------------- */
|
||||
|
||||
|
||||
static GtkWidget *add_activator(GtkWidget *hbox, int active,
|
||||
gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
|
||||
gpointer user, const char *fmt, ...)
|
||||
{
|
||||
GtkWidget *label;
|
||||
va_list ap;
|
||||
char buf[100];
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsprintf(buf, fmt, ap);
|
||||
va_end(ap);
|
||||
label = label_in_box_new(buf);
|
||||
gtk_misc_set_padding(GTK_MISC(label), 2, 2);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
label_in_box_bg(label,
|
||||
active ? COLOR_CHOICE_SELECTED : COLOR_CHOICE_UNSELECTED);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(label),
|
||||
FALSE, FALSE, 2);
|
||||
g_signal_connect(G_OBJECT(box_of_label(label)),
|
||||
"button_press_event", G_CALLBACK(cb), user);
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
/* ----- assignments ------------------------------------------------------- */
|
||||
|
||||
|
||||
@ -336,11 +363,23 @@ static gboolean loop_to_select_event(GtkWidget *widget,
|
||||
}
|
||||
|
||||
|
||||
static gboolean loop_select_event(GtkWidget *widget, GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
struct loop *loop = data;
|
||||
|
||||
loop->active = (long) gtk_object_get_data(GTK_OBJECT(widget), "value");
|
||||
change_world();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void build_loop(GtkWidget *vbox, struct frame *frame,
|
||||
struct loop *loop)
|
||||
{
|
||||
GtkWidget *hbox, *field;
|
||||
GtkWidget *hbox, *field, *label;
|
||||
char *expr;
|
||||
int i;
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
||||
@ -378,6 +417,19 @@ static void build_loop(GtkWidget *vbox, struct frame *frame,
|
||||
"button_press_event",
|
||||
G_CALLBACK(loop_to_select_event), loop);
|
||||
loop->to.widget = field;
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(" ("),
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
for (i = 0; i != loop->iterations; i++) {
|
||||
label = add_activator(hbox, loop->active == i,
|
||||
loop_select_event, loop, "%d", i);
|
||||
gtk_object_set_data(GTK_OBJECT(box_of_label(label)), "value",
|
||||
(gpointer) (long) i);
|
||||
}
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(")"),
|
||||
FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -503,26 +555,16 @@ static gboolean frame_ref_select_event(GtkWidget *widget, GdkEventButton *event,
|
||||
|
||||
static GtkWidget *build_frame_refs(const struct frame *frame)
|
||||
{
|
||||
GtkWidget *hbox, *label;
|
||||
GtkWidget *hbox;
|
||||
struct obj *obj;
|
||||
char buf[100];
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 0);
|
||||
for (obj = frame->objs; obj; obj = obj->next)
|
||||
if (obj->type == ot_frame && obj->u.frame.ref == active_frame) {
|
||||
sprintf(buf, "%d", obj->u.frame.lineno);
|
||||
label = label_in_box_new(buf);
|
||||
gtk_misc_set_padding(GTK_MISC(label), 2, 2);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
label_in_box_bg(label,
|
||||
obj == obj->u.frame.ref->active_ref ?
|
||||
COLOR_REF_SELECTED : COLOR_REF_UNSELECTED);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(label),
|
||||
FALSE, FALSE, 2);
|
||||
g_signal_connect(G_OBJECT(box_of_label(label)),
|
||||
"button_press_event",
|
||||
G_CALLBACK(frame_ref_select_event), obj);
|
||||
}
|
||||
if (obj->type == ot_frame && obj->u.frame.ref == active_frame)
|
||||
add_activator(hbox,
|
||||
obj == obj->u.frame.ref->active_ref,
|
||||
frame_ref_select_event, obj,
|
||||
"%d", obj->u.frame.lineno);
|
||||
return hbox;
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,6 @@
|
||||
#define COLOR_FRAME_SELECTED "#fff0a0"
|
||||
#define COLOR_FRAME_EDITING COLOR_EDITING
|
||||
|
||||
#define COLOR_REF_UNSELECTED COLOR_CHOICE_UNSELECTED
|
||||
#define COLOR_REF_SELECTED COLOR_CHOICE_SELECTED
|
||||
|
||||
#define COLOR_VAR_PASSIVE COLOR_FRAME_UNSELECTED
|
||||
#define COLOR_VAR_EDITING COLOR_EDITING
|
||||
#define COLOR_EXPR_PASSIVE "#f0f0ff"
|
||||
|
1
obj.c
1
obj.c
@ -213,6 +213,7 @@ static int run_loops(struct frame *frame, struct loop *loop,
|
||||
n++;
|
||||
}
|
||||
loop->initialized = 0;
|
||||
loop->iterations = n;
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
|
Loading…
Reference in New Issue
Block a user