2009-08-03 19:12:47 +03:00
|
|
|
/*
|
2009-08-08 22:44:17 +03:00
|
|
|
* gui_tool.c - GUI, tool bar
|
2009-08-03 19:12:47 +03:00
|
|
|
*
|
2011-10-25 22:46:26 +03:00
|
|
|
* Written 2009-2011 by Werner Almesberger
|
|
|
|
* Copyright 2009-2011 by Werner Almesberger
|
2009-08-03 19:12:47 +03:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-08-04 21:03:06 +03:00
|
|
|
#include <stdlib.h>
|
2009-08-05 17:44:36 +03:00
|
|
|
#include <math.h>
|
2009-08-04 21:03:06 +03:00
|
|
|
#include <assert.h>
|
2009-08-03 19:12:47 +03:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2009-08-04 15:06:04 +03:00
|
|
|
#include "util.h"
|
|
|
|
#include "inst.h"
|
2009-12-15 23:24:30 +02:00
|
|
|
#include "meas.h"
|
2009-08-04 15:06:04 +03:00
|
|
|
#include "obj.h"
|
2009-08-03 19:12:47 +03:00
|
|
|
#include "gui_util.h"
|
2009-08-04 15:06:04 +03:00
|
|
|
#include "gui_style.h"
|
|
|
|
#include "gui_inst.h"
|
2009-08-08 17:11:26 +03:00
|
|
|
#include "gui_over.h"
|
2009-08-08 00:47:51 +03:00
|
|
|
#include "gui_canvas.h"
|
2009-08-05 17:44:36 +03:00
|
|
|
#include "gui_status.h"
|
|
|
|
#include "gui.h"
|
2009-08-08 21:50:17 +03:00
|
|
|
#include "gui_meas.h"
|
2009-08-08 22:44:17 +03:00
|
|
|
#include "gui_tool.h"
|
2009-08-03 19:12:47 +03:00
|
|
|
|
|
|
|
|
2009-12-15 23:24:30 +02:00
|
|
|
#include "icons/arc.xpm"
|
2009-08-03 19:12:47 +03:00
|
|
|
#include "icons/circ.xpm"
|
|
|
|
#include "icons/frame.xpm"
|
|
|
|
#include "icons/line.xpm"
|
|
|
|
#include "icons/meas.xpm"
|
2009-08-08 00:47:51 +03:00
|
|
|
#include "icons/meas_x.xpm"
|
|
|
|
#include "icons/meas_y.xpm"
|
2009-08-03 19:12:47 +03:00
|
|
|
#include "icons/pad.xpm"
|
2009-08-14 13:18:40 +03:00
|
|
|
#include "icons/rpad.xpm"
|
2010-04-25 13:58:07 +03:00
|
|
|
#include "icons/hole.xpm"
|
2009-08-03 19:12:47 +03:00
|
|
|
#include "icons/point.xpm"
|
2009-08-07 22:42:57 +03:00
|
|
|
#include "icons/delete.xpm"
|
2009-08-11 23:52:33 +03:00
|
|
|
#include "icons/delete_off.xpm"
|
2009-08-03 19:12:47 +03:00
|
|
|
#include "icons/rect.xpm"
|
|
|
|
#include "icons/vec.xpm"
|
|
|
|
|
|
|
|
|
2010-04-25 03:11:45 +03:00
|
|
|
static GtkWidget *ev_point, *ev_delete;
|
2009-08-04 15:06:04 +03:00
|
|
|
static GtkWidget *active_tool;
|
|
|
|
static struct tool_ops *active_ops = NULL;
|
|
|
|
static struct inst *hover_inst = NULL;
|
2009-08-11 23:52:33 +03:00
|
|
|
static GtkWidget *delete_image[2];
|
2009-08-05 17:44:36 +03:00
|
|
|
|
2009-08-04 21:03:06 +03:00
|
|
|
static struct drag_state {
|
2009-08-05 17:44:36 +03:00
|
|
|
struct inst *inst; /* non-NULL if dragging an existing object */
|
2009-08-04 21:03:06 +03:00
|
|
|
struct inst *new; /* non-NULL if dragging a new object */
|
|
|
|
int anchors_n; /* number of anchors, 0 if no moving */
|
|
|
|
int anchor_i; /* current anchor */
|
|
|
|
struct vec **anchors[3];
|
|
|
|
} drag = {
|
|
|
|
.new = NULL,
|
|
|
|
.anchors_n = 0,
|
|
|
|
};
|
|
|
|
|
2009-08-07 19:19:23 +03:00
|
|
|
static struct coord last_canvas_pos;
|
2009-08-04 15:06:04 +03:00
|
|
|
|
2009-08-05 17:44:36 +03:00
|
|
|
|
|
|
|
static struct vec *new_vec(struct inst *base)
|
|
|
|
{
|
|
|
|
struct vec *vec, **walk;
|
|
|
|
|
|
|
|
vec = alloc_type(struct vec);
|
2011-10-25 22:46:26 +03:00
|
|
|
vec->nul_tag = 0;
|
2009-08-05 17:44:36 +03:00
|
|
|
vec->name = NULL;
|
2009-08-06 07:33:49 +03:00
|
|
|
vec->base = inst_get_vec(base);
|
2009-08-05 17:44:36 +03:00
|
|
|
vec->next = NULL;
|
|
|
|
vec->frame = active_frame;
|
|
|
|
for (walk = &active_frame->vecs; *walk; walk = &(*walk)->next);
|
|
|
|
*walk = vec;
|
|
|
|
return vec;
|
|
|
|
}
|
2009-08-04 15:06:04 +03:00
|
|
|
|
|
|
|
|
2009-08-12 00:54:18 +03:00
|
|
|
struct obj *new_obj_unconnected(enum obj_type type, struct inst *base)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2009-08-12 00:54:18 +03:00
|
|
|
struct obj *obj;
|
2009-08-04 15:06:04 +03:00
|
|
|
|
|
|
|
obj = alloc_type(struct obj);
|
|
|
|
obj->type = type;
|
2010-04-25 13:58:07 +03:00
|
|
|
obj->name = NULL;
|
2009-08-05 17:44:36 +03:00
|
|
|
obj->frame = active_frame;
|
2009-08-06 07:33:49 +03:00
|
|
|
obj->base = inst_get_vec(base);
|
2009-08-04 15:06:04 +03:00
|
|
|
obj->next = NULL;
|
|
|
|
obj->lineno = 0;
|
2009-08-12 00:54:18 +03:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void connect_obj(struct frame *frame, struct obj *obj)
|
|
|
|
{
|
|
|
|
struct obj **walk;
|
|
|
|
|
2009-08-22 17:29:48 +03:00
|
|
|
obj->frame = frame;
|
2009-08-12 00:54:18 +03:00
|
|
|
for (walk = &frame->objs; *walk; walk = &(*walk)->next);
|
2009-08-04 15:06:04 +03:00
|
|
|
*walk = obj;
|
2009-08-12 00:54:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct obj *new_obj(enum obj_type type, struct inst *base)
|
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
obj = new_obj_unconnected(type, base);
|
|
|
|
connect_obj(active_frame, obj);
|
2009-08-04 15:06:04 +03:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 17:44:36 +03:00
|
|
|
/* ----- shared functions -------------------------------------------------- */
|
2009-08-04 15:06:04 +03:00
|
|
|
|
|
|
|
|
2009-08-08 21:50:17 +03:00
|
|
|
struct pix_buf *draw_move_line_common(struct inst *inst,
|
2009-08-08 17:11:26 +03:00
|
|
|
struct coord end, struct coord pos, int i)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2009-08-05 17:44:36 +03:00
|
|
|
struct coord from, to;
|
2009-08-04 15:06:04 +03:00
|
|
|
struct pix_buf *buf;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
from = translate(inst->base);
|
|
|
|
to = translate(end);
|
|
|
|
pos = translate(pos);
|
2009-08-05 17:44:36 +03:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
from = pos;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
to = pos;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
buf = save_pix_buf(DA, from.x, from.y, to.x, to.y, 1);
|
|
|
|
gdk_draw_line(DA, gc_drag, from.x, from.y, to.x, to.y);
|
2009-08-04 15:06:04 +03:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 17:44:36 +03:00
|
|
|
static struct pix_buf *draw_move_rect_common(struct inst *inst,
|
2009-08-08 17:11:26 +03:00
|
|
|
struct coord other, struct coord pos, int i)
|
2009-08-05 00:45:33 +03:00
|
|
|
{
|
2009-08-05 17:44:36 +03:00
|
|
|
struct coord min, max;
|
2009-08-05 00:45:33 +03:00
|
|
|
struct pix_buf *buf;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
min = translate(inst->base);
|
|
|
|
max = translate(other);
|
|
|
|
pos = translate(pos);
|
2009-08-05 00:45:33 +03:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2009-08-05 17:44:36 +03:00
|
|
|
min = pos;
|
2009-08-05 00:45:33 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2009-08-05 17:44:36 +03:00
|
|
|
max = pos;
|
2009-08-05 00:45:33 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2009-08-05 17:44:36 +03:00
|
|
|
sort_coord(&min, &max);
|
|
|
|
buf = save_pix_buf(DA, min.x, min.y, max.x, max.y, 1);
|
|
|
|
gdk_draw_rectangle(DA, gc_drag, FALSE,
|
|
|
|
min.x, min.y, max.x-min.x, max.y-min.y);
|
2009-08-05 00:45:33 +03:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static struct pix_buf *hover_common(GdkGC *gc, struct coord center, unit_type r)
|
|
|
|
{
|
|
|
|
struct pix_buf *buf;
|
|
|
|
|
|
|
|
center = translate(center);
|
|
|
|
buf = save_pix_buf(DA,
|
|
|
|
center.x-r, center.y-r, center.x+r, center.y+r, 2);
|
|
|
|
draw_circle(DA, gc, FALSE, center.x, center.y, VEC_EYE_R);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-07 22:42:57 +03:00
|
|
|
/* ----- delete ------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
2009-08-11 23:52:33 +03:00
|
|
|
static void tool_selected_delete(void)
|
2009-08-07 22:42:57 +03:00
|
|
|
{
|
|
|
|
if (selected_inst) {
|
2009-08-08 17:11:26 +03:00
|
|
|
tool_dehover();
|
2009-08-07 22:42:57 +03:00
|
|
|
inst_delete(selected_inst);
|
2009-08-11 23:52:33 +03:00
|
|
|
change_world();
|
2009-08-07 22:42:57 +03:00
|
|
|
}
|
|
|
|
tool_reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops delete_ops = {
|
2009-08-11 23:52:33 +03:00
|
|
|
.tool_selected = tool_selected_delete,
|
2009-08-07 22:42:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-11 23:52:33 +03:00
|
|
|
void tool_selected_inst(struct inst *inst)
|
|
|
|
{
|
|
|
|
set_image(ev_delete, delete_image[inst != NULL]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 17:44:36 +03:00
|
|
|
/* ----- vec --------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-06 07:33:49 +03:00
|
|
|
static struct coord gridify(struct coord base, struct coord pos)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
2009-08-06 07:33:49 +03:00
|
|
|
struct coord new;
|
2009-08-22 18:58:58 +03:00
|
|
|
unit_type unit;
|
2009-08-06 07:33:49 +03:00
|
|
|
|
2009-08-22 18:58:58 +03:00
|
|
|
switch (curr_unit) {
|
|
|
|
case curr_unit_mm:
|
|
|
|
case curr_unit_auto:
|
|
|
|
unit = mm_to_units(0.1);
|
|
|
|
break;
|
|
|
|
case curr_unit_mil:
|
|
|
|
unit = mil_to_units(10);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2009-08-07 03:48:06 +03:00
|
|
|
new.x = pos.x-((pos.x-base.x) % unit);
|
|
|
|
new.y = pos.y-((pos.y-base.y) % unit);
|
2009-08-06 07:33:49 +03:00
|
|
|
if (new.x != base.x || new.y != base.y)
|
|
|
|
return new;
|
|
|
|
if (fabs(pos.x-base.x) > fabs(pos.y-base.y))
|
|
|
|
new.x += pos.x > base.x ? unit : -unit;
|
|
|
|
else
|
|
|
|
new.y += pos.y > base.y ? unit : -unit;
|
|
|
|
return new;
|
2009-08-05 17:44:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static struct pix_buf *drag_new_vec(struct inst *from, struct coord to)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
|
|
|
struct coord pos;
|
|
|
|
struct pix_buf *buf;
|
|
|
|
|
|
|
|
pos = inst_get_point(from);
|
2009-08-06 07:33:49 +03:00
|
|
|
to = gridify(pos, to);
|
2010-01-03 01:27:36 +02:00
|
|
|
status_set_type_x(NULL, "dX =");
|
|
|
|
status_set_type_y(NULL, "dX =");
|
2009-08-22 18:58:58 +03:00
|
|
|
/* @@@ use status_set_xy */
|
|
|
|
switch (curr_unit) {
|
|
|
|
case curr_unit_mm:
|
|
|
|
case curr_unit_auto:
|
2010-01-03 01:27:36 +02:00
|
|
|
status_set_x(NULL, "%lg mm", units_to_mm(to.x-pos.x));
|
|
|
|
status_set_y(NULL, "%lg mm", units_to_mm(to.y-pos.y));
|
2009-08-22 18:58:58 +03:00
|
|
|
break;
|
|
|
|
case curr_unit_mil:
|
2010-01-03 01:27:36 +02:00
|
|
|
status_set_x(NULL, "%lg mil", units_to_mil(to.x-pos.x));
|
|
|
|
status_set_y(NULL, "%lg mil", units_to_mil(to.y-pos.y));
|
2009-08-22 18:58:58 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2009-08-08 17:11:26 +03:00
|
|
|
pos = translate(pos);
|
|
|
|
to = translate(to);
|
2009-08-05 17:44:36 +03:00
|
|
|
buf = save_pix_buf(DA, pos.x, pos.y, to.x, to.y, 1);
|
|
|
|
gdk_draw_line(DA, gc_drag, pos.x, pos.y, to.x, to.y);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
struct pix_buf *draw_move_vec(struct inst *inst, struct coord pos, int i)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
|
|
|
return draw_move_line_common(inst,
|
2009-08-27 12:01:24 +03:00
|
|
|
add_vec(sub_vec(inst->u.vec.end, inst->base), pos), pos, i);
|
2009-08-08 17:11:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct pix_buf *gui_hover_vec(struct inst *self)
|
|
|
|
{
|
|
|
|
return hover_common(gc_vec[mode_hover],
|
2009-08-27 12:01:24 +03:00
|
|
|
self->u.vec.end, VEC_EYE_R);
|
2009-08-05 17:44:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static int end_new_raw_vec(struct inst *from, struct coord to)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
|
|
|
struct vec *vec;
|
|
|
|
struct coord pos;
|
|
|
|
|
|
|
|
vec = new_vec(from);
|
|
|
|
pos = inst_get_point(from);
|
2009-08-06 07:33:49 +03:00
|
|
|
to = gridify(pos, to);
|
2009-08-22 18:58:58 +03:00
|
|
|
switch (curr_unit) {
|
|
|
|
case curr_unit_mm:
|
|
|
|
case curr_unit_auto:
|
|
|
|
vec->x = new_num(make_mm(units_to_mm(to.x-pos.x)));
|
|
|
|
vec->y = new_num(make_mm(units_to_mm(to.y-pos.y)));
|
|
|
|
break;
|
|
|
|
case curr_unit_mil:
|
|
|
|
vec->x = new_num(make_mil(units_to_mil(to.x-pos.x)));
|
|
|
|
vec->y = new_num(make_mil(units_to_mil(to.y-pos.y)));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2009-08-05 17:44:36 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops vec_ops = {
|
|
|
|
.drag_new = drag_new_vec,
|
|
|
|
.end_new_raw = end_new_raw_vec,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- line -------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-08 21:50:17 +03:00
|
|
|
struct pix_buf *drag_new_line(struct inst *from, struct coord to)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
|
|
|
struct coord pos;
|
|
|
|
struct pix_buf *buf;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
pos = translate(inst_get_point(from));
|
|
|
|
to = translate(to);
|
2009-08-05 17:44:36 +03:00
|
|
|
buf = save_pix_buf(DA, pos.x, pos.y, to.x, to.y, 1);
|
|
|
|
gdk_draw_line(DA, gc_drag, pos.x, pos.y, to.x, to.y);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
struct pix_buf *draw_move_line(struct inst *inst, struct coord pos, int i)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
2009-08-08 17:11:26 +03:00
|
|
|
return draw_move_line_common(inst, inst->u.rect.end, pos, i);
|
2009-08-05 17:44:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static int end_new_line(struct inst *from, struct inst *to)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
if (from == to)
|
|
|
|
return 0;
|
|
|
|
obj = new_obj(ot_line, from);
|
2009-08-06 07:33:49 +03:00
|
|
|
obj->u.line.other = inst_get_vec(to);
|
2009-08-04 15:06:04 +03:00
|
|
|
obj->u.line.width = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops line_ops = {
|
2009-08-04 21:03:06 +03:00
|
|
|
.drag_new = drag_new_line,
|
|
|
|
.end_new = end_new_line,
|
2009-08-04 15:06:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- rect -------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static struct pix_buf *drag_new_rect(struct inst *from, struct coord to)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
|
|
|
struct coord pos;
|
|
|
|
struct pix_buf *buf;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
pos = translate(inst_get_point(from));
|
|
|
|
to = translate(to);
|
2009-08-05 00:45:33 +03:00
|
|
|
sort_coord(&pos, &to);
|
2009-08-04 15:06:04 +03:00
|
|
|
buf = save_pix_buf(DA, pos.x, pos.y, to.x, to.y, 1);
|
|
|
|
gdk_draw_rectangle(DA, gc_drag, FALSE,
|
|
|
|
pos.x, pos.y, to.x-pos.x, to.y-pos.y);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
struct pix_buf *draw_move_rect(struct inst *inst, struct coord pos, int i)
|
2009-08-05 00:45:33 +03:00
|
|
|
{
|
2009-08-08 17:11:26 +03:00
|
|
|
return draw_move_rect_common(inst, inst->u.rect.end, pos, i);
|
2009-08-05 00:45:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static int end_new_rect(struct inst *from, struct inst *to)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
if (from == to)
|
|
|
|
return 0;
|
|
|
|
obj = new_obj(ot_rect, from);
|
2009-08-06 07:33:49 +03:00
|
|
|
obj->u.rect.other = inst_get_vec(to);
|
2009-08-04 15:06:04 +03:00
|
|
|
obj->u.rect.width = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops rect_ops = {
|
2009-08-04 21:03:06 +03:00
|
|
|
.drag_new = drag_new_rect,
|
|
|
|
.end_new = end_new_rect,
|
2009-08-04 15:06:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-05 00:45:33 +03:00
|
|
|
/* ----- pad --------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static int end_new_pad(struct inst *from, struct inst *to)
|
2009-08-05 00:45:33 +03:00
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
if (from == to)
|
|
|
|
return 0;
|
|
|
|
obj = new_obj(ot_pad, from);
|
2009-08-06 07:33:49 +03:00
|
|
|
obj->u.pad.other = inst_get_vec(to);
|
2009-08-05 00:45:33 +03:00
|
|
|
obj->u.pad.name = stralloc("?");
|
2009-08-14 13:18:40 +03:00
|
|
|
obj->u.pad.rounded = 0;
|
2009-09-13 14:11:03 +03:00
|
|
|
obj->u.pad.type = pt_normal;
|
2009-08-05 00:45:33 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
struct pix_buf *draw_move_pad(struct inst *inst, struct coord pos, int i)
|
2009-08-05 00:45:33 +03:00
|
|
|
{
|
2009-08-08 17:11:26 +03:00
|
|
|
return draw_move_rect_common(inst, inst->u.pad.other, pos, i);
|
2009-08-05 00:45:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops pad_ops = {
|
|
|
|
.drag_new = drag_new_rect,
|
|
|
|
.end_new = end_new_pad,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-14 13:18:40 +03:00
|
|
|
/* ----- rounded pad ------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static int end_new_rpad(struct inst *from, struct inst *to)
|
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
if (from == to)
|
|
|
|
return 0;
|
|
|
|
obj = new_obj(ot_pad, from);
|
|
|
|
obj->u.pad.other = inst_get_vec(to);
|
|
|
|
obj->u.pad.name = stralloc("?");
|
|
|
|
obj->u.pad.rounded = 1;
|
2009-12-01 03:04:32 +02:00
|
|
|
obj->u.pad.type = pt_normal;
|
2009-08-14 13:18:40 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct pix_buf *draw_move_rpad(struct inst *inst, struct coord pos, int i)
|
|
|
|
{
|
|
|
|
return draw_move_rect_common(inst, inst->u.pad.other, pos, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops rpad_ops = {
|
|
|
|
.drag_new = drag_new_rect,
|
|
|
|
.end_new = end_new_rpad,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-04-25 13:58:07 +03:00
|
|
|
/* ----- hole -------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static int end_new_hole(struct inst *from, struct inst *to)
|
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
if (from == to)
|
|
|
|
return 0;
|
|
|
|
obj = new_obj(ot_hole, from);
|
|
|
|
obj->u.hole.other = inst_get_vec(to);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct pix_buf *draw_move_hole(struct inst *inst, struct coord pos, int i)
|
|
|
|
{
|
|
|
|
return draw_move_rect_common(inst, inst->u.hole.other, pos, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops hole_ops = {
|
|
|
|
.drag_new = drag_new_rect,
|
|
|
|
.end_new = end_new_hole,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-04 15:06:04 +03:00
|
|
|
/* ----- circ -------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static struct pix_buf *drag_new_circ(struct inst *from, struct coord to)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
|
|
|
struct coord pos;
|
|
|
|
struct pix_buf *buf;
|
|
|
|
double r;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
pos = translate(inst_get_point(from));
|
|
|
|
to = translate(to);
|
2009-08-04 15:06:04 +03:00
|
|
|
r = hypot(to.x-pos.x, to.y-pos.y);
|
|
|
|
buf = save_pix_buf(DA, pos.x-r, pos.y-r, pos.x+r, pos.y+r, 1);
|
|
|
|
draw_circle(DA, gc_drag, FALSE, pos.x, pos.y, r);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static int end_new_circ(struct inst *from, struct inst *to)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
if (from == to)
|
|
|
|
return 0;
|
|
|
|
obj = new_obj(ot_arc, from);
|
2009-08-06 07:33:49 +03:00
|
|
|
obj->u.arc.start = inst_get_vec(to);
|
|
|
|
obj->u.arc.end = inst_get_vec(to);
|
2009-08-04 15:06:04 +03:00
|
|
|
obj->u.arc.width = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
struct pix_buf *draw_move_arc(struct inst *inst, struct coord pos, int i)
|
2009-08-05 00:45:33 +03:00
|
|
|
{
|
2009-08-06 23:19:00 +03:00
|
|
|
struct coord c, from, to, end;
|
|
|
|
double r, r_save, a1, a2;
|
2009-08-05 00:45:33 +03:00
|
|
|
struct pix_buf *buf;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
c = translate(inst->base);
|
2009-08-05 00:45:33 +03:00
|
|
|
from =
|
2009-08-08 17:11:26 +03:00
|
|
|
translate(rotate_r(inst->base, inst->u.arc.r, inst->u.arc.a1));
|
2009-08-05 00:45:33 +03:00
|
|
|
to =
|
2009-08-08 17:11:26 +03:00
|
|
|
translate(rotate_r(inst->base, inst->u.arc.r, inst->u.arc.a2));
|
|
|
|
pos = translate(pos);
|
2009-08-05 00:45:33 +03:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
c = pos;
|
|
|
|
break;
|
|
|
|
case 2:
|
2009-08-18 23:52:09 +03:00
|
|
|
from = pos;
|
|
|
|
break;
|
|
|
|
case 1:
|
2009-08-05 00:45:33 +03:00
|
|
|
to = pos;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
r = hypot(from.x-c.x, from.y-c.y);
|
|
|
|
/*
|
|
|
|
* the screen coordinate system is reversed with y growing downward,
|
|
|
|
* so we have to negate the angles.
|
|
|
|
*/
|
|
|
|
a1 = -theta(c, from);
|
|
|
|
a2 = -theta(c, to);
|
|
|
|
if (a2 < a1)
|
|
|
|
a2 += 360.0;
|
2009-08-06 23:19:00 +03:00
|
|
|
|
|
|
|
if (i != 2)
|
|
|
|
r_save = r;
|
|
|
|
else {
|
|
|
|
r_save = hypot(to.x-c.x, to.y-c.y);
|
|
|
|
if (r > r_save)
|
|
|
|
r_save = r;
|
|
|
|
}
|
|
|
|
buf = save_pix_buf(DA,
|
|
|
|
c.x-r_save, c.y-r_save, c.x+r_save, c.y+r_save, 1);
|
2009-08-05 00:45:33 +03:00
|
|
|
draw_arc(DA, gc_drag, FALSE, c.x, c.y, r, a1, a2);
|
2009-08-18 23:52:09 +03:00
|
|
|
if (i == 1) {
|
2009-08-06 23:19:00 +03:00
|
|
|
end = rotate_r(c, r_save, -a2);
|
|
|
|
gdk_draw_line(DA, gc_drag, c.x, c.y, end.x, end.y);
|
|
|
|
}
|
2009-08-05 00:45:33 +03:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-10 16:51:51 +03:00
|
|
|
void do_move_to_arc(struct inst *inst, struct inst *to, int i)
|
2009-08-05 00:45:33 +03:00
|
|
|
{
|
2009-08-10 16:51:51 +03:00
|
|
|
struct vec *vec = inst_get_vec(to);
|
2009-08-05 00:45:33 +03:00
|
|
|
struct obj *obj = inst->obj;
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2009-08-06 07:33:49 +03:00
|
|
|
obj->base = vec;
|
2009-08-05 00:45:33 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
2009-08-18 23:52:09 +03:00
|
|
|
obj->u.arc.start = vec;
|
|
|
|
break;
|
|
|
|
case 1:
|
2009-08-06 07:33:49 +03:00
|
|
|
obj->u.arc.end = vec;
|
2009-08-05 00:45:33 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-04 15:06:04 +03:00
|
|
|
static struct tool_ops circ_ops = {
|
2009-08-04 21:03:06 +03:00
|
|
|
.drag_new = drag_new_circ,
|
|
|
|
.end_new = end_new_circ,
|
2009-08-04 15:06:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-05 17:44:36 +03:00
|
|
|
/* ----- frame helper ------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
2010-04-27 04:02:24 +03:00
|
|
|
int is_parent_of(const struct frame *p, const struct frame *c)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
|
|
|
const struct obj *obj;
|
|
|
|
|
|
|
|
if (p == c)
|
|
|
|
return 1;
|
|
|
|
for (obj = p->objs; obj; obj = obj->next)
|
|
|
|
if (obj->type == ot_frame)
|
|
|
|
if (is_parent_of(obj->u.frame.ref, c))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-25 03:11:45 +03:00
|
|
|
/* ----- frame ------------------------------------------------------------- */
|
2009-08-05 17:44:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
static struct frame *locked_frame = NULL;
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
struct pix_buf *draw_move_frame(struct inst *inst, struct coord pos, int i)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
|
|
|
struct pix_buf *buf;
|
|
|
|
int r = FRAME_EYE_R2;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
pos = translate(pos);
|
2009-08-05 17:44:36 +03:00
|
|
|
buf = save_pix_buf(DA, pos.x-r, pos.y-r, pos.x+r, pos.y+r, 1);
|
|
|
|
draw_arc(DA, gc_drag, FALSE, pos.x, pos.y, r, 0, 360);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
struct pix_buf *gui_hover_frame(struct inst *self)
|
|
|
|
{
|
|
|
|
return hover_common(gc_frame[mode_hover],
|
|
|
|
self->base, FRAME_EYE_R2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int end_new_frame(struct inst *from, struct inst *to)
|
2009-08-05 17:44:36 +03:00
|
|
|
{
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
if (!locked_frame || is_parent_of(locked_frame, active_frame))
|
|
|
|
return 0;
|
|
|
|
obj = new_obj(ot_frame, from);
|
|
|
|
obj->u.frame.ref = locked_frame;
|
|
|
|
obj->u.frame.lineno = 0;
|
2009-08-07 03:48:06 +03:00
|
|
|
if (!locked_frame->active_ref)
|
|
|
|
locked_frame->active_ref = obj;
|
2009-08-05 17:44:36 +03:00
|
|
|
locked_frame = NULL;
|
2009-08-22 15:27:47 +03:00
|
|
|
tool_reset();
|
2009-08-05 17:44:36 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops frame_ops = {
|
2010-04-25 03:11:45 +03:00
|
|
|
.tool_selected = NULL,
|
2009-08-05 17:44:36 +03:00
|
|
|
.drag_new = NULL,
|
|
|
|
.end_new = end_new_frame,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-04 21:03:06 +03:00
|
|
|
/* ----- moving references ------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-10 16:51:51 +03:00
|
|
|
#if 0
|
2009-08-04 21:03:06 +03:00
|
|
|
static int may_move(struct inst *curr)
|
|
|
|
{
|
|
|
|
if (!selected_inst)
|
|
|
|
return 0;
|
|
|
|
if (drag.anchors_n)
|
|
|
|
return 0; /* already moving something else */
|
|
|
|
drag.anchors_n = inst_anchors(selected_inst, drag.anchors);
|
|
|
|
for (drag.anchor_i = 0; drag.anchor_i != drag.anchors_n;
|
|
|
|
drag.anchor_i++)
|
|
|
|
if (*drag.anchors[drag.anchor_i] == inst_get_vec(curr))
|
|
|
|
return 1;
|
|
|
|
drag.anchors_n = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-08-10 16:51:51 +03:00
|
|
|
#endif
|
2009-08-04 21:03:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
static int would_be_equal(const struct drag_state *state,
|
|
|
|
int a, int b, struct inst *curr)
|
|
|
|
{
|
|
|
|
const struct vec *va;
|
|
|
|
const struct vec *vb;
|
|
|
|
|
|
|
|
va = a == state->anchor_i ? inst_get_vec(curr) : *state->anchors[a];
|
|
|
|
vb = b == state->anchor_i ? inst_get_vec(curr) : *state->anchors[b];
|
|
|
|
return va == vb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int may_move_to(const struct drag_state *state, struct inst *curr)
|
|
|
|
{
|
2009-08-05 17:44:36 +03:00
|
|
|
assert(drag.inst);
|
2009-08-04 21:03:06 +03:00
|
|
|
assert(state->anchors_n);
|
|
|
|
switch (state->anchors_n) {
|
|
|
|
case 3:
|
|
|
|
if (would_be_equal(state, 0, 2, curr))
|
|
|
|
return 0;
|
|
|
|
/* fall through */
|
|
|
|
case 2:
|
|
|
|
if (would_be_equal(state, 0, 1, curr))
|
|
|
|
return 0;
|
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void do_move_to(struct drag_state *state, struct inst *curr)
|
|
|
|
{
|
2009-08-10 16:51:51 +03:00
|
|
|
assert(state->inst->ops->find_point || may_move_to(state, curr));
|
2009-08-06 07:33:49 +03:00
|
|
|
*state->anchors[state->anchor_i] = inst_get_vec(curr);
|
2009-08-04 21:03:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- hover ------------------------------------------------------------- */
|
2009-08-04 15:06:04 +03:00
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static struct pix_buf *hover_save_and_draw(void *user)
|
|
|
|
{
|
|
|
|
return inst_hover(hover_inst);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void tool_dehover(void)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2009-08-08 17:11:26 +03:00
|
|
|
if (!hover_inst)
|
|
|
|
return;
|
|
|
|
over_leave();
|
2009-08-04 15:06:04 +03:00
|
|
|
hover_inst = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-10 16:51:51 +03:00
|
|
|
/*
|
|
|
|
* When hovering, we have to consider the following states:
|
|
|
|
*
|
|
|
|
* selected (selected_inst != NULL)
|
|
|
|
* | dragging new (drag.new != NULL)
|
|
|
|
* | | dragging existing (drag.anchors_n != 0)
|
|
|
|
* | | | tool selected (active_ops)
|
|
|
|
* | | | |
|
|
|
|
* Y N N N highlight if inst_find_point_selected else don't
|
|
|
|
* Y N N Y highlight if inst_find_point_selected else fall over to tool
|
|
|
|
* - Y N - highlight if inst_find_point / active_ops->find_point else don't
|
|
|
|
* - N Y - highlight if may_move_to else don't
|
|
|
|
* - Y Y - invalid state
|
|
|
|
* N N N Y highlight if inst_find_point / active_ops->find_point else don't
|
|
|
|
* N N N N don't highlight
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct inst *get_hover_inst(struct coord pos)
|
|
|
|
{
|
|
|
|
struct inst *inst;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (drag.new) {
|
|
|
|
if (active_ops->find_point)
|
|
|
|
return active_ops->find_point(pos);
|
|
|
|
return inst_find_point(pos);
|
|
|
|
}
|
|
|
|
if (drag.anchors_n) {
|
|
|
|
if (drag.inst->ops->find_point)
|
|
|
|
return drag.inst->ops->find_point(drag.inst, pos);
|
|
|
|
inst = inst_find_point(pos);
|
|
|
|
if (!inst)
|
|
|
|
return NULL;
|
|
|
|
return may_move_to(&drag, inst) ? inst : NULL;
|
|
|
|
}
|
|
|
|
if (selected_inst) {
|
|
|
|
i = inst_find_point_selected(pos, &inst);
|
|
|
|
if (i != -1)
|
|
|
|
return inst;
|
|
|
|
}
|
|
|
|
if (!active_ops)
|
|
|
|
return NULL;
|
|
|
|
if (active_ops->find_point)
|
|
|
|
return active_ops->find_point(pos);
|
|
|
|
return inst_find_point(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Dragging a frame into the canvas now works. It's built on top of the frame
tool, with all the old code still around, so the code paths are a bit obscure.
- gui_frame_drag.c: use GTK_DEST_DEFAULT_MOTION instead of
GTK_DEST_DEFAULT_HIGHLIGHT
- gui_frame_drag.c: put meat on the frame and canvas drag and drop skeleton
- gui_frame_drag.c (setup_frame_drag, setup_canvas_drag): use GDK_ACTION_COPY
instead of GDK_ACTION_PRIVATE
- gui_frame_drag.h, gui_frame_drag.c (is_dragging_anything): new helper
function to check if we're dragging anything, without specifying what
- gui_canvas.h, gui_canvas.c: added thin interface layer between gui_frame.c
and gui_tool.c
- gui_canvas.c (enter_notify_event, leave_notify_event): return FALSE so that
other widgets can get the events, too
- gui_tool.h, gui_tool.c (tool_hover): return whether we found anything to
hover on
- gui_tool.h, gui_tool.c: added interface for dropping a frame on the canvas
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5932 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-04-25 00:46:43 +03:00
|
|
|
int tool_hover(struct coord pos)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2010-01-02 14:55:34 +02:00
|
|
|
struct inst *curr;
|
2009-08-04 21:03:06 +03:00
|
|
|
|
2009-08-10 16:51:51 +03:00
|
|
|
curr = get_hover_inst(pos);
|
|
|
|
#if 0
|
2009-08-08 17:11:26 +03:00
|
|
|
if ((drag.new && curr == drag.new) || (drag.inst && curr == drag.inst))
|
|
|
|
return;
|
2009-08-04 21:03:06 +03:00
|
|
|
if (curr && !active_ops) {
|
|
|
|
if (drag.anchors_n) {
|
|
|
|
if (!may_move_to(&drag, curr))
|
|
|
|
curr = NULL;
|
|
|
|
} else {
|
|
|
|
if (!may_move(curr))
|
|
|
|
curr = NULL;
|
|
|
|
drag.anchors_n = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-08-10 16:51:51 +03:00
|
|
|
got:
|
|
|
|
#endif
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
if (curr == hover_inst)
|
Dragging a frame into the canvas now works. It's built on top of the frame
tool, with all the old code still around, so the code paths are a bit obscure.
- gui_frame_drag.c: use GTK_DEST_DEFAULT_MOTION instead of
GTK_DEST_DEFAULT_HIGHLIGHT
- gui_frame_drag.c: put meat on the frame and canvas drag and drop skeleton
- gui_frame_drag.c (setup_frame_drag, setup_canvas_drag): use GDK_ACTION_COPY
instead of GDK_ACTION_PRIVATE
- gui_frame_drag.h, gui_frame_drag.c (is_dragging_anything): new helper
function to check if we're dragging anything, without specifying what
- gui_canvas.h, gui_canvas.c: added thin interface layer between gui_frame.c
and gui_tool.c
- gui_canvas.c (enter_notify_event, leave_notify_event): return FALSE so that
other widgets can get the events, too
- gui_tool.h, gui_tool.c (tool_hover): return whether we found anything to
hover on
- gui_tool.h, gui_tool.c: added interface for dropping a frame on the canvas
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5932 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-04-25 00:46:43 +03:00
|
|
|
return !!curr;
|
2009-08-08 17:11:26 +03:00
|
|
|
if (hover_inst) {
|
|
|
|
over_leave();
|
|
|
|
hover_inst = NULL;
|
2009-08-04 15:06:04 +03:00
|
|
|
}
|
2009-08-08 17:11:26 +03:00
|
|
|
if (!curr)
|
Dragging a frame into the canvas now works. It's built on top of the frame
tool, with all the old code still around, so the code paths are a bit obscure.
- gui_frame_drag.c: use GTK_DEST_DEFAULT_MOTION instead of
GTK_DEST_DEFAULT_HIGHLIGHT
- gui_frame_drag.c: put meat on the frame and canvas drag and drop skeleton
- gui_frame_drag.c (setup_frame_drag, setup_canvas_drag): use GDK_ACTION_COPY
instead of GDK_ACTION_PRIVATE
- gui_frame_drag.h, gui_frame_drag.c (is_dragging_anything): new helper
function to check if we're dragging anything, without specifying what
- gui_canvas.h, gui_canvas.c: added thin interface layer between gui_frame.c
and gui_tool.c
- gui_canvas.c (enter_notify_event, leave_notify_event): return FALSE so that
other widgets can get the events, too
- gui_tool.h, gui_tool.c (tool_hover): return whether we found anything to
hover on
- gui_tool.h, gui_tool.c: added interface for dropping a frame on the canvas
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5932 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-04-25 00:46:43 +03:00
|
|
|
return 0;
|
2009-08-08 17:11:26 +03:00
|
|
|
hover_inst = curr;
|
|
|
|
over_enter(hover_save_and_draw, NULL);
|
Dragging a frame into the canvas now works. It's built on top of the frame
tool, with all the old code still around, so the code paths are a bit obscure.
- gui_frame_drag.c: use GTK_DEST_DEFAULT_MOTION instead of
GTK_DEST_DEFAULT_HIGHLIGHT
- gui_frame_drag.c: put meat on the frame and canvas drag and drop skeleton
- gui_frame_drag.c (setup_frame_drag, setup_canvas_drag): use GDK_ACTION_COPY
instead of GDK_ACTION_PRIVATE
- gui_frame_drag.h, gui_frame_drag.c (is_dragging_anything): new helper
function to check if we're dragging anything, without specifying what
- gui_canvas.h, gui_canvas.c: added thin interface layer between gui_frame.c
and gui_tool.c
- gui_canvas.c (enter_notify_event, leave_notify_event): return FALSE so that
other widgets can get the events, too
- gui_tool.h, gui_tool.c (tool_hover): return whether we found anything to
hover on
- gui_tool.h, gui_tool.c: added interface for dropping a frame on the canvas
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5932 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-04-25 00:46:43 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- frame drag and drop ----------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When dragging a frame, we temporarily replace the selected tool (if any)
|
|
|
|
* with the frame tool.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static struct tool_ops *pushed_ops;
|
|
|
|
|
|
|
|
|
|
|
|
void tool_push_frame(struct frame *frame)
|
|
|
|
{
|
|
|
|
pushed_ops = active_ops;
|
|
|
|
locked_frame = frame;
|
|
|
|
active_ops = &frame_ops;
|
|
|
|
/*
|
|
|
|
* We don't need to call tool_selected since, with drag and drop, the
|
|
|
|
* frame tools doesn't need activation anymore.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int do_place_frame(struct frame *frame, struct coord pos)
|
|
|
|
{
|
|
|
|
if (!get_hover_inst(pos))
|
|
|
|
return 0;
|
|
|
|
tool_consider_drag(pos);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gtk calls drag-leave, drag-end, and only then drag-drop. So we'll already
|
|
|
|
* have cleaned up in tool_pop_frame before we get here. In order to place the
|
|
|
|
* frame, we need to activate the frame tool again.
|
|
|
|
*
|
|
|
|
* @@@ bug: there's a tool_reset in this path, so we'll lose the widget of the
|
|
|
|
* tool that's really active. This problem will vanish when scrapping the
|
|
|
|
* old-style frame referenes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int tool_place_frame(struct frame *frame, struct coord pos)
|
|
|
|
{
|
|
|
|
int ok;
|
|
|
|
|
|
|
|
active_ops = &frame_ops;
|
|
|
|
ok = do_place_frame(frame, pos);
|
|
|
|
active_ops = pushed_ops;
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void tool_pop_frame(void)
|
|
|
|
{
|
|
|
|
if (!active_tool)
|
|
|
|
return;
|
|
|
|
active_ops = pushed_ops;
|
|
|
|
/*
|
|
|
|
* We don't need to call tool_selected since the only tool that could
|
|
|
|
* use this would be the delete tool, and there the semantics would be
|
|
|
|
* undesirable. Also, the delete tool never stays active, so it can't
|
|
|
|
* appear together with drag and drop anyway.
|
|
|
|
*/
|
2009-08-04 15:06:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-02 14:55:34 +02:00
|
|
|
/* ----- tooltip ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
const char *tool_tip(struct coord pos)
|
|
|
|
{
|
|
|
|
struct inst *inst;
|
|
|
|
|
|
|
|
inst = get_hover_inst(pos);
|
|
|
|
if (!inst)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The logic below follows exactly what happens in get_hover_inst.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (drag.new)
|
|
|
|
return "End here";
|
|
|
|
if (drag.anchors_n)
|
|
|
|
return "Move here";
|
|
|
|
if (selected_inst)
|
|
|
|
return "Move this point";
|
|
|
|
return "Start here";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-04 21:03:06 +03:00
|
|
|
/* ----- mouse actions ----------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
static struct pix_buf *drag_save_and_draw(void *user, struct coord to)
|
|
|
|
{
|
|
|
|
if (drag.new) {
|
|
|
|
assert(active_ops);
|
|
|
|
return active_ops->drag_new(drag.new, to);
|
|
|
|
} else {
|
|
|
|
return inst_draw_move(drag.inst, to, drag.anchor_i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-10 16:51:51 +03:00
|
|
|
/*
|
|
|
|
* When considering dragging, we have the following states:
|
|
|
|
*
|
|
|
|
* selected (selected_inst != NULL)
|
|
|
|
* | tool selected (active_ops)
|
|
|
|
* | |
|
|
|
|
* N N don't
|
|
|
|
* Y - if we could drag, drag_new/end_new, else fall over to tool
|
2009-08-11 23:52:33 +03:00
|
|
|
* N Y else single-click creation, else drag_new/end_new
|
2009-08-10 16:51:51 +03:00
|
|
|
*/
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
int tool_consider_drag(struct coord pos)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2009-08-04 21:03:06 +03:00
|
|
|
struct inst *curr;
|
|
|
|
|
|
|
|
assert(!drag.new);
|
|
|
|
assert(!drag.anchors_n);
|
2009-08-08 17:11:26 +03:00
|
|
|
last_canvas_pos = translate(pos);
|
2009-08-10 16:51:51 +03:00
|
|
|
|
|
|
|
if (!selected_inst && !active_ops)
|
|
|
|
return 0;
|
|
|
|
if (selected_inst) {
|
|
|
|
drag.anchor_i = inst_find_point_selected(pos, NULL);
|
|
|
|
if (drag.anchor_i != -1) {
|
|
|
|
tool_dehover();
|
|
|
|
drag.inst = selected_inst;
|
|
|
|
drag.new = NULL;
|
|
|
|
drag.anchors_n =
|
|
|
|
inst_anchors(selected_inst, drag.anchors);
|
|
|
|
over_begin(drag_save_and_draw, NULL, pos);
|
|
|
|
inst_begin_drag_move(selected_inst, drag.anchor_i);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!active_ops)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
curr = get_hover_inst(pos);
|
2009-08-04 21:03:06 +03:00
|
|
|
if (!curr)
|
2009-08-04 15:06:04 +03:00
|
|
|
return 0;
|
2009-08-10 16:51:51 +03:00
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
tool_dehover();
|
2009-08-10 16:51:51 +03:00
|
|
|
|
|
|
|
if (active_ops->drag_new) {
|
|
|
|
if (active_ops->begin_drag_new)
|
|
|
|
active_ops->begin_drag_new(curr);
|
|
|
|
drag.inst = NULL;
|
|
|
|
drag.new = curr;
|
|
|
|
over_begin(drag_save_and_draw, NULL, pos);
|
|
|
|
return 1;
|
2009-08-04 21:03:06 +03:00
|
|
|
}
|
2009-08-10 16:51:51 +03:00
|
|
|
|
|
|
|
/* object is created without dragging */
|
2009-08-10 18:13:07 +03:00
|
|
|
if (active_ops->end_new(curr, NULL))
|
2009-08-10 16:51:51 +03:00
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
|
2009-08-04 15:06:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
void tool_drag(struct coord to)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2009-08-08 17:11:26 +03:00
|
|
|
last_canvas_pos = translate(to);
|
|
|
|
over_move(to);
|
2009-08-04 15:06:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
void tool_cancel_drag(void)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2009-08-10 16:51:51 +03:00
|
|
|
if (drag.anchors_n && drag.inst->ops->end_drag_move)
|
|
|
|
drag.inst->ops->end_drag_move();
|
2009-08-04 21:03:06 +03:00
|
|
|
drag.new = NULL;
|
2009-08-04 15:06:04 +03:00
|
|
|
active_ops = NULL;
|
2009-08-04 21:03:06 +03:00
|
|
|
drag.anchors_n = 0;
|
2009-08-10 16:51:51 +03:00
|
|
|
over_end();
|
|
|
|
tool_dehover();
|
|
|
|
tool_reset();
|
2009-08-04 15:06:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
int tool_end_drag(struct coord to)
|
2009-08-04 15:06:04 +03:00
|
|
|
{
|
2009-08-04 21:03:06 +03:00
|
|
|
struct drag_state state = drag;
|
2009-08-04 15:06:04 +03:00
|
|
|
struct inst *end;
|
|
|
|
struct tool_ops *ops = active_ops;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
tool_cancel_drag();
|
2009-08-05 17:44:36 +03:00
|
|
|
if (state.new && ops->end_new_raw)
|
2009-08-08 17:11:26 +03:00
|
|
|
return ops->end_new_raw(state.new, to);
|
2009-08-10 16:51:51 +03:00
|
|
|
if (state.new && ops->find_point)
|
2009-08-08 21:50:17 +03:00
|
|
|
end = ops->find_point(to);
|
2009-08-10 16:51:51 +03:00
|
|
|
else {
|
|
|
|
if (state.inst && state.inst->ops->find_point)
|
|
|
|
end = state.inst->ops->find_point(state.inst, to);
|
|
|
|
else
|
|
|
|
end = inst_find_point(to);
|
|
|
|
}
|
|
|
|
if (!end) {
|
|
|
|
if (state.new && ops->cancel_drag_new)
|
|
|
|
ops->cancel_drag_new();
|
2009-08-04 21:03:06 +03:00
|
|
|
return 0;
|
2009-08-10 16:51:51 +03:00
|
|
|
}
|
2009-08-04 21:03:06 +03:00
|
|
|
if (state.new)
|
2009-08-08 17:11:26 +03:00
|
|
|
return ops->end_new(state.new, end);
|
2009-08-10 16:51:51 +03:00
|
|
|
|
|
|
|
/* if we got the point from find_point, it's authoritative */
|
|
|
|
if (!state.inst->ops->find_point && !may_move_to(&state, end))
|
2009-08-04 21:03:06 +03:00
|
|
|
return 0;
|
2009-08-10 16:51:51 +03:00
|
|
|
if (!inst_do_move_to(state.inst, end, state.anchor_i))
|
2009-08-05 00:45:33 +03:00
|
|
|
do_move_to(&state, end);
|
2009-08-04 21:03:06 +03:00
|
|
|
return 1;
|
2009-08-04 15:06:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
void tool_redraw(void)
|
2009-08-07 19:19:23 +03:00
|
|
|
{
|
2009-08-10 16:51:51 +03:00
|
|
|
struct coord pos;
|
|
|
|
|
2009-08-08 17:11:26 +03:00
|
|
|
over_reset();
|
2009-08-10 16:51:51 +03:00
|
|
|
hover_inst = NULL;
|
2009-08-07 19:19:23 +03:00
|
|
|
if (!drag.new && !drag.anchors_n)
|
|
|
|
return;
|
2009-08-10 16:51:51 +03:00
|
|
|
pos = canvas_to_coord(last_canvas_pos.x, last_canvas_pos.y);
|
|
|
|
tool_hover(pos);
|
|
|
|
over_begin(drag_save_and_draw, NULL, pos);
|
2009-08-07 19:19:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-15 23:24:30 +02:00
|
|
|
/* ----- Retrieve icons by instance characteristics ------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *get_icon_by_inst(const struct inst *inst)
|
|
|
|
{
|
|
|
|
char **image;
|
|
|
|
|
|
|
|
switch (inst->prio) {
|
|
|
|
case ip_frame:
|
|
|
|
image = xpm_frame;
|
|
|
|
break;
|
|
|
|
case ip_pad_copper:
|
|
|
|
case ip_pad_special:
|
|
|
|
image = inst->obj->u.pad.rounded ? xpm_rpad : xpm_pad;
|
|
|
|
break;
|
2010-04-25 13:58:07 +03:00
|
|
|
case ip_hole:
|
|
|
|
image = xpm_hole;
|
|
|
|
break;
|
2009-12-15 23:24:30 +02:00
|
|
|
case ip_circ:
|
|
|
|
image = xpm_circ;
|
|
|
|
break;
|
|
|
|
case ip_arc:
|
|
|
|
image = xpm_arc;
|
|
|
|
break;
|
|
|
|
case ip_rect:
|
|
|
|
image = xpm_rect;
|
|
|
|
break;
|
|
|
|
case ip_meas:
|
|
|
|
switch (inst->obj->u.meas.type) {
|
|
|
|
case mt_xy_next:
|
|
|
|
case mt_xy_max:
|
|
|
|
image = xpm_meas;
|
|
|
|
break;
|
|
|
|
case mt_x_next:
|
|
|
|
case mt_x_max:
|
|
|
|
image = xpm_meas_x;
|
|
|
|
break;
|
|
|
|
case mt_y_next:
|
|
|
|
case mt_y_max:
|
|
|
|
image = xpm_meas_y;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ip_line:
|
|
|
|
image = xpm_line;
|
|
|
|
break;
|
|
|
|
case ip_vec:
|
|
|
|
image = xpm_vec;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2010-01-01 16:59:17 +02:00
|
|
|
return make_transparent_image(DA, image, NULL);
|
2009-12-15 23:24:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-04 15:06:04 +03:00
|
|
|
/* ----- tool bar creation ------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static void tool_select(GtkWidget *evbox, struct tool_ops *ops)
|
|
|
|
{
|
|
|
|
GdkColor col;
|
|
|
|
|
|
|
|
if (active_tool) {
|
2009-08-08 00:47:51 +03:00
|
|
|
if (active_ops && active_ops->tool_deselected)
|
|
|
|
active_ops->tool_deselected();
|
2009-08-13 12:30:16 +03:00
|
|
|
col = get_color(COLOR_TOOL_UNSELECTED);
|
2009-08-04 15:06:04 +03:00
|
|
|
gtk_widget_modify_bg(active_tool, GTK_STATE_NORMAL, &col);
|
|
|
|
active_tool = NULL;
|
|
|
|
}
|
2009-08-13 12:30:16 +03:00
|
|
|
col = get_color(COLOR_TOOL_SELECTED);
|
2009-08-04 15:06:04 +03:00
|
|
|
gtk_widget_modify_bg(evbox, GTK_STATE_NORMAL, &col);
|
|
|
|
active_tool = evbox;
|
|
|
|
active_ops = ops;
|
2009-08-05 17:44:36 +03:00
|
|
|
if (ops && ops->tool_selected)
|
|
|
|
ops->tool_selected();
|
2009-08-04 15:06:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void tool_reset(void)
|
|
|
|
{
|
2009-08-08 17:11:26 +03:00
|
|
|
over_reset();
|
2009-08-10 16:51:51 +03:00
|
|
|
hover_inst = NULL;
|
2009-08-04 15:06:04 +03:00
|
|
|
tool_select(ev_point, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean tool_button_press_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
2009-08-09 00:59:33 +03:00
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
|
|
|
tool_select(widget, data);
|
|
|
|
break;
|
2009-08-05 17:44:36 +03:00
|
|
|
}
|
2009-08-09 00:59:33 +03:00
|
|
|
return TRUE;
|
2009-08-03 19:12:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-07 22:42:57 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-04 10:24:13 +03:00
|
|
|
GtkWidget *gui_setup_tools(GdkDrawable *drawable)
|
2009-08-03 19:12:47 +03:00
|
|
|
{
|
|
|
|
GtkWidget *bar;
|
|
|
|
|
|
|
|
bar = gtk_toolbar_new();
|
|
|
|
gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_ICONS);
|
|
|
|
gtk_toolbar_set_orientation(GTK_TOOLBAR(bar),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
2009-08-04 15:06:04 +03:00
|
|
|
|
2009-08-09 00:59:33 +03:00
|
|
|
ev_point = tool_button(bar, drawable, xpm_point,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Select and move items",
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button_press_event, NULL);
|
2010-01-01 16:59:17 +02:00
|
|
|
ev_delete = tool_button(bar, drawable, NULL, NULL,
|
2009-08-11 23:52:33 +03:00
|
|
|
tool_button_press_event, &delete_ops);
|
2009-08-07 22:42:57 +03:00
|
|
|
tool_separator(bar);
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button(bar, drawable, xpm_vec,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a vector",
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button_press_event, &vec_ops);
|
|
|
|
tool_button(bar, drawable, xpm_pad,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a rectangular pad",
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button_press_event, &pad_ops);
|
2009-08-14 13:18:40 +03:00
|
|
|
tool_button(bar, drawable, xpm_rpad,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a rounded pad",
|
2009-08-14 13:18:40 +03:00
|
|
|
tool_button_press_event, &rpad_ops);
|
2010-04-25 13:58:07 +03:00
|
|
|
tool_button(bar, drawable, xpm_hole,
|
|
|
|
"Add a hole",
|
|
|
|
tool_button_press_event, &hole_ops);
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button(bar, drawable, xpm_line,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a silk screen line",
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button_press_event, &line_ops);
|
|
|
|
tool_button(bar, drawable, xpm_rect,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a silk screen rectangle",
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button_press_event, &rect_ops);
|
|
|
|
tool_button(bar, drawable, xpm_circ,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a silk screen circle or arc",
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button_press_event, &circ_ops);
|
2009-08-08 00:47:51 +03:00
|
|
|
tool_separator(bar);
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button(bar, drawable, xpm_meas,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a measurement",
|
2009-08-09 04:51:20 +03:00
|
|
|
tool_button_press_event, &tool_meas_ops);
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button(bar, drawable, xpm_meas_x,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a horizontal measurement",
|
2009-08-09 04:51:20 +03:00
|
|
|
tool_button_press_event, &tool_meas_ops_x);
|
2009-08-09 00:59:33 +03:00
|
|
|
tool_button(bar, drawable, xpm_meas_y,
|
2010-01-01 16:59:17 +02:00
|
|
|
"Add a vertical measurement",
|
2009-08-09 04:51:20 +03:00
|
|
|
tool_button_press_event, &tool_meas_ops_y);
|
2009-08-04 15:06:04 +03:00
|
|
|
|
2010-01-01 16:59:17 +02:00
|
|
|
delete_image[0] = gtk_widget_ref(make_image(drawable, xpm_delete_off,
|
|
|
|
NULL));
|
|
|
|
delete_image[1] = gtk_widget_ref(make_image(drawable, xpm_delete,
|
|
|
|
"Delete the selected item"));
|
2009-08-11 23:52:33 +03:00
|
|
|
set_image(ev_delete, delete_image[0]);
|
|
|
|
|
2009-08-04 15:06:04 +03:00
|
|
|
tool_reset();
|
2009-08-03 19:12:47 +03:00
|
|
|
|
|
|
|
return bar;
|
|
|
|
}
|
2009-08-21 21:20:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
void gui_cleanup_tools(void)
|
|
|
|
{
|
|
|
|
g_object_unref(delete_image[0]);
|
|
|
|
g_object_unref(delete_image[1]);
|
|
|
|
}
|