mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-22 12:00:36 +02:00
- zoom out now doesn't stop before there is a significant border around the
drawing - zoom to frame was broken because it didn't track the recent change in location of active flag - we can now pan and zoom while dragging - gui_canvas.c:button_release_event didn't consider the button, making centering also end dragging git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5401 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
d046f9306c
commit
55916cc75b
1
TODO
1
TODO
@ -24,7 +24,6 @@ Style:
|
||||
Bugs:
|
||||
- default silk width has no business being hard-coded in obj.c
|
||||
- undelete only works if not much has changed since the deletion
|
||||
- re-center while dragging confuses the save-under mechanism
|
||||
|
||||
Code cleanup:
|
||||
- merge edit_unique with edit_name
|
||||
|
14
gui_canvas.c
14
gui_canvas.c
@ -104,6 +104,7 @@ void redraw(void)
|
||||
gdk_draw_rectangle(ctx.widget->window, gc_bg, TRUE, 0, 0, aw, ah);
|
||||
|
||||
inst_draw(&ctx);
|
||||
tool_redraw(&ctx);
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +199,10 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
|
||||
{
|
||||
struct coord pos = canvas_to_coord(&ctx, event->x, event->y);
|
||||
|
||||
if (dragging) {
|
||||
switch (event->button) {
|
||||
case 1:
|
||||
if (!dragging)
|
||||
break;
|
||||
dragging = 0;
|
||||
if (hypot(pos.x-drag_start.x, pos.y-drag_start.y)/ctx.scale <
|
||||
DRAG_MIN_R)
|
||||
@ -207,6 +211,7 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
|
||||
if (tool_end_drag(&ctx, pos))
|
||||
change_world();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -234,9 +239,10 @@ static void zoom_out(struct coord pos)
|
||||
bbox = inst_get_bbox();
|
||||
bbox.min = translate(&ctx, bbox.min);
|
||||
bbox.max = translate(&ctx, bbox.max);
|
||||
if (bbox.min.x >= 0 && bbox.max.y >= 0 &&
|
||||
bbox.max.x < ctx.widget->allocation.width &&
|
||||
bbox.min.y < ctx.widget->allocation.height)
|
||||
if (bbox.min.x >= ZOOM_STOP_BORDER &&
|
||||
bbox.max.y >= ZOOM_STOP_BORDER &&
|
||||
bbox.max.x < ctx.widget->allocation.width-ZOOM_STOP_BORDER &&
|
||||
bbox.min.y < ctx.widget->allocation.height-ZOOM_STOP_BORDER)
|
||||
return;
|
||||
ctx.scale *= 2;
|
||||
ctx.center.x = 2*ctx.center.x-pos.x;
|
||||
|
@ -24,6 +24,9 @@
|
||||
|
||||
#define CANVAS_CLEARANCE 10
|
||||
|
||||
#define ZOOM_STOP_BORDER 50 /* stop zoom if we have at least a 50
|
||||
pixel border */
|
||||
|
||||
#define VEC_ARROW_LEN 10
|
||||
#define VEC_ARROW_ANGLE 20
|
||||
#define VEC_EYE_R 5
|
||||
|
20
gui_tools.c
20
gui_tools.c
@ -59,7 +59,6 @@ static struct tool_ops *active_ops = NULL;
|
||||
static struct inst *hover_inst = NULL;
|
||||
static GtkWidget *frame_image, *frame_image_locked, *frame_image_ready;
|
||||
|
||||
|
||||
static struct drag_state {
|
||||
struct inst *inst; /* non-NULL if dragging an existing object */
|
||||
struct inst *new; /* non-NULL if dragging a new object */
|
||||
@ -72,6 +71,7 @@ static struct drag_state {
|
||||
};
|
||||
|
||||
static struct pix_buf *pix_buf;
|
||||
static struct coord last_canvas_pos;
|
||||
|
||||
|
||||
static struct vec *new_vec(struct inst *base)
|
||||
@ -706,6 +706,7 @@ int tool_consider_drag(struct draw_ctx *ctx, struct coord pos)
|
||||
|
||||
assert(!drag.new);
|
||||
assert(!drag.anchors_n);
|
||||
last_canvas_pos = translate(ctx, pos);
|
||||
curr = inst_find_point(ctx, pos);
|
||||
if (!curr)
|
||||
return 0;
|
||||
@ -736,6 +737,7 @@ void tool_drag(struct draw_ctx *ctx, struct coord to)
|
||||
{
|
||||
if (pix_buf)
|
||||
restore_pix_buf(pix_buf);
|
||||
last_canvas_pos = translate(ctx, to);
|
||||
tool_hover(ctx, to);
|
||||
pix_buf = drag.new ? active_ops->drag_new(ctx, drag.new, to) :
|
||||
inst_draw_move(drag.inst, ctx, to, drag.anchor_i);
|
||||
@ -746,8 +748,10 @@ void tool_cancel_drag(struct draw_ctx *ctx)
|
||||
{
|
||||
tool_dehover(ctx);
|
||||
tool_reset();
|
||||
if (pix_buf)
|
||||
if (pix_buf) {
|
||||
restore_pix_buf(pix_buf);
|
||||
pix_buf = NULL;
|
||||
}
|
||||
drag.new = NULL;
|
||||
active_ops = NULL;
|
||||
drag.anchors_n = 0;
|
||||
@ -776,6 +780,18 @@ int tool_end_drag(struct draw_ctx *ctx, struct coord to)
|
||||
}
|
||||
|
||||
|
||||
void tool_redraw(struct draw_ctx *ctx)
|
||||
{
|
||||
if (!drag.new && !drag.anchors_n)
|
||||
return;
|
||||
if (pix_buf)
|
||||
free_pix_buf(pix_buf);
|
||||
pix_buf = NULL;
|
||||
tool_drag(ctx, canvas_to_coord(ctx,
|
||||
last_canvas_pos.x, last_canvas_pos.y));
|
||||
}
|
||||
|
||||
|
||||
/* ----- tool bar creation ------------------------------------------------- */
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@ int tool_consider_drag(struct draw_ctx *ctx, struct coord pos);
|
||||
void tool_drag(struct draw_ctx *ctx, struct coord to);
|
||||
void tool_cancel_drag(struct draw_ctx *ctx);
|
||||
int tool_end_drag(struct draw_ctx *ctx, struct coord to);
|
||||
void tool_redraw(struct draw_ctx *ctx);
|
||||
|
||||
/*
|
||||
* Cache the frame and track it.
|
||||
|
10
gui_util.c
10
gui_util.c
@ -51,6 +51,13 @@ void set_width(GdkGC *gc, int width)
|
||||
/* ----- backing store ----------------------------------------------------- */
|
||||
|
||||
|
||||
void free_pix_buf(struct pix_buf *buf)
|
||||
{
|
||||
g_object_unref(G_OBJECT(buf->buf));
|
||||
free(buf);
|
||||
}
|
||||
|
||||
|
||||
struct pix_buf *save_pix_buf(GdkDrawable *da, int xa, int ya, int xb, int yb,
|
||||
int border)
|
||||
{
|
||||
@ -92,8 +99,7 @@ void restore_pix_buf(struct pix_buf *buf)
|
||||
{
|
||||
gdk_draw_pixbuf(buf->da, NULL, buf->buf, 0, 0, buf->x, buf->y, -1, -1,
|
||||
GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||
g_object_unref(G_OBJECT(buf->buf));
|
||||
free(buf);
|
||||
free_pix_buf(buf);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@ GdkColor get_color(const char *spec);
|
||||
|
||||
void set_width(GdkGC *gc, int width);
|
||||
|
||||
void free_pix_buf(struct pix_buf *buf);
|
||||
struct pix_buf *save_pix_buf(GdkDrawable *da, int xa, int ya, int xb, int yb,
|
||||
int border);
|
||||
void restore_pix_buf(struct pix_buf *buf);
|
||||
|
Loading…
Reference in New Issue
Block a user