Thanks Gabriele, Anton, and Carl,

This is all cool stuff!!

I've made a couple of changes to Gabriele and Carl's code to make it more 
general.  The code as written swapped the last two faces -- and that gave me 
all the clues to write what I think I need.

I need to take an arbitrary screen element and pop it to the top. I think 
this revised code does that. The change is mainly replacing Gabriele's Swap 
with 'move-to-end, and tweaking Carl's code to use this new function.

I've added a couple more counters (dice) and the change button also pops d1 
to the top.

Thanks for all the help guys!!!

Sunanda.


rebol []

unview/all
; This function just makes an image from a layout...
make-die: func [color [tuple!] /local image][
    layout [
        image: box 30x30 effect [draw [
            pen none
            fill-pen color none
            circle 14x14 15
        ]]
    ]
    to-image image
]

Board-elements: Stylize [
    black-square: box 100.100.100 50x50
    white-square: box white 50x50
    ; 'die is now an image - note the 'key effect used
    ; to make the black in the image transparent.
    die: box 30x30 effect [key 0.0.0 oval]
]


move-to-end: func [series item /local item-index item-value][
    item-index: find series item
    item-value: first item-index
    remove item-index
 
    append series item-value
    show last series
    show item-value
    
    ]
    


view board: layout [
    styles board-elements
    space 0x0
    across
    black-square
    white-square
    black-square
    return
    white-square
    black-square
    white-square
    return
    black-square
    white-square
    black-square
    return
    ; User-defined color. (;
    button "change" [
        d1/color: random 255.255.255
        move-to-end board/pane d1
        
    ]
    ; The 'feels here are just a copy of the drag & drop
    ; example from the 'feel how-to example on the REBOL
    ; site.
    d1: die feel [engage: func [face action event] [
        if action = 'down [move-to-end board/pane face start: event/offset]
        if find [over away] action [
            face/offset: face/offset + event/offset - start
            show face
        ]
    ]]
    d2: die feel [engage: func [face action event] [
        if action = 'down [move-to-end board/pane face start: event/offset]
        if find [over away] action [
            face/offset: face/offset + event/offset - start
            show face
        ]
    ]]
    return
    d3: die feel [engage: func [face action event] [
        if action = 'down [move-to-end board/pane face start: event/offset]
        if find [over away] action [
            face/offset: face/offset + event/offset - start
            show face
        ]
    ]]
    
    d4: die feel [engage: func [face action event] [
        if action = 'down [move-to-end board/pane face start: event/offset]
        if find [over away] action [
            face/offset: face/offset + event/offset - start
            show face
        ]
    ]]
    
    
    ; Set original colors...
    do [
        d1/color: red
        d2/color: blue
        d3/color: green
        d4/color: yellow
    ]
]
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to