tags:

views:

65

answers:

2

Why are my buttons not positioned at 0x0 within the box panels ?

main: layout [
    size 680x400
    origin 0x0
    space 0x0
    pad 0x0
    at 0x0

    across       
    Menu1: box brick 200x200
    return     
    Menu2: box blue 200x300
]


Menu1-items: layout [
    origin 0x0
    space 0x0
    at 0x0
    button "1"
    button "2"
    button "Quit" [quit]
]

Menu2-items: layout [
    origin 0x0
    space 0x0
    at 0x0
    button "3"
    button "4"
]    
Menu1/pane: Menu1-items
Menu2/pane: Menu2-items
Show Menu1
Show Menu2

View Main
+1  A: 

The menu1-items layout itself has a default offset. Ditto for menu2-items.

There are two ways to address that. I've used one method for menu1-items, and the other for menu2-items. Pick the one you prefer:

main: layout [
    size 680x400
    origin 0x0
    space 0x0
    pad 0x0
    at 0x0

    across       
    Menu1: box brick 200x200
    return     
    Menu2: box blue 200x300
]


Menu1-items: layout/offset [    ;; added /offset
    origin 0x0
    space 0x0
    at 0x0
    b1: button "1"
    button "2"
    button "Quit" [quit]
] 0x0                           ;; added 0x0 for value of /offset refinement

Menu2-items: layout [
    origin 0x0
    space 0x0
    at 0x0
    button "3"
    button "4"
]    

menu2-items/offset: 0x0         ;; inserted setting of /offset variable
Menu1/pane: Menu1-items
Menu2/pane: Menu2-items
Show Menu1
Show Menu2


View Main
Hello Thank you very much cannot vote for you yet as my reputation is below 15 but will do as soon as I can :)
Rebol Tutorial
+1  A: 

Another similar solution is to use the /tight refinement of layout like this :

Menu1-items: layout/tight [
    space 0x0
    button "1"
    button "2"
    button "Quit" [quit]
]

Menu2-items: layout/tight [
    space 0x0
    button "3"
    button "4"
]

Another approach would be to use PANEL element instead of BOX for having the sub-layouts inlined in one big block.