mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-05 14:22:29 +02:00
A bit of cleanup.
- gui_frame_drag.c (FOR_UNORDERED, drag_var_motion, drag_value_motion, drag_frame_motion): moved hard to read loop into helper macro - capitalized SWAP, to make it clear it's a macro and can multiply side-effects - TODO: updated discussion of open issues git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5971 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
d4c4031b9a
commit
b2b3a46119
6
TODO
6
TODO
@ -53,11 +53,13 @@ Open decisions:
|
||||
A1: no: would cause confusion in GUI (vectors could become orphaned)
|
||||
A2: yes. but we don't change the linkage.
|
||||
- Q: how do we handle stacks of objects ?
|
||||
A: we don't but we make it easy to avoid them, by giving a good zoom,
|
||||
A1: we don't but we make it easy to avoid them, by giving a good zoom,
|
||||
flexible selection, and by disallowing stacks of identical objects in the
|
||||
first place.
|
||||
A2: the current mechanism of selecting the next eligible object when clicking
|
||||
on the same position repeatedly lets one cycle through stacks.
|
||||
- Q: add frame arguments ? (e.g., .frame pad(pin_num_offset) ...)
|
||||
we can already approximate this by introducing an intermediate table that
|
||||
A: we can already approximate this by introducing an intermediate table that
|
||||
sets up the arguments (provided that we don't consider vectors as well)
|
||||
- Q: should we make it a requirement to generate objects only once ?
|
||||
A: yes.
|
||||
|
4
coord.c
4
coord.c
@ -157,9 +157,9 @@ double theta(struct coord c, struct coord p)
|
||||
void sort_coord(struct coord *min, struct coord *max)
|
||||
{
|
||||
if (min->x > max->x)
|
||||
swap(min->x, max->x);
|
||||
SWAP(min->x, max->x);
|
||||
if (min->y > max->y)
|
||||
swap(min->y, max->y);
|
||||
SWAP(min->y, max->y);
|
||||
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,10 @@ int is_dragging_anything(void)
|
||||
NTH_walk = &(*NTH_walk)->next; \
|
||||
NTH_walk; })
|
||||
|
||||
#define FOR_UNORDERED(var, a, b) \
|
||||
for (var = (a) < (b) ? (a) : (b); var != ((a) < (b) ? (b) : (a)); \
|
||||
var++)
|
||||
|
||||
|
||||
/* ----- generic helper functions. maybe move to gui_util later ------------ */
|
||||
|
||||
@ -203,8 +207,8 @@ static void swap_vars(struct table *table, int a, int b)
|
||||
swap_table_cells(box_of_label((*var_a)->widget),
|
||||
box_of_label((*var_b)->widget));
|
||||
|
||||
swap(*var_a, *var_b);
|
||||
swap((*var_a)->next, (*var_b)->next);
|
||||
SWAP(*var_a, *var_b);
|
||||
SWAP((*var_a)->next, (*var_b)->next);
|
||||
}
|
||||
|
||||
|
||||
@ -218,12 +222,11 @@ static void swap_values(struct row *row, int a, int b)
|
||||
swap_table_cells(box_of_label((*value_a)->widget),
|
||||
box_of_label((*value_b)->widget));
|
||||
|
||||
swap(*value_a, *value_b);
|
||||
swap((*value_a)->next, (*value_b)->next);
|
||||
SWAP(*value_a, *value_b);
|
||||
SWAP((*value_a)->next, (*value_b)->next);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void swap_cols(struct table *table, int a, int b)
|
||||
{
|
||||
struct row *row;
|
||||
@ -246,8 +249,8 @@ static void swap_rows(struct row **a, struct row **b)
|
||||
value_a = value_a->next;
|
||||
value_b = value_b->next;
|
||||
}
|
||||
swap(*a, *b);
|
||||
swap((*a)->next, (*b)->next);
|
||||
SWAP(*a, *b);
|
||||
SWAP((*a)->next, (*b)->next);
|
||||
}
|
||||
|
||||
|
||||
@ -262,8 +265,8 @@ static void swap_frames(GtkWidget *table, int a, int b)
|
||||
swap_table_rows(table, 2*a+1, 2*b+1);
|
||||
swap_table_rows(table, 2*a+2, 2*b+2);
|
||||
|
||||
swap(*frame_a, *frame_b);
|
||||
swap((*frame_a)->next, (*frame_b)->next);
|
||||
SWAP(*frame_a, *frame_b);
|
||||
SWAP((*frame_a)->next, (*frame_b)->next);
|
||||
}
|
||||
|
||||
|
||||
@ -341,8 +344,7 @@ static gboolean drag_var_motion(GtkWidget *widget,
|
||||
return FALSE;
|
||||
from_n = NDX(from->table->vars, from);
|
||||
to_n = NDX(to->table->vars, to);
|
||||
for (i = from_n < to_n ? from_n : to_n;
|
||||
i != (from_n < to_n ? to_n : from_n); i++)
|
||||
FOR_UNORDERED(i, from_n, to_n)
|
||||
swap_cols(from->table, i, i+1);
|
||||
return FALSE;
|
||||
}
|
||||
@ -386,8 +388,7 @@ static gboolean drag_value_motion(GtkWidget *widget,
|
||||
|
||||
from_n = NDX(from->row->values, from);
|
||||
to_n = NDX(to->row->values, to);
|
||||
for (i = from_n < to_n ? from_n : to_n;
|
||||
i != (from_n < to_n ? to_n : from_n); i++)
|
||||
FOR_UNORDERED(i, from_n, to_n)
|
||||
swap_cols(table, i, i+1);
|
||||
|
||||
/* rows */
|
||||
@ -490,8 +491,7 @@ static gboolean drag_frame_motion(GtkWidget *widget,
|
||||
assert(to != frames);
|
||||
from_n = NDX(frames, from);
|
||||
to_n = NDX(frames, to);
|
||||
for (i = from_n < to_n ? from_n : to_n;
|
||||
i != (from_n < to_n ? to_n : from_n); i++)
|
||||
FOR_UNORDERED(i, from_n, to_n)
|
||||
swap_frames(gtk_widget_get_ancestor(widget, GTK_TYPE_TABLE),
|
||||
i, i+1);
|
||||
return FALSE;
|
||||
|
@ -378,7 +378,7 @@ void begin_drag_move_meas(struct inst *inst, int i)
|
||||
a = inst->base;
|
||||
b = inst->u.meas.end;
|
||||
if (inst->obj->u.meas.inverted)
|
||||
swap(a, b);
|
||||
SWAP(a, b);
|
||||
switch (i) {
|
||||
case 0:
|
||||
mode = meas->type < 3 ? next_to_min : max_to_min;
|
||||
|
@ -68,9 +68,9 @@ struct pix_buf *save_pix_buf(GdkDrawable *da, int xa, int ya, int xb, int yb,
|
||||
int w, h;
|
||||
|
||||
if (xa > xb)
|
||||
swap(xa, xb);
|
||||
SWAP(xa, xb);
|
||||
if (ya > yb)
|
||||
swap(ya, yb);
|
||||
SWAP(ya, yb);
|
||||
buf = alloc_type(struct pix_buf);
|
||||
buf->da = da;
|
||||
buf->x = xa-border;
|
||||
|
Loading…
Reference in New Issue
Block a user