Buttons are misplaced, if a different anchor is used

From Liberty BASIC Family
Jump to navigation Jump to search

Description

Placing four buttons within a rectangle will result in different locations in respect to the window border.

Example code to demonstrate the bug.

    nomainwin
    WindowWidth = 400
    WindowHeight = 300
    UpperLeftX = (DisplayWidth- WindowWidth) /2
    UpperLeftY = (DisplayHeight- WindowHeight) /2
    BUTTON #a, "aaaa", [none], UL, 35, 20
    BUTTON #a, "bbbb", [none], UR, 35, 20
    BUTTON #a, "cccc", [none], LL, 35, 20
    BUTTON #a, "dddd", [none], LR, 35, 20
    open "sample" for graphics_nsb as #a
    #a "trapclose [a.quit]"
    #a "down"
    #a "fill Yellow"
    #a "home"
    #a "posxy CenterX CenterY"
    #a "place 35 20"
    #a "backcolor blue"
    #a "boxfilled "; CenterX * 2 - 35; " "; CenterY * 2 - 20
    #a "flush"
[none]
    wait

[a.quit]
    close #a
    end

Example code to work around the bug.

    nomainwin
    WindowWidth = 400
    WindowHeight = 300
    UpperLeftX = (DisplayWidth- WindowWidth) /2
    UpperLeftY = (DisplayHeight- WindowHeight) /2
    BUTTON #a, "aaaa", [none], UL, 35, 20
    BUTTON #a, "bbbb", [none], UR, 35+11, 20   '
    BUTTON #a, "cccc", [none], LL, 35, 20-15   ' <<--- these three need an offset to be correct
    BUTTON #a, "dddd", [none], LR, 35+17, 20   '
    open "sample" for graphics_nsb as #a
    #a "trapclose [a.quit]"
    #a "down"
    #a "fill Yellow"
    #a "home"
    #a "posxy CenterX CenterY"
    #a "place 35 20"
    #a "backcolor blue"
    #a "boxfilled "; CenterX * 2 - 35; " "; CenterY * 2 - 20
    #a "flush"
[none]
    wait

[a.quit]
    close #a
    end