mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-25 19:44:05 +02:00
- gui_tools.c:new_vec didn't initialize vec->samples, causing fped to crash
- we didn't dehover before deleting, which could cause a crash - added delete tool to canvas. Thus ... - we no longer need the Delete key on the canvas, so we can ... - always focus the (first) entry field, and ... - removed "focus" parameter to edit functions git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5403 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
3ef1bb4afa
commit
bb7355d84b
2
Makefile
2
Makefile
@ -16,7 +16,7 @@ OBJS = fped.o expr.o coord.o obj.o delete.o inst.o util.o error.o \
|
||||
gui.o gui_util.o gui_style.o gui_inst.o gui_status.o gui_canvas.o \
|
||||
gui_tools.o
|
||||
|
||||
XPMS = point.xpm vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \
|
||||
XPMS = point.xpm delete.xpm vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \
|
||||
line.xpm rect.xpm pad.xpm circ.xpm meas.xpm
|
||||
|
||||
CFLAGS_GTK = `pkg-config --cflags gtk+-2.0`
|
||||
|
1
README
1
README
@ -399,7 +399,6 @@ Space reset user coordinates
|
||||
. cursor position to screen center (like middle click)
|
||||
* zoom and center to extents
|
||||
# zoom and center to currently active frame instance
|
||||
Delete delete the currently selected object
|
||||
U undelete the previously deleted object
|
||||
|
||||
|
||||
|
8
gui.c
8
gui.c
@ -534,7 +534,7 @@ static void edit_var(struct var *var)
|
||||
label_in_box_bg(var->widget, COLOR_VAR_EDITING);
|
||||
status_set_type_entry("name =");
|
||||
status_set_name("%s", var->name);
|
||||
edit_unique(&var->name, validate_var_name, var, 1);
|
||||
edit_unique(&var->name, validate_var_name, var);
|
||||
}
|
||||
|
||||
|
||||
@ -555,7 +555,7 @@ static void edit_value(struct value *value)
|
||||
{
|
||||
inst_select_outside(value, unselect_value);
|
||||
label_in_box_bg(value->widget, COLOR_EXPR_EDITING);
|
||||
edit_expr(&value->expr, 1);
|
||||
edit_expr(&value->expr);
|
||||
}
|
||||
|
||||
|
||||
@ -958,7 +958,7 @@ static gboolean part_name_edit_event(GtkWidget *widget, GdkEventButton *event,
|
||||
label_in_box_bg(widget, COLOR_PART_NAME_EDITING);
|
||||
status_set_type_entry("part =");
|
||||
status_set_name("%s", part_name);
|
||||
edit_name(&part_name, validate_part_name, NULL, 1);
|
||||
edit_name(&part_name, validate_part_name, NULL);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
@ -1019,7 +1019,7 @@ static void edit_frame(struct frame *frame)
|
||||
label_in_box_bg(frame->label, COLOR_FRAME_EDITING);
|
||||
status_set_type_entry("name =");
|
||||
status_set_name("%s", frame->name);
|
||||
edit_unique(&frame->name, validate_frame_name, frame, 1);
|
||||
edit_unique(&frame->name, validate_frame_name, frame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -307,6 +307,7 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
|
||||
break;
|
||||
case GDK_BackSpace:
|
||||
case GDK_Delete:
|
||||
#if 0
|
||||
case GDK_KP_Delete:
|
||||
if (selected_inst) {
|
||||
inst_delete(selected_inst);
|
||||
@ -314,6 +315,7 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
|
||||
change_world();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 'u':
|
||||
if (undelete())
|
||||
change_world();
|
||||
|
30
gui_status.c
30
gui_status.c
@ -168,8 +168,7 @@ static gboolean edit_key_press_event(GtkWidget *widget, GdkEventKey *event,
|
||||
}
|
||||
|
||||
|
||||
static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx,
|
||||
int focus)
|
||||
static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx)
|
||||
{
|
||||
gtk_object_set_data(GTK_OBJECT(widget), "edit-ops", ops);
|
||||
gtk_object_set_data(GTK_OBJECT(widget), "edit-ctx", ctx);
|
||||
@ -177,7 +176,7 @@ static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx,
|
||||
|
||||
reset_edit(widget);
|
||||
|
||||
if (focus)
|
||||
if (!open_edits)
|
||||
gtk_widget_grab_focus(GTK_WIDGET(widget));
|
||||
gtk_widget_show(widget);
|
||||
|
||||
@ -241,14 +240,14 @@ static struct edit_ops edit_ops_unique = {
|
||||
|
||||
|
||||
void edit_unique(const char **s, int (*validate)(const char *s, void *ctx),
|
||||
void *ctx, int focus)
|
||||
void *ctx)
|
||||
{
|
||||
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, focus);
|
||||
setup_edit(status_entry, &edit_ops_unique, &unique_ctx);
|
||||
}
|
||||
|
||||
|
||||
@ -287,14 +286,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 focus)
|
||||
int (*validate)(const char *s, void *ctx), void *ctx)
|
||||
{
|
||||
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, focus);
|
||||
setup_edit(status_entry, &edit_ops_null_unique, &unique_ctx);
|
||||
}
|
||||
|
||||
|
||||
@ -343,15 +342,14 @@ static struct edit_ops edit_ops_name = {
|
||||
};
|
||||
|
||||
|
||||
void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx,
|
||||
int focus)
|
||||
void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx)
|
||||
{
|
||||
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, focus);
|
||||
setup_edit(status_entry, &edit_ops_name, &name_ctx);
|
||||
}
|
||||
|
||||
|
||||
@ -405,27 +403,27 @@ static struct edit_ops edit_ops_expr = {
|
||||
};
|
||||
|
||||
|
||||
static void edit_any_expr(GtkWidget *widget, struct expr **expr, int focus)
|
||||
static void edit_any_expr(GtkWidget *widget, struct expr **expr)
|
||||
{
|
||||
setup_edit(widget, &edit_ops_expr, expr, focus);
|
||||
setup_edit(widget, &edit_ops_expr, expr);
|
||||
}
|
||||
|
||||
|
||||
void edit_expr(struct expr **expr, int focus)
|
||||
void edit_expr(struct expr **expr)
|
||||
{
|
||||
edit_any_expr(status_entry, expr, focus);
|
||||
edit_any_expr(status_entry, expr);
|
||||
}
|
||||
|
||||
|
||||
void edit_x(struct expr **expr)
|
||||
{
|
||||
edit_any_expr(status_entry_x, expr, 0);
|
||||
edit_any_expr(status_entry_x, expr);
|
||||
}
|
||||
|
||||
|
||||
void edit_y(struct expr **expr)
|
||||
{
|
||||
edit_any_expr(status_entry_y, expr, 0);
|
||||
edit_any_expr(status_entry_y, expr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,12 +21,11 @@
|
||||
|
||||
|
||||
void edit_unique(const char **s, int (*validate)(const char *s, void *ctx),
|
||||
void *ctx, int focus);
|
||||
void *ctx);
|
||||
void edit_unique_null(const char **s, int (*validate)(const char *s, void *ctx),
|
||||
void *ctx, int focus);
|
||||
void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx,
|
||||
int focus);
|
||||
void edit_expr(struct expr **expr, int focus);
|
||||
void *ctx);
|
||||
void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx);
|
||||
void edit_expr(struct expr **expr);
|
||||
void edit_x(struct expr **expr);
|
||||
void edit_y(struct expr **expr);
|
||||
void edit_nothing(void);
|
||||
|
42
gui_tools.c
42
gui_tools.c
@ -35,6 +35,7 @@
|
||||
#include "icons/meas.xpm"
|
||||
#include "icons/pad.xpm"
|
||||
#include "icons/point.xpm"
|
||||
#include "icons/delete.xpm"
|
||||
#include "icons/rect.xpm"
|
||||
#include "icons/vec.xpm"
|
||||
|
||||
@ -44,6 +45,7 @@
|
||||
|
||||
struct tool_ops {
|
||||
void (*tool_selected)(void);
|
||||
void (*click)(struct draw_ctx *ctx, struct coord pos);
|
||||
struct pix_buf *(*drag_new)(struct draw_ctx *ctx, struct inst *from,
|
||||
struct coord to);
|
||||
int (*end_new_raw)(struct draw_ctx *ctx, struct inst *from,
|
||||
@ -83,6 +85,7 @@ static struct vec *new_vec(struct inst *base)
|
||||
vec->base = inst_get_vec(base);
|
||||
vec->next = NULL;
|
||||
vec->frame = active_frame;
|
||||
vec->samples = NULL;
|
||||
for (walk = &active_frame->vecs; *walk; walk = &(*walk)->next);
|
||||
*walk = vec;
|
||||
return vec;
|
||||
@ -160,6 +163,27 @@ static struct pix_buf *draw_move_rect_common(struct inst *inst,
|
||||
}
|
||||
|
||||
|
||||
/* ----- delete ------------------------------------------------------------ */
|
||||
|
||||
|
||||
static void click_delete(struct draw_ctx *ctx, struct coord pos)
|
||||
{
|
||||
inst_deselect();
|
||||
inst_select(ctx, pos);
|
||||
if (selected_inst) {
|
||||
tool_dehover(ctx);
|
||||
inst_delete(selected_inst);
|
||||
}
|
||||
change_world();
|
||||
tool_reset();
|
||||
}
|
||||
|
||||
|
||||
static struct tool_ops delete_ops = {
|
||||
.click = click_delete,
|
||||
};
|
||||
|
||||
|
||||
/* ----- vec --------------------------------------------------------------- */
|
||||
|
||||
|
||||
@ -707,6 +731,10 @@ int tool_consider_drag(struct draw_ctx *ctx, struct coord pos)
|
||||
assert(!drag.new);
|
||||
assert(!drag.anchors_n);
|
||||
last_canvas_pos = translate(ctx, pos);
|
||||
if (active_ops && active_ops->click) {
|
||||
active_ops->click(ctx, pos);
|
||||
return 0;
|
||||
}
|
||||
curr = inst_find_point(ctx, pos);
|
||||
if (!curr)
|
||||
return 0;
|
||||
@ -882,6 +910,16 @@ static GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable,
|
||||
}
|
||||
|
||||
|
||||
static void tool_separator(GtkWidget *bar)
|
||||
{
|
||||
GtkToolItem *item;
|
||||
|
||||
item = gtk_separator_tool_item_new();
|
||||
gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(item), FALSE);
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(bar), item, -1);
|
||||
}
|
||||
|
||||
|
||||
GtkWidget *gui_setup_tools(GdkDrawable *drawable)
|
||||
{
|
||||
GtkWidget *bar;
|
||||
@ -893,7 +931,9 @@ GtkWidget *gui_setup_tools(GdkDrawable *drawable)
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
ev_point = tool_button(bar, drawable, xpm_point, NULL, NULL);
|
||||
last = tool_button(bar, drawable, xpm_vec, ev_point, &vec_ops);
|
||||
last = tool_button(bar, drawable, xpm_delete, ev_point, &delete_ops);
|
||||
tool_separator(bar);
|
||||
last = tool_button(bar, drawable, xpm_vec, last, &vec_ops);
|
||||
ev_frame = tool_button(bar, drawable, NULL, last, &frame_ops);
|
||||
last = ev_frame;
|
||||
last = tool_button(bar, drawable, xpm_pad, last, &pad_ops);
|
||||
|
15
icons/delete.fig
Normal file
15
icons/delete.fig
Normal file
@ -0,0 +1,15 @@
|
||||
#FIG 3.2 Produced by xfig version 3.2.5a
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
A4
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
|
||||
3600 2400 6000 2400 6000 4800 3600 4800 3600 2400
|
||||
2 1 0 15 18 7 50 -1 -1 0.000 0 1 -1 0 0 2
|
||||
4125 2925 5475 4275
|
||||
2 1 0 15 18 7 50 -1 -1 0.000 0 1 -1 0 0 2
|
||||
4125 4275 5475 2925
|
12
inst.c
12
inst.c
@ -358,7 +358,7 @@ static void vec_op_select(struct inst *self)
|
||||
rect_status(self->base, self->u.rect.end, -1);
|
||||
edit_x(&self->vec->x);
|
||||
edit_y(&self->vec->y);
|
||||
edit_unique_null(&self->vec->name, validate_vec_name, self->vec, 0);
|
||||
edit_unique_null(&self->vec->name, validate_vec_name, self->vec);
|
||||
}
|
||||
|
||||
|
||||
@ -407,7 +407,7 @@ static void line_op_debug(struct inst *self)
|
||||
static void line_op_select(struct inst *self)
|
||||
{
|
||||
rect_status(self->bbox.min, self->bbox.max, self->u.rect.width);
|
||||
edit_expr(&self->obj->u.line.width, 0);
|
||||
edit_expr(&self->obj->u.line.width);
|
||||
}
|
||||
|
||||
|
||||
@ -460,7 +460,7 @@ static void rect_op_debug(struct inst *self)
|
||||
static void rect_op_select(struct inst *self)
|
||||
{
|
||||
rect_status(self->bbox.min, self->bbox.max, self->u.rect.width);
|
||||
edit_expr(&self->obj->u.rect.width, 0);
|
||||
edit_expr(&self->obj->u.rect.width);
|
||||
}
|
||||
|
||||
|
||||
@ -517,7 +517,7 @@ static void pad_op_select(struct inst *self)
|
||||
status_set_type_entry("label =");
|
||||
status_set_name("%s", self->u.pad.name);
|
||||
rect_status(self->base, self->u.pad.other, -1);
|
||||
edit_name(&self->obj->u.pad.name, validate_pad_name, NULL, 0);
|
||||
edit_name(&self->obj->u.pad.name, validate_pad_name, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -575,7 +575,7 @@ static void arc_op_select(struct inst *self)
|
||||
status_set_r("r = %5.2f mm", units_to_mm(self->u.arc.r));
|
||||
status_set_type_entry("width =");
|
||||
status_set_name("%5.2f mm", units_to_mm(self->u.arc.width));
|
||||
edit_expr(&self->obj->u.arc.width, 0);
|
||||
edit_expr(&self->obj->u.arc.width);
|
||||
}
|
||||
|
||||
|
||||
@ -645,7 +645,7 @@ static void meas_op_select(struct inst *self)
|
||||
status_set_name("%5.2f mm", units_to_mm(self->u.meas.offset));
|
||||
if (!self->obj)
|
||||
return; /* @@@ new-style measurements */
|
||||
edit_expr(&self->obj->u.meas.offset, 0);
|
||||
edit_expr(&self->obj->u.meas.offset);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user