Friday, 26 October 2012


VID dialect has a "strange" component: LIST.
This component is very useful, but you have to know what it means.
LIST try to fill vertically the given area using the layout you give and supply block, for example:
view layout [list 300x300 [space 0x0 across button red button gold button forest ] supply [face/text: reform [count "x" index ] ] ]

will produce this:

As you noticed, LIST uses two variables: count and index.
COUNT is the variable index to every layout line, INDEX is the variable index for every face in the current layout.
LIST permit you to create funny multi column lists, here an example:

Here the source:
Rebol []
files: sort read %.
list-files: copy []
foreach item files [append/only list-files reduce [
        size? item
        modified? item      
n:   0 ;scroller starter for list
view layout [
    backdrop effect [gradient 1x1 0.0.20 0.30.120]
    text as-is white bold join "Path:   " what-dir    
    vx: list 320x400 240.240.240 [
        across space 0x0
        txt bold 100 [print face/text]
        txt 80 180.0.0 right
        txt 75 right        
        ] supply [
            count: count + n ; n is the amount of scrolling for data
            either count <= length? files [ face/text:   list-files/:count/:index ] [face/text: ""]          
        scroller 16x400 [
            n:   to-integer (face/data * (length? list-files) )          
            show vx

BEWARE: every time something happen to the LIST (mouse over LIST, click, anything), LIST will redraw the all the face and your data (and index data) must be in the correct position, otherwise you could obtain a lot of "none" on the screen.
To scroll a LIST you have just to change the starting count, you don't need to use other functions.
You can use LIST also when you don't know the number of faces (buttons, fields, etc.) you'll need, or to create "dynamic" layouts.

No comments:

Post a Comment