Mercurial > MadButterfly
diff src/coord.c @ 138:9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
1. Add opacity for each coord.
2. Trival and draw tree of shapes and coords in post-order.
3. Coords have a before_pmem member variable to note it's order been draw.
It is relative to it's siblings and member shapes of parent coord.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 22 Sep 2008 11:45:00 +0800 |
parents | da770188a44d |
children | 1695a4b02b14 |
line wrap: on
line diff
--- a/src/coord.c Fri Sep 19 09:53:17 2008 +0800 +++ b/src/coord.c Mon Sep 22 11:45:00 2008 +0800 @@ -123,7 +123,7 @@ coord_t *preorder_coord_subtree(coord_t *root, coord_t *last) { coord_t *next; - ASSERT(last == NULL); + ASSERT(last != NULL); if(STAILQ_HEAD(last->children)) next = STAILQ_HEAD(last->children); @@ -140,6 +140,32 @@ return next; } +coord_t *postorder_coord_subtree(coord_t *root, coord_t *last) { + coord_t *next; + + if(root == last) + return NULL; + + if(last == NULL) { + /* Go most left leaf. */ + next = root; + while(STAILQ_HEAD(next->children)) + next = STAILQ_HEAD(next->children); + return next; + } + + next = last; + if(STAILQ_NEXT(coord_t, sibling, next) == NULL) /* most right */ + return next->parent; + + /* Go most left leaf of right sibling sub-tree. */ + next = STAILQ_NEXT(coord_t, sibling, next); + while(STAILQ_HEAD(next->children)) + next = STAILQ_HEAD(next->children); + + return next; +} + void sh_attach_coord(shape_t *sh, coord_t *coord) { STAILQ_INS_TAIL(coord->members, shape_t, coord_mem_next, sh); sh->coord = coord;