From 393c178a5f26b8f3adde5752ffc13958c9b495f7 Mon Sep 17 00:00:00 2001 From: werner Date: Sun, 3 Jan 2010 00:36:52 +0000 Subject: [PATCH] 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 --- TODO | 1 - gui_frame.c | 19 ++++++++++-------- gui_status.c | 48 ++++++++++++++++++++++++-------------------- gui_status.h | 17 ++++++++-------- inst.c | 56 +++++++++++++++++++++------------------------------- 5 files changed, 70 insertions(+), 71 deletions(-) diff --git a/TODO b/TODO index 5670e14..1423201 100644 --- a/TODO +++ b/TODO @@ -27,7 +27,6 @@ Style and usability: - when changing the part, we should automatically switch to a configuration that generates any of its (non-global) elements - add zoom controls to top toolbar -- add tooltips (in progress) Bugs: - default silk width has no business being hard-coded in obj.c diff --git a/gui_frame.c b/gui_frame.c index 7eafcd5..aeaecef 100644 --- a/gui_frame.c +++ b/gui_frame.c @@ -541,11 +541,13 @@ static void edit_var(struct var *var, { inst_select_outside(var, unselect_var); 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); edit_nothing(); edit_unique_with_values(&var->name, validate_var_name, var, - set_values, user, max_values); + set_values, user, max_values, + "Variable name. " + "Shortcut:name=value,... "); } @@ -578,7 +580,7 @@ static void edit_value(struct value *value) inst_select_outside(value, unselect_value); label_in_box_bg(value->widget, COLOR_EXPR_EDITING); 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); label_in_box_bg(value->widget, COLOR_VAR_EDITING); 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: inst_select_outside(widget, unselect_pkg_name); 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); edit_nothing(); - edit_name(&pkg_name, validate_pkg_name, NULL); + edit_name(&pkg_name, validate_pkg_name, NULL, + "Package name (template)"); break; } return TRUE; @@ -1470,10 +1473,10 @@ static void edit_frame(struct frame *frame) inst_select_outside(frame, unselect_frame); label_in_box_bg(frame->label, COLOR_FRAME_EDITING); tip = "Frame name"; - status_set_type_entry(tip, "name ="); + status_set_type_entry(NULL, "name ="); status_set_name(tip, "%s", frame->name); edit_nothing(); - edit_unique(&frame->name, validate_frame_name, frame); + edit_unique(&frame->name, validate_frame_name, frame, tip); } diff --git a/gui_status.c b/gui_status.c index 103cb81..0790e84 100644 --- a/gui_status.c +++ b/gui_status.c @@ -159,8 +159,8 @@ void status_set_icon(GtkWidget *image) void status_set_xy(struct coord coord) { /* do dX/dY etc. stuff later */ - status_set_type_x("Width", "X ="); - status_set_type_y("Height", "Y ="); + status_set_type_x(NULL, "X ="); + status_set_type_y(NULL, "Y ="); set_with_units(status_set_x, "", coord.x, "Width"); 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-ctx", ctx); @@ -321,6 +322,7 @@ static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx) else open_edits = 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 *ctx) + void *ctx, const char *tooltip) { static struct edit_unique_ctx unique_ctx; unique_ctx.s = s; unique_ctx.validate = validate; 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, - 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; unique_ctx.s = s; unique_ctx.validate = validate; 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, int (*validate)(const char *s, void *ctx), void *ctx, 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; @@ -500,7 +503,8 @@ void edit_unique_with_values(const char **s, unique_ctx.set_values = set_values; unique_ctx.user = user; 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; name_ctx.s = s; name_ctx.validate = validate; 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); gtk_container_add(GTK_CONTAINER(status_box_x), status_entry_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 (*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; expr_list_ctx.expr = expr; expr_list_ctx.set_values = set_values; 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); } diff --git a/gui_status.h b/gui_status.h index 8a6db63..82af96a 100644 --- a/gui_status.h +++ b/gui_status.h @@ -34,20 +34,21 @@ extern enum curr_unit curr_unit; void edit_pad_type(enum pad_type *type); 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 *ctx); + void *ctx, const char *tooltip); void edit_unique_with_values(const char **s, int (*validate)(const char *s, void *ctx), void *ctx, void (*set_values)(void *user, const struct value *values, int n_values), - void *user, int max_values); -void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx); -void edit_expr(struct expr **expr); + void *user, int max_values, const char *tooltip); +void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx, + const char *tooltip); +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); -void edit_x(struct expr **expr); -void edit_y(struct expr **expr); + void *user, 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); void set_with_units(void (*set)(const char *tooltip, const char *fmt, ...), diff --git a/inst.c b/inst.c index 0aa8eeb..c09c816 100644 --- a/inst.c +++ b/inst.c @@ -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"); if (width != -1) { - tip = "Line width"; - status_set_type_entry(tip, "width ="); - set_with_units(status_set_name, "", width, tip); + status_set_type_entry(NULL, "width ="); + set_with_units(status_set_name, "", width, "Line width"); } } @@ -573,19 +572,17 @@ static int validate_vec_name(const char *s, void *ctx) static void vec_edit(struct vec *vec) { - edit_x(&vec->x); - edit_y(&vec->y); - edit_unique_null(&vec->name, validate_vec_name, vec); + edit_x(&vec->x, "X distance"); + edit_y(&vec->y, "Y distance"); + edit_unique_null(&vec->name, validate_vec_name, vec, "Vector name"); } static void vec_op_select(struct inst *self) { - const char *tip; - - tip = "Vector reference (name)"; - status_set_type_entry(tip, "ref ="); - status_set_name(tip, "%s", self->vec->name ? self->vec->name : ""); + status_set_type_entry(NULL, "ref ="); + status_set_name("Vector reference (name)", + "%s", self->vec->name ? self->vec->name : ""); rect_status(self->base, self->u.vec.end, -1, 0); 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) { - 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) { - 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) { 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) { - status_set_type_entry("Pad name", "label ="); + status_set_type_entry(NULL, "label ="); status_set_name("Pad name (actual)", "%s", self->u.pad.name); rect_status(self->base, self->u.pad.other, -1, 0); obj_pad_edit(self->obj); @@ -848,7 +846,7 @@ static struct inst_ops pad_ops = { 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); rect_status(self->base, self->u.pad.other, -1, 1); 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) { - edit_expr(&obj->u.arc.width); + edit_expr(&obj->u.arc.width, "Line width"); } static void arc_op_select(struct inst *self) { - const char *tip; - status_set_xy(self->base); status_set_angle("Angle", "a = %3.1f deg", self->u.arc.a1 == self->u.arc.a2 ? 360 : self->u.arc.a2-self->u.arc.a1); set_with_units(status_set_r, "r = ", self->u.arc.r, "Radius"); - tip = "Line width"; - status_set_type_entry(tip, "width ="); - set_with_units(status_set_name, "", self->u.arc.width, tip); + status_set_type_entry(NULL, "width ="); + set_with_units(status_set_name, "", self->u.arc.width, "Line width"); 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) { - edit_expr(&obj->u.meas.offset); + edit_expr(&obj->u.meas.offset, "Measurement line offset"); } static void meas_op_select(struct inst *self) { - const char *tip; - rect_status(self->bbox.min, self->bbox.max, -1, 0); - tip = "Measurement line offset"; - status_set_type_entry(tip, "offset ="); - set_with_units(status_set_name, "", self->u.meas.offset, tip); + status_set_type_entry(NULL, "offset ="); + set_with_units(status_set_name, "", self->u.meas.offset, + "Measurement line offset"); obj_meas_edit(self->obj); } @@ -1096,12 +1089,9 @@ void inst_end_active(void) static void frame_op_select(struct inst *self) { - const char *tip; - - tip = "Frame name"; rect_status(self->bbox.min, self->bbox.max, -1, 0); - status_set_type_entry(tip, "name ="); - status_set_name(tip, "%s", self->u.frame.ref->name); + status_set_type_entry(NULL, "name ="); + status_set_name("Frame name", "%s", self->u.frame.ref->name); }