mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-25 18:01:54 +02:00
- changed item list font to Courier, which looks a lot tidier
- active items can now be selected from the item list (selecting inactive items will be a little harder) git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5424 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
e65d90947c
commit
a648cb888f
51
gui_frame.c
51
gui_frame.c
@ -25,6 +25,7 @@
|
||||
#include "gui_style.h"
|
||||
#include "gui_status.h"
|
||||
#include "gui_tool.h"
|
||||
#include "gui_canvas.h"
|
||||
#include "gui.h"
|
||||
#include "gui_frame.h"
|
||||
|
||||
@ -948,7 +949,39 @@ void gui_frame_deselect_inst(struct inst *inst)
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *item_label(GtkWidget *tab, char *s, int col, int row)
|
||||
static gboolean item_select_vec(GtkWidget *widget, GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
const struct vec *vec = data;
|
||||
|
||||
switch (event->button) {
|
||||
case 1:
|
||||
inst_select_vec(vec);
|
||||
redraw();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean item_select_obj(GtkWidget *widget, GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
const struct obj *obj = data;
|
||||
|
||||
switch (event->button) {
|
||||
case 1:
|
||||
inst_select_obj(obj);
|
||||
redraw();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *item_label(GtkWidget *tab, char *s, int col, int row,
|
||||
gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
@ -958,6 +991,11 @@ static GtkWidget *item_label(GtkWidget *tab, char *s, int col, int row)
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), box_of_label(label),
|
||||
col, col+1, row, row+1);
|
||||
label_in_box_bg(box_of_label(label), COLOR_ITEM_NORMAL);
|
||||
|
||||
if (cb)
|
||||
g_signal_connect(G_OBJECT(box_of_label(label)),
|
||||
"button_press_event", G_CALLBACK(cb), data);
|
||||
|
||||
free(s);
|
||||
return label;
|
||||
}
|
||||
@ -989,15 +1027,17 @@ static GtkWidget *build_items(struct frame *frame)
|
||||
for (item = order; item->vec || item->obj; item++) {
|
||||
if (item->obj) {
|
||||
s = print_obj(item->obj, item->vec);
|
||||
item->obj->list_widget = item_label(tab, s, 1, n);
|
||||
item->obj->list_widget = item_label(tab, s, 1, n,
|
||||
item_select_obj, item->obj);
|
||||
} else {
|
||||
s = print_label(item->vec);
|
||||
t = stralloc_printf("%s: ", s);
|
||||
free(s);
|
||||
item_label(tab, t, 0, n);
|
||||
item_label(tab, t, 0, n, NULL, NULL);
|
||||
|
||||
s = print_vec(item->vec);
|
||||
item->vec->list_widget = item_label(tab, s, 1, n);
|
||||
item->vec->list_widget = item_label(tab, s, 1, n,
|
||||
item_select_vec, item->vec);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
@ -1029,7 +1069,8 @@ static GtkWidget *build_meas(struct frame *frame)
|
||||
if (obj->type != ot_meas)
|
||||
continue;
|
||||
s = print_meas(obj);
|
||||
obj->list_widget = item_label(tab, s, 0, n);
|
||||
obj->list_widget = item_label(tab, s, 0, n,
|
||||
item_select_obj, obj);
|
||||
n++;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define FRAME_EYE_R1 3
|
||||
#define FRAME_EYE_R2 5
|
||||
|
||||
#define ITEM_LIST_FONT "Sans 8"
|
||||
#define ITEM_LIST_FONT "Courier Bold 8"
|
||||
|
||||
#define SELECT_R 6 /* pixels within which we select */
|
||||
|
||||
|
51
inst.c
51
inst.c
@ -109,6 +109,17 @@ return;
|
||||
}
|
||||
|
||||
|
||||
static void inst_select_inst(struct inst *inst)
|
||||
{
|
||||
selected_inst = inst;
|
||||
set_path(1);
|
||||
tool_selected_inst(inst);
|
||||
gui_frame_select_inst(inst);
|
||||
if (inst->ops->select)
|
||||
selected_inst->ops->select(inst);
|
||||
}
|
||||
|
||||
|
||||
int inst_select(struct coord pos)
|
||||
{
|
||||
enum inst_prio prio;
|
||||
@ -158,11 +169,7 @@ int inst_select(struct coord pos)
|
||||
return 0;
|
||||
|
||||
selected:
|
||||
set_path(1);
|
||||
tool_selected_inst(selected_inst);
|
||||
gui_frame_select_inst(selected_inst);
|
||||
if (selected_inst->ops->select)
|
||||
selected_inst->ops->select(selected_inst);
|
||||
inst_select_inst(selected_inst);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -289,6 +296,40 @@ void inst_deselect(void)
|
||||
}
|
||||
|
||||
|
||||
/* ----- select instance by vector/object ---------------------------------- */
|
||||
|
||||
|
||||
void inst_select_vec(const struct vec *vec)
|
||||
{
|
||||
struct inst *inst;
|
||||
|
||||
for (inst = insts[ip_vec]; inst; inst = inst->next)
|
||||
if (inst->vec == vec && inst->active) {
|
||||
inst_deselect();
|
||||
inst_select_inst(inst);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void inst_select_obj(const struct obj *obj)
|
||||
{
|
||||
enum inst_prio prio;
|
||||
struct inst *inst;
|
||||
|
||||
FOR_INSTS_DOWN(prio, inst)
|
||||
if (inst->obj && inst->obj == obj && inst->active) {
|
||||
inst_deselect();
|
||||
inst_select_inst(inst);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----- common status reporting ------------------------------------------- */
|
||||
|
||||
|
||||
static void rect_status(struct coord a, struct coord b, unit_type width)
|
||||
{
|
||||
struct coord d = sub_vec(b, a);
|
||||
|
3
inst.h
3
inst.h
@ -133,6 +133,9 @@ void inst_select_outside(void *item, void (*deselect)(void *item));
|
||||
int inst_select(struct coord pos);
|
||||
void inst_deselect(void);
|
||||
|
||||
void inst_select_vec(const struct vec *vec);
|
||||
void inst_select_obj(const struct obj *obj);
|
||||
|
||||
struct inst *inst_find_point(struct coord pos);
|
||||
int inst_find_point_selected(struct coord pos, struct inst **res);
|
||||
struct coord inst_get_point(const struct inst *inst);
|
||||
|
Loading…
Reference in New Issue
Block a user