home *** CD-ROM | disk | FTP | other *** search
- /*
- * name: upfront
- *
- * description: pull layer lp to the front of the screen.
- *
- * synopsis: upfront (lp)
- * struct layer *lp;
- *
- * globals: bottomlayer (r/w)
- * toplayer (r/w)
- *
- * calls: screenswap (screenswap.c)
- * rectxrect (rectxrect.c)
- *
- * called by: this is a top level routine.
- * dellayer (dellayer.c)
- * newlayer (newlayer.c)
- */
- #include "layers.h"
-
- extern struct layer *toplayer;
- extern struct layer *bottomlayer;
-
- upfront (lp)
- struct layer *lp;
- {
- struct layer *fr; /* a layer in front of lp */
- struct layer *beh; /* a layer behind lp */
- struct obscured *op;
- struct obscured *nop;
-
- if (lp -> ly_front == null)
- return; /* lp is at the front already */
- for (fr = lp -> ly_front; fr != null; fr = fr -> ly_front)
- /* fr = each layer in front of lp */
- for (op = lp -> ly_obs; op != null;) {
- /* op = each obscured portion of lp */
- nop = op;
- op = op -> ob_next;
- if (nop -> ob_obs == fr) { /* fr obscures nop */
- (void) screenswap (nop -> ob_bmap, &(nop -> ob_bmap -> bm_rect));
- /*
- * unlink nop from lp
- */
- if (nop -> ob_prev != null)
- nop -> ob_prev -> ob_next = nop -> ob_next;
- else
- lp -> ly_obs = nop -> ob_next;
- if (nop -> ob_next != null)
- nop -> ob_next -> ob_prev = nop -> ob_prev;
- else
- lp -> ly_endobs = nop -> ob_prev;
- /*
- * link nop into end of fr
- */
- if (fr -> ly_endobs != null)
- fr -> ly_endobs -> ob_next = nop;
- else
- fr -> ly_obs = nop;
- nop -> ob_prev = fr -> ly_endobs;
- nop -> ob_next = null;
- fr -> ly_endobs = nop;
- }
- }
- /*
- * move lp to front of layer list by
- * unlinking lp from layer list...
- */
- if (lp -> ly_back != null)
- lp -> ly_back -> ly_front = lp -> ly_front;
- else
- bottomlayer = lp -> ly_front;
- if (lp -> ly_front != null)
- lp -> ly_front -> ly_back = lp -> ly_back;
- else
- toplayer = lp -> ly_back;
- /*
- * ...and linking lp in at head of list
- */
- toplayer -> ly_front = lp;
- lp -> ly_front = null;
- lp -> ly_back = toplayer;
- toplayer = lp;
- for (beh = bottomlayer; beh != lp; beh = beh -> ly_front)
- /* beh = all other layers from back to
- front */
- for (op = beh -> ly_obs; op != null; op = op -> ob_next)
- /* op = each obscured portion of beh */
- if (rectxrect (&(lp -> ly_rect), &(op -> ob_rect)))
- op -> ob_obs = lp; /* mark op obscured by lp */
- }