1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-12-01 13:54:05 +02:00

Added tooltips for editable status area items. All tools are now tipped.

- gui_status.h, gui_status.c (edit_*): edit functions now accept a tooltip
- added tooltips for editable status area items
- tooltips on setup_set_type_* looked strange. Show them only for the value
  field next to the type field.



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5776 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2010-01-03 00:36:52 +00:00
parent feabeb73f4
commit 393c178a5f
5 changed files with 70 additions and 71 deletions

1
TODO
View File

@ -27,7 +27,6 @@ Style and usability:
- when changing the part, we should automatically switch to a configuration - when changing the part, we should automatically switch to a configuration
that generates any of its (non-global) elements that generates any of its (non-global) elements
- add zoom controls to top toolbar - add zoom controls to top toolbar
- add tooltips (in progress)
Bugs: Bugs:
- default silk width has no business being hard-coded in obj.c - default silk width has no business being hard-coded in obj.c

View File

@ -541,11 +541,13 @@ static void edit_var(struct var *var,
{ {
inst_select_outside(var, unselect_var); inst_select_outside(var, unselect_var);
label_in_box_bg(var->widget, COLOR_VAR_EDITING); label_in_box_bg(var->widget, COLOR_VAR_EDITING);
status_set_type_entry("Variable name", "name ="); status_set_type_entry(NULL, "name =");
status_set_name("Variable name", "%s", var->name); status_set_name("Variable name", "%s", var->name);
edit_nothing(); edit_nothing();
edit_unique_with_values(&var->name, validate_var_name, var, edit_unique_with_values(&var->name, validate_var_name, var,
set_values, user, max_values); set_values, user, max_values,
"Variable name. "
"Shortcut:<b><i>name</i>=<i>value</i>,<i>...</i> </b>");
} }
@ -578,7 +580,7 @@ static void edit_value(struct value *value)
inst_select_outside(value, unselect_value); inst_select_outside(value, unselect_value);
label_in_box_bg(value->widget, COLOR_EXPR_EDITING); label_in_box_bg(value->widget, COLOR_EXPR_EDITING);
edit_nothing(); edit_nothing();
edit_expr(&value->expr); edit_expr(&value->expr, "Value");
} }
@ -589,7 +591,7 @@ static void edit_value_list(struct value *value,
inst_select_outside(value, unselect_value); inst_select_outside(value, unselect_value);
label_in_box_bg(value->widget, COLOR_VAR_EDITING); label_in_box_bg(value->widget, COLOR_VAR_EDITING);
edit_nothing(); edit_nothing();
edit_expr_list(value->expr, set_values, user); edit_expr_list(value->expr, set_values, user, "Value(s)");
} }
@ -1336,10 +1338,11 @@ static gboolean pkg_name_edit_event(GtkWidget *widget, GdkEventButton *event,
case 1: case 1:
inst_select_outside(widget, unselect_pkg_name); inst_select_outside(widget, unselect_pkg_name);
label_in_box_bg(widget, COLOR_PART_NAME_EDITING); label_in_box_bg(widget, COLOR_PART_NAME_EDITING);
status_set_type_entry("Package name", "package ="); status_set_type_entry(NULL, "package =");
status_set_name("Package name (actual)", "%s", pkg_name); status_set_name("Package name (actual)", "%s", pkg_name);
edit_nothing(); edit_nothing();
edit_name(&pkg_name, validate_pkg_name, NULL); edit_name(&pkg_name, validate_pkg_name, NULL,
"Package name (template)");
break; break;
} }
return TRUE; return TRUE;
@ -1470,10 +1473,10 @@ static void edit_frame(struct frame *frame)
inst_select_outside(frame, unselect_frame); inst_select_outside(frame, unselect_frame);
label_in_box_bg(frame->label, COLOR_FRAME_EDITING); label_in_box_bg(frame->label, COLOR_FRAME_EDITING);
tip = "Frame name"; tip = "Frame name";
status_set_type_entry(tip, "name ="); status_set_type_entry(NULL, "name =");
status_set_name(tip, "%s", frame->name); status_set_name(tip, "%s", frame->name);
edit_nothing(); edit_nothing();
edit_unique(&frame->name, validate_frame_name, frame); edit_unique(&frame->name, validate_frame_name, frame, tip);
} }

View File

@ -159,8 +159,8 @@ void status_set_icon(GtkWidget *image)
void status_set_xy(struct coord coord) void status_set_xy(struct coord coord)
{ {
/* do dX/dY etc. stuff later */ /* do dX/dY etc. stuff later */
status_set_type_x("Width", "X ="); status_set_type_x(NULL, "X =");
status_set_type_y("Height", "Y ="); status_set_type_y(NULL, "Y =");
set_with_units(status_set_x, "", coord.x, "Width"); set_with_units(status_set_x, "", coord.x, "Width");
set_with_units(status_set_y, "", coord.y, "Height"); set_with_units(status_set_y, "", coord.y, "Height");
@ -301,7 +301,8 @@ static gboolean edit_key_press_event(GtkWidget *widget, GdkEventKey *event,
} }
static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx) static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx,
const char *tooltip)
{ {
gtk_object_set_data(GTK_OBJECT(widget), "edit-ops", ops); gtk_object_set_data(GTK_OBJECT(widget), "edit-ops", ops);
gtk_object_set_data(GTK_OBJECT(widget), "edit-ctx", ctx); gtk_object_set_data(GTK_OBJECT(widget), "edit-ctx", ctx);
@ -321,6 +322,7 @@ static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx)
else else
open_edits = widget; open_edits = widget;
last_edit = widget; last_edit = widget;
gtk_widget_set_tooltip_markup(widget, tooltip);
} }
@ -373,14 +375,14 @@ static struct edit_ops edit_ops_unique = {
void edit_unique(const char **s, int (*validate)(const char *s, void *ctx), void edit_unique(const char **s, int (*validate)(const char *s, void *ctx),
void *ctx) void *ctx, const char *tooltip)
{ {
static struct edit_unique_ctx unique_ctx; static struct edit_unique_ctx unique_ctx;
unique_ctx.s = s; unique_ctx.s = s;
unique_ctx.validate = validate; unique_ctx.validate = validate;
unique_ctx.ctx = ctx; unique_ctx.ctx = ctx;
setup_edit(status_entry, &edit_ops_unique, &unique_ctx); setup_edit(status_entry, &edit_ops_unique, &unique_ctx, tooltip);
} }
@ -419,14 +421,14 @@ static struct edit_ops edit_ops_null_unique = {
void edit_unique_null(const char **s, void edit_unique_null(const char **s,
int (*validate)(const char *s, void *ctx), void *ctx) int (*validate)(const char *s, void *ctx), void *ctx, const char *tooltip)
{ {
static struct edit_unique_ctx unique_ctx; static struct edit_unique_ctx unique_ctx;
unique_ctx.s = s; unique_ctx.s = s;
unique_ctx.validate = validate; unique_ctx.validate = validate;
unique_ctx.ctx = ctx; unique_ctx.ctx = ctx;
setup_edit(status_entry, &edit_ops_null_unique, &unique_ctx); setup_edit(status_entry, &edit_ops_null_unique, &unique_ctx, tooltip);
} }
@ -490,7 +492,8 @@ static struct edit_ops edit_ops_unique_with_values = {
void edit_unique_with_values(const char **s, void edit_unique_with_values(const char **s,
int (*validate)(const char *s, void *ctx), void *ctx, int (*validate)(const char *s, void *ctx), void *ctx,
void (*set_values)(void *user, const struct value *values, int n_values), void (*set_values)(void *user, const struct value *values, int n_values),
void *user, int max_values) void *user, int max_values,
const char *tooltip)
{ {
static struct edit_unique_with_values_ctx unique_ctx; static struct edit_unique_with_values_ctx unique_ctx;
@ -500,7 +503,8 @@ void edit_unique_with_values(const char **s,
unique_ctx.set_values = set_values; unique_ctx.set_values = set_values;
unique_ctx.user = user; unique_ctx.user = user;
unique_ctx.max_values = max_values; unique_ctx.max_values = max_values;
setup_edit(status_entry, &edit_ops_unique_with_values, &unique_ctx); setup_edit(status_entry, &edit_ops_unique_with_values, &unique_ctx,
tooltip);
} }
@ -549,14 +553,15 @@ static struct edit_ops edit_ops_name = {
}; };
void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx) void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx,
const char *tooltip)
{ {
static struct edit_name_ctx name_ctx; static struct edit_name_ctx name_ctx;
name_ctx.s = s; name_ctx.s = s;
name_ctx.validate = validate; name_ctx.validate = validate;
name_ctx.ctx = ctx; name_ctx.ctx = ctx;
setup_edit(status_entry, &edit_ops_name, &name_ctx); setup_edit(status_entry, &edit_ops_name, &name_ctx, tooltip);
} }
@ -610,30 +615,31 @@ static struct edit_ops edit_ops_expr = {
}; };
static void edit_any_expr(GtkWidget *widget, struct expr **expr) static void edit_any_expr(GtkWidget *widget, struct expr **expr,
const char *tooltip)
{ {
setup_edit(widget, &edit_ops_expr, expr); setup_edit(widget, &edit_ops_expr, expr, tooltip);
} }
void edit_expr(struct expr **expr) void edit_expr(struct expr **expr, const char *tooltip)
{ {
edit_any_expr(status_entry, expr); edit_any_expr(status_entry, expr, tooltip);
} }
void edit_x(struct expr **expr) void edit_x(struct expr **expr, const char *tooltip)
{ {
vacate_widget(status_box_x); vacate_widget(status_box_x);
gtk_container_add(GTK_CONTAINER(status_box_x), status_entry_x); gtk_container_add(GTK_CONTAINER(status_box_x), status_entry_x);
gtk_widget_show(status_box_x); gtk_widget_show(status_box_x);
edit_any_expr(status_entry_x, expr); edit_any_expr(status_entry_x, expr, tooltip);
} }
void edit_y(struct expr **expr) void edit_y(struct expr **expr, const char *tooltip)
{ {
edit_any_expr(status_entry_y, expr); edit_any_expr(status_entry_y, expr, tooltip);
} }
@ -693,14 +699,14 @@ static struct edit_ops edit_ops_expr_list = {
void edit_expr_list(struct expr *expr, void edit_expr_list(struct expr *expr,
void (*set_values)(void *user, const struct value *values, int n_values), void (*set_values)(void *user, const struct value *values, int n_values),
void *user) void *user, const char *tooltip)
{ {
static struct edit_expr_list_ctx expr_list_ctx; static struct edit_expr_list_ctx expr_list_ctx;
expr_list_ctx.expr = expr; expr_list_ctx.expr = expr;
expr_list_ctx.set_values = set_values; expr_list_ctx.set_values = set_values;
expr_list_ctx.user = user; expr_list_ctx.user = user;
setup_edit(status_entry, &edit_ops_expr_list, &expr_list_ctx); setup_edit(status_entry, &edit_ops_expr_list, &expr_list_ctx, tooltip);
} }

View File

@ -34,20 +34,21 @@ extern enum curr_unit curr_unit;
void edit_pad_type(enum pad_type *type); void edit_pad_type(enum pad_type *type);
void edit_unique(const char **s, int (*validate)(const char *s, void *ctx), void edit_unique(const char **s, int (*validate)(const char *s, void *ctx),
void *ctx); void *ctx, const char *tooltip);
void edit_unique_null(const char **s, int (*validate)(const char *s, void *ctx), void edit_unique_null(const char **s, int (*validate)(const char *s, void *ctx),
void *ctx); void *ctx, const char *tooltip);
void edit_unique_with_values(const char **s, void edit_unique_with_values(const char **s,
int (*validate)(const char *s, void *ctx), void *ctx, int (*validate)(const char *s, void *ctx), void *ctx,
void (*set_values)(void *user, const struct value *values, int n_values), void (*set_values)(void *user, const struct value *values, int n_values),
void *user, int max_values); void *user, int max_values, const char *tooltip);
void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx); void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx,
void edit_expr(struct expr **expr); const char *tooltip);
void edit_expr(struct expr **expr, const char *tooltip);
void edit_expr_list(struct expr *expr, void edit_expr_list(struct expr *expr,
void (*set_values)(void *user, const struct value *values, int n_values), void (*set_values)(void *user, const struct value *values, int n_values),
void *user); void *user, const char *tooltip);
void edit_x(struct expr **expr); void edit_x(struct expr **expr, const char *tooltip);
void edit_y(struct expr **expr); void edit_y(struct expr **expr, const char *tooltip);
void edit_nothing(void); void edit_nothing(void);
void set_with_units(void (*set)(const char *tooltip, const char *fmt, ...), void set_with_units(void (*set)(const char *tooltip, const char *fmt, ...),

56
inst.c
View File

@ -492,9 +492,8 @@ static void rect_status(struct coord a, struct coord b, unit_type width,
} }
set_with_units(status_set_r, "d = ", diag, "Length of diagonal"); set_with_units(status_set_r, "d = ", diag, "Length of diagonal");
if (width != -1) { if (width != -1) {
tip = "Line width"; status_set_type_entry(NULL, "width =");
status_set_type_entry(tip, "width ="); set_with_units(status_set_name, "", width, "Line width");
set_with_units(status_set_name, "", width, tip);
} }
} }
@ -573,19 +572,17 @@ static int validate_vec_name(const char *s, void *ctx)
static void vec_edit(struct vec *vec) static void vec_edit(struct vec *vec)
{ {
edit_x(&vec->x); edit_x(&vec->x, "X distance");
edit_y(&vec->y); edit_y(&vec->y, "Y distance");
edit_unique_null(&vec->name, validate_vec_name, vec); edit_unique_null(&vec->name, validate_vec_name, vec, "Vector name");
} }
static void vec_op_select(struct inst *self) static void vec_op_select(struct inst *self)
{ {
const char *tip; status_set_type_entry(NULL, "ref =");
status_set_name("Vector reference (name)",
tip = "Vector reference (name)"; "%s", self->vec->name ? self->vec->name : "");
status_set_type_entry(tip, "ref =");
status_set_name(tip, "%s", self->vec->name ? self->vec->name : "");
rect_status(self->base, self->u.vec.end, -1, 0); rect_status(self->base, self->u.vec.end, -1, 0);
vec_edit(self->vec); vec_edit(self->vec);
} }
@ -710,7 +707,7 @@ int inst_vec(struct vec *vec, struct coord base)
static void obj_line_edit(struct obj *obj) static void obj_line_edit(struct obj *obj)
{ {
edit_expr(&obj->u.line.width); edit_expr(&obj->u.line.width, "Line width");
} }
@ -760,7 +757,7 @@ int inst_line(struct obj *obj, struct coord a, struct coord b, unit_type width)
static void obj_rect_edit(struct obj *obj) static void obj_rect_edit(struct obj *obj)
{ {
edit_expr(&obj->u.rect.width); edit_expr(&obj->u.rect.width, "Line width");
} }
@ -814,13 +811,14 @@ static int validate_pad_name(const char *s, void *ctx)
static void obj_pad_edit(struct obj *obj) static void obj_pad_edit(struct obj *obj)
{ {
edit_pad_type(&obj->u.pad.type); edit_pad_type(&obj->u.pad.type);
edit_name(&obj->u.pad.name, validate_pad_name, NULL); edit_name(&obj->u.pad.name, validate_pad_name, NULL,
"Pad name (template)");
} }
static void pad_op_select(struct inst *self) static void pad_op_select(struct inst *self)
{ {
status_set_type_entry("Pad name", "label ="); status_set_type_entry(NULL, "label =");
status_set_name("Pad name (actual)", "%s", self->u.pad.name); status_set_name("Pad name (actual)", "%s", self->u.pad.name);
rect_status(self->base, self->u.pad.other, -1, 0); rect_status(self->base, self->u.pad.other, -1, 0);
obj_pad_edit(self->obj); obj_pad_edit(self->obj);
@ -848,7 +846,7 @@ static struct inst_ops pad_ops = {
static void rpad_op_select(struct inst *self) static void rpad_op_select(struct inst *self)
{ {
status_set_type_entry("Pad name", "label ="); status_set_type_entry(NULL, "label =");
status_set_name("Pad name (actual)", "%s", self->u.pad.name); status_set_name("Pad name (actual)", "%s", self->u.pad.name);
rect_status(self->base, self->u.pad.other, -1, 1); rect_status(self->base, self->u.pad.other, -1, 1);
obj_pad_edit(self->obj); obj_pad_edit(self->obj);
@ -886,22 +884,19 @@ int inst_pad(struct obj *obj, const char *name, struct coord a, struct coord b)
static void obj_arc_edit(struct obj *obj) static void obj_arc_edit(struct obj *obj)
{ {
edit_expr(&obj->u.arc.width); edit_expr(&obj->u.arc.width, "Line width");
} }
static void arc_op_select(struct inst *self) static void arc_op_select(struct inst *self)
{ {
const char *tip;
status_set_xy(self->base); status_set_xy(self->base);
status_set_angle("Angle", "a = %3.1f deg", status_set_angle("Angle", "a = %3.1f deg",
self->u.arc.a1 == self->u.arc.a2 ? 360 : self->u.arc.a1 == self->u.arc.a2 ? 360 :
self->u.arc.a2-self->u.arc.a1); self->u.arc.a2-self->u.arc.a1);
set_with_units(status_set_r, "r = ", self->u.arc.r, "Radius"); set_with_units(status_set_r, "r = ", self->u.arc.r, "Radius");
tip = "Line width"; status_set_type_entry(NULL, "width =");
status_set_type_entry(tip, "width ="); set_with_units(status_set_name, "", self->u.arc.width, "Line width");
set_with_units(status_set_name, "", self->u.arc.width, tip);
obj_arc_edit(self->obj); obj_arc_edit(self->obj);
} }
@ -962,18 +957,16 @@ int inst_arc(struct obj *obj, struct coord center, struct coord start,
static void obj_meas_edit(struct obj *obj) static void obj_meas_edit(struct obj *obj)
{ {
edit_expr(&obj->u.meas.offset); edit_expr(&obj->u.meas.offset, "Measurement line offset");
} }
static void meas_op_select(struct inst *self) static void meas_op_select(struct inst *self)
{ {
const char *tip;
rect_status(self->bbox.min, self->bbox.max, -1, 0); rect_status(self->bbox.min, self->bbox.max, -1, 0);
tip = "Measurement line offset"; status_set_type_entry(NULL, "offset =");
status_set_type_entry(tip, "offset ="); set_with_units(status_set_name, "", self->u.meas.offset,
set_with_units(status_set_name, "", self->u.meas.offset, tip); "Measurement line offset");
obj_meas_edit(self->obj); obj_meas_edit(self->obj);
} }
@ -1096,12 +1089,9 @@ void inst_end_active(void)
static void frame_op_select(struct inst *self) static void frame_op_select(struct inst *self)
{ {
const char *tip;
tip = "Frame name";
rect_status(self->bbox.min, self->bbox.max, -1, 0); rect_status(self->bbox.min, self->bbox.max, -1, 0);
status_set_type_entry(tip, "name ="); status_set_type_entry(NULL, "name =");
status_set_name(tip, "%s", self->u.frame.ref->name); status_set_name("Frame name", "%s", self->u.frame.ref->name);
} }