Changeset 6355 for code/branches/presentation2/data/gui/scripts
- Timestamp:
- Dec 15, 2009, 5:02:22 PM (15 years ago)
- Location:
- code/branches/presentation2/data/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/data/gui/scripts/GUITools.lua
r6311 r6355 11 11 InfoPopup.setCloseButton(closeButton) 12 12 end 13 14 function getMinTextSize(window) 15 local size = {} 16 17 local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel()) 18 local height = window:getFont():getLineSpacing() + window:getUnclippedPixelRect():getHeight() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getHeight() 19 local width = window:getFont():getTextExtent(window:getText()) + window:getUnclippedPixelRect():getWidth() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getWidth() 20 21 table.insert(size, height) 22 table.insert(size, width) 23 return size 24 end 25 26 function getScrollingStepSize(window) 27 local height = window:getUnclippedPixelRect():getHeight() 28 local maxHeight = CEGUI.System:getSingleton():getGUISheet():getUnclippedPixelRect():getHeight() 29 local ratio = height/maxHeight 30 return 0.008*ratio/0.3204 31 end -
code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
r6352 r6355 67 67 linesList = {} 68 68 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 71 95 buttonWidth = 145 72 clearWidth = 2073 addWidth = 3074 spaceWidth = 1075 96 76 97 P.createLines() … … 101 122 102 123 local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command") 124 command:setText(nameList[k]) 103 125 command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(1, 0))) 104 126 command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0))) 105 command:setText(nameList[k])106 127 line:addChildWindow(command) 107 128 offset = offset + commandWidth + spaceWidth … … 118 139 for i=0,(numButtons-1) do 119 140 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)))122 141 local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i) 123 142 name = P.KeyNameNiceifier(name) 124 143 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))) 125 149 orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked") 126 150 --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked") … … 150 174 window:addChildWindow(line) 151 175 end 176 177 pane = tolua.cast(window, "CEGUI::ScrollablePane") 178 pane:setVerticalStepSize(getScrollingStepSize(window)) 152 179 end 153 180
Note: See TracChangeset
for help on using the changeset viewer.