Here's a script you will probably enjoy.  It's been hanging around for
a couple months nagging to educate others, so I decided to give it a
name and post it.

REBOL [
    Title:  "Graphical Layout Editor"
    Author: "Carl Sassenrath"
    Date:   20-Jun-2000
    File:   %layed.r
    Purpose: {
        Your basic 1K REBOL graphical object layout editor.
        Not many features, but a good example of how to drag
        faces and show nubs.
    }
    Note: "Keeping the nubs on top is done on purpose."
    Category: [view vid 3]
]

; Layout to edit:
faces: layout [
    backdrop %bay.jpg 0.0.200
    title "Test"
    image %bay.jpg
    field
    across space 0
    button "Send"
    button "Cancel"
]

vid-face: get-style 'face

engage-drag: func [f a e][  
    if find [over away] a [
        f/offset: f/offset + e/offset - f/data
        update-nubs f
        show [f nub-face]
    ]
    if a = 'down [
        f/data: e/offset
        show-nubs f
    ]
]

nub-face: make vid-face [
    edge: make edge [color: 250.120.40 effect: 'nubs size: 4x4]
    color: font: para: text: data: none
    feel: make feel [
        engage: func [f a e] [  ;intercepts target face events
            if data [data/feel/engage data a e]
        ]
    ]
]

update-nubs: func [f] [
    nub-face/offset: f/offset - 4x4
    nub-face/size: f/size + 8x8
]

show-nubs: func [f] [
    update-nubs f
    nub-face/data: f
    if not find f/parent-face/pane nub-face [
        append f/parent-face/pane nub-face
    ]
    show f/parent-face
]

foreach f faces/pane [f/feel/engage: :engage-drag]

view faces


Reply via email to