Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 15, 2009, 5:02:22 PM (15 years ago)
Author:
dafrick
Message:

Made KeyBindMenu less Resolution dependent, because of this the keybind buttons aren't vertically aligned anymore.
Also made scrolling (with the mouse wheel) (to some extent) invariant of the size of the ScrollablePane in the KeyBindManager.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua

    r6352 r6355  
    6767    linesList = {}
    6868
    69     lineHeight = 30
    70     commandWidth = 150
     69    --Calculate design parameters:
     70    sampleWindow = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/SampleWindow")
     71    sampleWindow:setText("SampleText")
     72   
     73    local size = getMinTextSize(sampleWindow)
     74    lineHeight = size[1]
     75   
     76    commandWidth = 0
     77    for k,v in pairs(commandList) do
     78        sampleWindow:setText(nameList[k])
     79        size = getMinTextSize(sampleWindow)
     80        if size[2] > commandWidth then
     81            commandWidth = size[2]
     82        end
     83    end
     84
     85    sampleWindow:setText("add")
     86    size = getMinTextSize(sampleWindow)
     87    addWidth = size[2]
     88   
     89    sampleWindow:setText("X")
     90    size = getMinTextSize(sampleWindow)
     91    clearWidth = size[2]
     92
     93    spaceWidth = math.floor(1/14*commandWidth)
     94   
    7195    buttonWidth = 145
    72     clearWidth = 20
    73     addWidth = 30
    74     spaceWidth = 10
    7596
    7697    P.createLines()
     
    101122
    102123    local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
     124    command:setText(nameList[k])
    103125    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(1, 0)))
    104126    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0)))
    105     command:setText(nameList[k])
    106127    line:addChildWindow(command)
    107128    offset = offset + commandWidth + spaceWidth
     
    118139    for i=0,(numButtons-1) do
    119140        local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
    120         button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
    121         button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
    122141        local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i)
    123142        name = P.KeyNameNiceifier(name)
    124143        button:setText(name)
     144        sampleWindow:setText(name)
     145        local size = getMinTextSize(sampleWindow)
     146        local buttonWidth = size[2]
     147        button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
     148        button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
    125149        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
    126150        --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
     
    150174        window:addChildWindow(line)
    151175    end
     176   
     177    pane = tolua.cast(window, "CEGUI::ScrollablePane")
     178    pane:setVerticalStepSize(getScrollingStepSize(window))
    152179end
    153180
Note: See TracChangeset for help on using the changeset viewer.