1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-25 16:55:20 +02:00

- adjust measurement bbox for projection (still not perfect, but better)

- we can now scroll-wheel through table rows
- added menu branch "View" with zoom and var/code display controls
- commented out is_min_of_next until its fate is decided, so that we don't get 
  a warning



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5462 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-16 12:04:01 +00:00
parent 5a86125002
commit be86e276b8
6 changed files with 100 additions and 12 deletions

21
gui.c
View File

@ -39,18 +39,37 @@ static GtkWidget *ev_stuff, *ev_meas;
static GtkWidget *stuff_image[2], *meas_image[2];
/* ----- view callbacks ---------------------------------------------------- */
static void swap_var_code(void)
{
extern int show_vars;
show_vars = !show_vars;
change_world();
}
/* ----- menu bar ---------------------------------------------------------- */
static GtkItemFactoryEntry menu_entries[] = {
{ "/File", NULL, NULL, 0, "<Branch>" },
{ "/File/Save", NULL, save_fpd, 0, "<Item>" },
{ "/File/sep0", NULL, NULL, 0, "<Separator>" },
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
{ "/File/Write KiCad", NULL, write_kicad, 0, "<Item>" },
{ "/File/Write Postscript",
NULL, write_ps, 0, "<Item>" },
{ "/File/sep2", NULL, NULL, 0, "<Separator>" },
{ "/File/Quit", NULL, gtk_main_quit, 0, "<Item>" },
{ "/View", NULL, NULL, 0, "<Branch>" },
{ "/View/Zoom in", NULL, zoom_in_center, 0, "<Item>" },
{ "/View/Zoom out", NULL, zoom_out_center,0, "<Item>" },
{ "/View/Zoom all", NULL, zoom_to_extents,0, "<Item>" },
{ "/View/Zoom frame", NULL, zoom_to_frame, 0, "<Item>" },
{ "/View/sep1", NULL, NULL, 0, "<Separator>" },
{ "/View/Swap var&code",NULL, swap_var_code, 0, "<Item>" },
};

View File

@ -279,6 +279,38 @@ static void zoom_out(struct coord pos)
}
void zoom_in_center(void)
{
zoom_in(draw_ctx.center);
}
void zoom_out_center(void)
{
zoom_out(draw_ctx.center);
}
void zoom_to_frame(void)
{
tool_dehover();
center(&active_frame_bbox);
auto_scale(&active_frame_bbox);
redraw();
tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
}
void zoom_to_extents(void)
{
tool_dehover();
center(NULL);
auto_scale(NULL);
redraw();
tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
}
static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
gpointer data)
{
@ -321,18 +353,10 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
zoom_out(pos);
break;
case '*':
tool_dehover();
center(NULL);
auto_scale(NULL);
redraw();
tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
zoom_to_extents();
break;
case '#':
tool_dehover();
center(&active_frame_bbox);
auto_scale(&active_frame_bbox);
redraw();
tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
zoom_to_frame();
break;
case '.':
tool_dehover();

View File

@ -29,6 +29,11 @@ void refresh_pos(void);
void redraw(void);
void zoom_in_center(void);
void zoom_out_center(void);
void zoom_to_frame(void);
void zoom_to_extents(void);
GtkWidget *make_canvas(void);
void init_canvas(void);

View File

@ -743,6 +743,34 @@ static gboolean table_value_select_event(GtkWidget *widget,
}
static gboolean table_scroll_event(GtkWidget *widget, GdkEventScroll *event,
gpointer data)
{
struct table *table = data;
struct row *row, *last;
switch (event->direction) {
case GDK_SCROLL_UP:
last = NULL;
for (row = table->rows;
row && (!last || row != table->active_row); row = row->next)
last = row;
table->active_row = last;
change_world();
break;
case GDK_SCROLL_DOWN:
table->active_row = table->active_row->next;
if (!table->active_row)
table->active_row = table->rows;
change_world();
break;
default:
/* ignore */;
}
return TRUE;
}
static void build_table(GtkWidget *vbox, struct frame *frame,
struct table *table)
{
@ -786,6 +814,9 @@ static void build_table(GtkWidget *vbox, struct frame *frame,
g_signal_connect(G_OBJECT(box_of_label(field)),
"button_press_event",
G_CALLBACK(table_var_select_event), var);
g_signal_connect(G_OBJECT(box_of_label(field)),
"scroll_event",
G_CALLBACK(table_scroll_event), table);
var->widget = field;
n_vars++;
}
@ -805,6 +836,9 @@ static void build_table(GtkWidget *vbox, struct frame *frame,
g_signal_connect(G_OBJECT(box_of_label(field)),
"button_press_event",
G_CALLBACK(table_value_select_event), value);
g_signal_connect(G_OBJECT(box_of_label(field)),
"scroll_event",
G_CALLBACK(table_scroll_event), table);
value->widget = field;
n_vars++;
}

View File

@ -102,6 +102,7 @@ static int is_a_next(lt_op_type lt, struct inst *inst)
}
#if 0
static int is_min_of_next(lt_op_type lt,
const struct inst *inst, const struct inst *ref)
{
@ -111,6 +112,7 @@ static int is_min_of_next(lt_op_type lt,
next = meas_find_next(lt, ref->vec->samples, min);
return coord_eq(next, ref->u.rect.end);
}
#endif
/* ----- picker functions -------------------------------------------------- */

6
inst.c
View File

@ -879,14 +879,18 @@ int inst_meas(struct obj *obj,
struct coord from, struct coord to, unit_type offset)
{
struct inst *inst;
struct coord a1, b1;
inst = add_inst(&meas_ops, ip_meas, from);
inst->obj = obj;
inst->u.meas.end = to;
inst->u.meas.offset = offset;
inst->active = 1; /* measurements are always active */
/* @@@ our bbox is actually a bit more complex than this */
/* @@@ we still need to consider the text size as well */
update_bbox(&inst->bbox, to);
project_meas(inst, &a1, &b1);
update_bbox(&inst->bbox, a1);
update_bbox(&inst->bbox, b1);
propagate_bbox(inst);
return 1;
}