1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-05 04:35:19 +02:00

Make delete feel "safer".

- objects are now deleted by selecting them, then clicking on the delete icon
- removed tool_ops.click, which was only there because of delete



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5419 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-11 20:52:33 +00:00
parent 57e76aeb9e
commit fe5f824b9e
7 changed files with 55 additions and 21 deletions

View File

@ -18,7 +18,7 @@ OBJS = fped.o expr.o coord.o obj.o delete.o inst.o util.o error.o \
XPMS = point.xpm delete.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 meas_x.xpm meas_y.xpm \ line.xpm rect.xpm pad.xpm circ.xpm meas.xpm meas_x.xpm meas_y.xpm \
stuff.xpm stuff_off.xpm meas_off.xpm stuff.xpm stuff_off.xpm meas_off.xpm delete_off.xpm
CFLAGS_GTK = `pkg-config --cflags gtk+-2.0` CFLAGS_GTK = `pkg-config --cflags gtk+-2.0`
LIBS_GTK = `pkg-config --libs gtk+-2.0` LIBS_GTK = `pkg-config --libs gtk+-2.0`

13
TODO
View File

@ -2,9 +2,10 @@ Major missing features:
- populate input area (still needed: mm/mil, rezoom) - populate input area (still needed: mm/mil, rezoom)
- add default unit (combine with grid unit selection ?) - add default unit (combine with grid unit selection ?)
- consider adding auto/mm/mil selection for each dimension - consider adding auto/mm/mil selection for each dimension
- add postscript output - add postscript output (partially done)
- add option to include/omit helper vecs and frames (done for display, still - add option to include/omit helper vecs and frames (done for display, still
need postscript) need postscript). Better idea: in PS, print the component 10x, 1x, and then
each individual frame 10x.
Minor missing features: Minor missing features:
- reorder frames (can use text editor) - reorder frames (can use text editor)
@ -35,6 +36,9 @@ Code cleanup:
- the drag logic is too complex. Better: let tool/instance just generate the - the drag logic is too complex. Better: let tool/instance just generate the
list of points at each stage, then handle the highlighting and hovering list of points at each stage, then handle the highlighting and hovering
inside a dragging module. inside a dragging module.
- code organization is very poor. E.g., functions belonging to the different
items (pads, silk objects, vectors, etc.) should be grouped by item, not by
type of function, similar to how some things are now with gui_meas.c
Open decisions: Open decisions:
- Q: should loop be (start, last) or (start, iterations) ? or start ... last ? - Q: should loop be (start, last) or (start, iterations) ? or start ... last ?
@ -60,5 +64,8 @@ Future directions:
- advanced: silk line width - advanced: silk line width
- future: when encountering an error after a change, we could try to find the - future: when encountering an error after a change, we could try to find the
same element in the old instance, and select it same element in the old instance, and select it
- future: consider editing off-canvas items in place - idea: run the sort algorithm of dump.c to generate a list of objects per
frame, then show the list per frame in the GUI, e.g., as an alternative to
the variables. Allow selection.
- future: consider editing non-canvas items in place
- near future: treat part name as pattern - near future: treat part name as pattern

View File

@ -41,15 +41,17 @@
#include "icons/pad.xpm" #include "icons/pad.xpm"
#include "icons/point.xpm" #include "icons/point.xpm"
#include "icons/delete.xpm" #include "icons/delete.xpm"
#include "icons/delete_off.xpm"
#include "icons/rect.xpm" #include "icons/rect.xpm"
#include "icons/vec.xpm" #include "icons/vec.xpm"
static GtkWidget *ev_point, *ev_frame; static GtkWidget *ev_point, *ev_delete, *ev_frame;
static GtkWidget *active_tool; static GtkWidget *active_tool;
static struct tool_ops *active_ops = NULL; static struct tool_ops *active_ops = NULL;
static struct inst *hover_inst = NULL; static struct inst *hover_inst = NULL;
static GtkWidget *frame_image, *frame_image_locked, *frame_image_ready; static GtkWidget *frame_image, *frame_image_locked, *frame_image_ready;
static GtkWidget *delete_image[2];
static struct drag_state { static struct drag_state {
struct inst *inst; /* non-NULL if dragging an existing object */ struct inst *inst; /* non-NULL if dragging an existing object */
@ -167,24 +169,28 @@ static struct pix_buf *hover_common(GdkGC *gc, struct coord center, unit_type r)
/* ----- delete ------------------------------------------------------------ */ /* ----- delete ------------------------------------------------------------ */
static void click_delete(struct coord pos) static void tool_selected_delete(void)
{ {
inst_deselect();
inst_select(pos);
if (selected_inst) { if (selected_inst) {
tool_dehover(); tool_dehover();
inst_delete(selected_inst); inst_delete(selected_inst);
change_world();
} }
change_world();
tool_reset(); tool_reset();
} }
static struct tool_ops delete_ops = { static struct tool_ops delete_ops = {
.click = click_delete, .tool_selected = tool_selected_delete,
}; };
void tool_selected_inst(struct inst *inst)
{
set_image(ev_delete, delete_image[inst != NULL]);
}
/* ----- vec --------------------------------------------------------------- */ /* ----- vec --------------------------------------------------------------- */
@ -772,7 +778,7 @@ static struct pix_buf *drag_save_and_draw(void *user, struct coord to)
* | | * | |
* N N don't * N N don't
* Y - if we could drag, drag_new/end_new, else fall over to tool * Y - if we could drag, drag_new/end_new, else fall over to tool
* N Y click, else single-click creation, else drag_new/end_new * N Y else single-click creation, else drag_new/end_new
*/ */
int tool_consider_drag(struct coord pos) int tool_consider_drag(struct coord pos)
@ -800,10 +806,6 @@ int tool_consider_drag(struct coord pos)
} }
if (!active_ops) if (!active_ops)
return 0; return 0;
if (active_ops->click) {
active_ops->click(pos);
return 0;
}
curr = get_hover_inst(pos); curr = get_hover_inst(pos);
if (!curr) if (!curr)
@ -961,8 +963,8 @@ GtkWidget *gui_setup_tools(GdkDrawable *drawable)
ev_point = tool_button(bar, drawable, xpm_point, ev_point = tool_button(bar, drawable, xpm_point,
tool_button_press_event, NULL); tool_button_press_event, NULL);
tool_button(bar, drawable, xpm_delete, ev_delete = tool_button(bar, drawable, NULL,
tool_button_press_event, &delete_ops); tool_button_press_event, &delete_ops);
tool_separator(bar); tool_separator(bar);
tool_button(bar, drawable, xpm_vec, tool_button(bar, drawable, xpm_vec,
tool_button_press_event, &vec_ops); tool_button_press_event, &vec_ops);
@ -991,6 +993,10 @@ GtkWidget *gui_setup_tools(GdkDrawable *drawable)
gtk_widget_ref(make_image(drawable, xpm_frame_ready)); gtk_widget_ref(make_image(drawable, xpm_frame_ready));
set_frame_image(frame_image); set_frame_image(frame_image);
delete_image[0] = gtk_widget_ref(make_image(drawable, xpm_delete_off));
delete_image[1] = gtk_widget_ref(make_image(drawable, xpm_delete));
set_image(ev_delete, delete_image[0]);
tool_reset(); tool_reset();
return bar; return bar;

View File

@ -23,7 +23,6 @@ struct tool_ops {
void (*tool_selected)(void); void (*tool_selected)(void);
void (*tool_deselected)(void); void (*tool_deselected)(void);
struct inst *(*find_point)(struct coord pos); struct inst *(*find_point)(struct coord pos);
void (*click)(struct coord pos);
void (*begin_drag_new)(struct inst *from); void (*begin_drag_new)(struct inst *from);
struct pix_buf *(*drag_new)(struct inst *from, struct coord to); struct pix_buf *(*drag_new)(struct inst *from, struct coord to);
int (*end_new_raw)(struct inst *from, struct coord to); int (*end_new_raw)(struct inst *from, struct coord to);
@ -71,6 +70,8 @@ struct pix_buf *drag_new_line(struct inst *from, struct coord to);
void tool_frame_update(void); void tool_frame_update(void);
void tool_frame_deleted(const struct frame *frame); void tool_frame_deleted(const struct frame *frame);
void tool_selected_inst(struct inst *inst);
void tool_reset(void); void tool_reset(void);
GtkWidget *gui_setup_tools(GdkDrawable *drawable); GtkWidget *gui_setup_tools(GdkDrawable *drawable);

View File

@ -9,7 +9,7 @@ Single
1200 2 1200 2
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 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 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 2 1 0 15 19 7 50 -1 -1 0.000 0 1 -1 0 0 2
4125 2925 5475 4275 4125 2925 5475 4275
2 1 0 15 18 7 50 -1 -1 0.000 0 1 -1 0 0 2 2 1 0 15 19 7 50 -1 -1 0.000 0 1 -1 0 0 2
4125 4275 5475 2925 4125 4275 5475 2925

15
icons/delete_off.fig Normal file
View 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 55 -1 10 0.000 0 0 -1 0 0 5
3600 2400 6000 2400 6000 4800 3600 4800 3600 2400
2 1 0 15 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
4125 2925 5475 4275
2 1 0 15 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
4125 4275 5475 2925

7
inst.c
View File

@ -118,6 +118,8 @@ int inst_select(struct coord pos)
deselect_outside(); deselect_outside();
edit_nothing(); edit_nothing();
selected_inst = NULL; selected_inst = NULL;
if (selected_inst)
tool_selected_inst(NULL);
FOR_INST_PRIOS_DOWN(prio) { FOR_INST_PRIOS_DOWN(prio) {
if (!show(prio)) if (!show(prio))
continue; continue;
@ -154,6 +156,7 @@ int inst_select(struct coord pos)
selected: selected:
set_path(1); set_path(1);
tool_selected_inst(selected_inst);
if (selected_inst->ops->select) if (selected_inst->ops->select)
selected_inst->ops->select(selected_inst); selected_inst->ops->select(selected_inst);
return 1; return 1;
@ -263,8 +266,10 @@ int inst_anchors(struct inst *inst, struct vec ***anchors)
void inst_deselect(void) void inst_deselect(void)
{ {
if (selected_inst) if (selected_inst) {
set_path(0); set_path(0);
tool_selected_inst(NULL);
}
deselect_outside(); deselect_outside();
status_set_type_x(""); status_set_type_x("");
status_set_type_y(""); status_set_type_y("");