Date:2010-05-31 07:53:56 (9 years 25 days ago)
Author:werner
Commit:b2b3a46119c500b6d02fba97e4eeede609d05c25
Message: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
Files: TODO (1 diff)
coord.c (1 diff)
gui_frame_drag.c (8 diffs)
gui_meas.c (1 diff)
gui_util.c (1 diff)
util.h (1 diff)

Change Details

TODO
5353  A1: no: would cause confusion in GUI (vectors could become orphaned)
5454  A2: yes. but we don't change the linkage.
5555- Q: how do we handle stacks of objects ?
56  A: we don't but we make it easy to avoid them, by giving a good zoom,
57     flexible selection, and by disallowing stacks of identical objects in the
58     first place.
56  A1: we don't but we make it easy to avoid them, by giving a good zoom,
57      flexible selection, and by disallowing stacks of identical objects in the
58      first place.
59  A2: the current mechanism of selecting the next eligible object when clicking
60      on the same position repeatedly lets one cycle through stacks.
5961- Q: add frame arguments ? (e.g., .frame pad(pin_num_offset) ...)
60  we can already approximate this by introducing an intermediate table that
61  sets up the arguments (provided that we don't consider vectors as well)
62  A: we can already approximate this by introducing an intermediate table that
63     sets up the arguments (provided that we don't consider vectors as well)
6264- Q: should we make it a requirement to generate objects only once ?
6365  A: yes.
6466
coord.c
157157void sort_coord(struct coord *min, struct coord *max)
158158{
159159    if (min->x > max->x)
160        swap(min->x, max->x);
160        SWAP(min->x, max->x);
161161    if (min->y > max->y)
162        swap(min->y, max->y);
162        SWAP(min->y, max->y);
163163
164164}
165165
gui_frame_drag.c
9393        NTH_walk = &(*NTH_walk)->next; \
9494       NTH_walk; })
9595
96#define FOR_UNORDERED(var, a, b) \
97    for (var = (a) < (b) ? (a) : (b); var != ((a) < (b) ? (b) : (a)); \
98        var++)
99
96100
97101/* ----- generic helper functions. maybe move to gui_util later ------------ */
98102
...... 
203207    swap_table_cells(box_of_label((*var_a)->widget),
204208        box_of_label((*var_b)->widget));
205209
206    swap(*var_a, *var_b);
207    swap((*var_a)->next, (*var_b)->next);
210    SWAP(*var_a, *var_b);
211    SWAP((*var_a)->next, (*var_b)->next);
208212}
209213
210214
...... 
218222    swap_table_cells(box_of_label((*value_a)->widget),
219223        box_of_label((*value_b)->widget));
220224
221    swap(*value_a, *value_b);
222    swap((*value_a)->next, (*value_b)->next);
225    SWAP(*value_a, *value_b);
226    SWAP((*value_a)->next, (*value_b)->next);
223227}
224228
225229
226
227230static void swap_cols(struct table *table, int a, int b)
228231{
229232    struct row *row;
...... 
246249        value_a = value_a->next;
247250        value_b = value_b->next;
248251    }
249    swap(*a, *b);
250    swap((*a)->next, (*b)->next);
252    SWAP(*a, *b);
253    SWAP((*a)->next, (*b)->next);
251254}
252255
253256
...... 
262265    swap_table_rows(table, 2*a+1, 2*b+1);
263266    swap_table_rows(table, 2*a+2, 2*b+2);
264267
265    swap(*frame_a, *frame_b);
266    swap((*frame_a)->next, (*frame_b)->next);
268    SWAP(*frame_a, *frame_b);
269    SWAP((*frame_a)->next, (*frame_b)->next);
267270}
268271
269272
...... 
341344        return FALSE;
342345    from_n = NDX(from->table->vars, from);
343346    to_n = NDX(to->table->vars, to);
344    for (i = from_n < to_n ? from_n : to_n;
345        i != (from_n < to_n ? to_n : from_n); i++)
347    FOR_UNORDERED(i, from_n, to_n)
346348        swap_cols(from->table, i, i+1);
347349    return FALSE;
348350}
...... 
386388
387389    from_n = NDX(from->row->values, from);
388390    to_n = NDX(to->row->values, to);
389    for (i = from_n < to_n ? from_n : to_n;
390        i != (from_n < to_n ? to_n : from_n); i++)
391    FOR_UNORDERED(i, from_n, to_n)
391392        swap_cols(table, i, i+1);
392393
393394    /* rows */
...... 
490491    assert(to != frames);
491492    from_n = NDX(frames, from);
492493    to_n = NDX(frames, to);
493    for (i = from_n < to_n ? from_n : to_n;
494        i != (from_n < to_n ? to_n : from_n); i++)
494    FOR_UNORDERED(i, from_n, to_n)
495495        swap_frames(gtk_widget_get_ancestor(widget, GTK_TYPE_TABLE),
496496            i, i+1);
497497    return FALSE;
gui_meas.c
378378    a = inst->base;
379379    b = inst->u.meas.end;
380380    if (inst->obj->u.meas.inverted)
381        swap(a, b);
381        SWAP(a, b);
382382    switch (i) {
383383    case 0:
384384        mode = meas->type < 3 ? next_to_min : max_to_min;
gui_util.c
6868    int w, h;
6969
7070    if (xa > xb)
71        swap(xa, xb);
71        SWAP(xa, xb);
7272    if (ya > yb)
73        swap(ya, yb);
73        SWAP(ya, yb);
7474    buf = alloc_type(struct pix_buf);
7575    buf->da = da;
7676    buf->x = xa-border;
util.h
5151    strnalloc_tmp[n] = 0; \
5252    strnalloc_tmp; })
5353
54#define swap(a, b) \
55    ({ typeof(a) swap_tmp = (a); \
54#define SWAP(a, b) \
55    ({ typeof(a) SWAP_tmp = (a); \
5656    (a) = (b); \
57    (b) = swap_tmp; })
57    (b) = SWAP_tmp; })
5858
5959
6060char *stralloc_vprintf(const char *fmt, va_list ap);

Archive Download the corresponding diff file

Branches:
master



interactive