1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-25 18:01:54 +02:00

As a shortcut, accept entry of "0" as a valid distance for dimensions. (For

safety, this only works if used directly, not through variables.)

- gui_status.c (edit_any_expr): replaced with dist_expr_store, which changes
  values of "0" to "0mm"
- gui_status.c, gui_status.h (edit_dist_expr): new function to edit distance
  expressions
- inst.c (obj_line_edit, obj_rect_edit, obj_arc_edit, obj_meas_edit): changed
  edit_expr to edit_dist_expr



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5844 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2010-02-18 13:39:20 +00:00
parent 0115283735
commit 3d6ef48930
3 changed files with 40 additions and 11 deletions

View File

@ -615,16 +615,44 @@ static struct edit_ops edit_ops_expr = {
};
static void edit_any_expr(GtkWidget *widget, struct expr **expr,
const char *tooltip)
void edit_expr(struct expr **expr, const char *tooltip)
{
setup_edit(widget, &edit_ops_expr, expr, tooltip);
setup_edit(status_entry, &edit_ops_expr, expr, tooltip);
}
void edit_expr(struct expr **expr, const char *tooltip)
/* ----- distance expressions ---------------------------------------------- */
static void dist_expr_store(const char *s, void *ctx)
{
edit_any_expr(status_entry, expr, tooltip);
struct expr **anchor = ctx;
struct expr *expr;
expr_store(s, ctx);
expr = *anchor;
if (expr->op == op_num && !expr->u.num.exponent && !expr->u.num.n)
expr->u.num.exponent = 1;
}
static struct edit_ops edit_ops_dist_expr = {
.retrieve = expr_retrieve,
.status = expr_status,
.store = dist_expr_store,
};
static void edit_any_dist_expr(GtkWidget *widget, struct expr **expr,
const char *tooltip)
{
setup_edit(widget, &edit_ops_dist_expr, expr, tooltip);
}
void edit_dist_expr(struct expr **expr, const char *tooltip)
{
edit_any_dist_expr(status_entry, expr, tooltip);
}
@ -633,13 +661,13 @@ void edit_x(struct expr **expr, const char *tooltip)
vacate_widget(status_box_x);
gtk_container_add(GTK_CONTAINER(status_box_x), status_entry_x);
gtk_widget_show(status_box_x);
edit_any_expr(status_entry_x, expr, tooltip);
edit_any_dist_expr(status_entry_x, expr, tooltip);
}
void edit_y(struct expr **expr, const char *tooltip)
{
edit_any_expr(status_entry_y, expr, tooltip);
edit_any_dist_expr(status_entry_y, expr, tooltip);
}

View File

@ -47,6 +47,7 @@ void edit_expr(struct expr **expr, const char *tooltip);
void edit_expr_list(struct expr *expr,
void (*set_values)(void *user, const struct value *values, int n_values),
void *user, const char *tooltip);
void edit_dist_expr(struct expr **expr, const char *tooltip);
void edit_x(struct expr **expr, const char *tooltip);
void edit_y(struct expr **expr, const char *tooltip);
void edit_nothing(void);

8
inst.c
View File

@ -754,7 +754,7 @@ int inst_vec(struct vec *vec, struct coord base)
static void obj_line_edit(struct obj *obj)
{
edit_expr(&obj->u.line.width, "Line width");
edit_dist_expr(&obj->u.line.width, "Line width");
}
@ -805,7 +805,7 @@ int inst_line(struct obj *obj, struct coord a, struct coord b, unit_type width)
static void obj_rect_edit(struct obj *obj)
{
edit_expr(&obj->u.rect.width, "Line width");
edit_dist_expr(&obj->u.rect.width, "Line width");
}
@ -934,7 +934,7 @@ int inst_pad(struct obj *obj, const char *name, struct coord a, struct coord b)
static void obj_arc_edit(struct obj *obj)
{
edit_expr(&obj->u.arc.width, "Line width");
edit_dist_expr(&obj->u.arc.width, "Line width");
}
@ -1008,7 +1008,7 @@ int inst_arc(struct obj *obj, struct coord center, struct coord start,
static void obj_meas_edit(struct obj *obj)
{
edit_expr(&obj->u.meas.offset, "Measurement line offset");
edit_dist_expr(&obj->u.meas.offset, "Measurement line offset");
}