1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-04 23:37:33 +02:00

- don't crash when editing a NULL expression (e.g., default width)

- bounding boxes of silk objects now include the width
- # zooms and centers to currently active frame instance



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5378 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-03 21:52:21 +00:00
parent 6c2734f6ac
commit 3c026696d4
5 changed files with 36 additions and 9 deletions

1
README
View File

@ -349,3 +349,4 @@ space reset user coordinates
- zoom out (like mouse wheel backward)
. cursor position to screen center (like middle click)
* zoom and center to extents
# zoom and center to currently active frame instance

View File

@ -49,24 +49,24 @@ static void update_pos(struct coord pos)
/* ----- coordinate system ------------------------------------------------- */
static void center(void)
static void center(const struct bbox *this_bbox)
{
struct bbox bbox;
bbox = inst_get_bbox();
bbox = this_bbox ? *this_bbox : inst_get_bbox();
ctx.center.x = (bbox.min.x+bbox.max.x)/2;
ctx.center.y = (bbox.min.y+bbox.max.y)/2;
}
static void auto_scale(void)
static void auto_scale(const struct bbox *this_bbox)
{
struct bbox bbox;
unit_type h, w;
int sx, sy;
float aw, ah;
bbox = inst_get_bbox();
bbox = this_bbox ? *this_bbox : inst_get_bbox();
aw = ctx.widget->allocation.width;
ah = ctx.widget->allocation.height;
h = bbox.max.x-bbox.min.x;
@ -236,9 +236,15 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
zoom_out(pos);
break;
case '*':
center();
auto_scale();
center(NULL);
auto_scale(NULL);
redraw();
break;
case '#':
center(&active_frame_bbox);
auto_scale(&active_frame_bbox);
redraw();
break;
case '.':
ctx.center = pos;
redraw();
@ -293,8 +299,8 @@ static gboolean leave_notify_event(GtkWidget *widget, GdkEventCrossing *event,
void init_canvas(void)
{
center();
auto_scale();
center(NULL);
auto_scale(NULL);
}

View File

@ -310,7 +310,8 @@ static int expr_activate(GtkWidget *widget, const char *s, void *ctx)
expr = try_parse_expr(s);
if (!expr)
return 0;
free_expr(*anchor);
if (*anchor)
free_expr(*anchor);
*anchor = expr;
entry_color(COLOR_EDIT_ASIS);
return 1;

18
inst.c
View File

@ -62,6 +62,7 @@ enum inst_prio {
struct inst *selected_inst = NULL;
struct bbox active_frame_bbox;
static struct inst *curr_frame = NULL;
static struct inst *insts[ip_n], **next_inst[ip_n];
@ -224,6 +225,16 @@ static void propagate_bbox(const struct inst *inst)
update_bbox(&curr_frame->bbox, inst->bbox.max);
}
static void grow_bbox_by_width(struct bbox *bbox, unit_type width)
{
bbox->min.x -= width/2;
bbox->min.y -= width/2;
bbox->max.x += width/2;
bbox->max.y += width/2;
}
static struct inst *add_inst(const struct inst_ops *ops, enum inst_prio prio,
struct coord base)
{
@ -331,6 +342,7 @@ int inst_line(struct obj *obj, struct coord a, struct coord b, unit_type width)
inst->u.rect.end = b;
inst->u.rect.width = width;
update_bbox(&inst->bbox, b);
grow_bbox_by_width(&inst->bbox, width);
propagate_bbox(inst);
return 1;
}
@ -371,6 +383,7 @@ int inst_rect(struct obj *obj, struct coord a, struct coord b, unit_type width)
inst->u.rect.end = b;
inst->u.rect.width = width;
update_bbox(&inst->bbox, b);
grow_bbox_by_width(&inst->bbox, width);
propagate_bbox(inst);
return 1;
}
@ -482,6 +495,7 @@ int inst_arc(struct obj *obj, struct coord center, struct coord start,
inst->bbox.max.x = center.x+r;
inst->bbox.min.y = center.y-r;
inst->bbox.max.y = center.y+r;
grow_bbox_by_width(&inst->bbox, width);
propagate_bbox(inst);
return 1;
}
@ -581,6 +595,8 @@ void inst_end_frame(const struct frame *frame)
curr_frame = curr_frame->outer;
if (curr_frame)
propagate_bbox(inst);
if (inst->active && frame == active_frame)
active_frame_bbox = inst->bbox;
}
@ -609,8 +625,10 @@ static void inst_free(struct inst *list[ip_n])
void inst_start(void)
{
static struct bbox bbox_zero = { { 0, 0 }, { 0, 0 }};
enum inst_prio prio;
active_frame_bbox = bbox_zero;
FOR_INST_PRIOS_UP(prio) {
prev_insts[prio] = insts[prio];
insts[prio] = NULL;

1
inst.h
View File

@ -71,6 +71,7 @@ struct inst {
extern struct inst *selected_inst;
extern struct bbox active_frame_bbox;
void inst_select_outside(void *item, void (*deselect)(void *item));