9fans.net/go@v0.0.5/draw/memdraw/ltofront.go (about)

     1  // #include <u.h>
     2  // #include <libc.h>
     3  // #include <draw.h>
     4  // #include <memdraw.h>
     5  // #include <memlayer.h>
     6  
     7  package memdraw
     8  
     9  import "9fans.net/go/draw"
    10  
    11  /*
    12   * Pull i towards top of screen, just behind front
    13   */
    14  func _memltofront(i *Image, front *Image, fill bool) {
    15  	l := i.Layer
    16  	s := l.Screen
    17  	for l.front != front {
    18  		f := l.front
    19  		x := l.Screenr
    20  		overlap := draw.RectClip(&x, f.Layer.Screenr)
    21  		if overlap {
    22  			memlhide(f, x)
    23  			f.Layer.clear = false
    24  		}
    25  		/* swap l and f in screen's list */
    26  		ff := f.Layer.front
    27  		rr := l.rear
    28  		if ff == nil {
    29  			s.Frontmost = i
    30  		} else {
    31  			ff.Layer.rear = i
    32  		}
    33  		if rr == nil {
    34  			s.Rearmost = f
    35  		} else {
    36  			rr.Layer.front = f
    37  		}
    38  		l.front = ff
    39  		l.rear = f
    40  		f.Layer.front = i
    41  		f.Layer.rear = rr
    42  		if overlap && fill {
    43  			memlexpose(i, x)
    44  		}
    45  	}
    46  }
    47  
    48  func _memltofrontfill(i *Image, fill bool) {
    49  	_memltofront(i, nil, fill)
    50  	_memlsetclear(i.Layer.Screen)
    51  }
    52  
    53  func memltofront(i *Image) {
    54  	_memltofront(i, nil, true)
    55  	_memlsetclear(i.Layer.Screen)
    56  }
    57  
    58  func LToFrontN(ip []*Image, n int) {
    59  	if n == 0 {
    60  		return
    61  	}
    62  	var front *Image
    63  	for {
    64  		if n--; n < 0 {
    65  			break
    66  		}
    67  		i := ip[0]
    68  		ip = ip[1:]
    69  		_memltofront(i, front, true)
    70  		front = i
    71  	}
    72  	s := front.Layer.Screen
    73  	_memlsetclear(s)
    74  }