mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Фиксы комбобокса
This commit is contained in:
parent
de52410d03
commit
07003f74c5
@ -319,7 +319,7 @@
|
|||||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
|
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
|
||||||
type="Library",
|
type="Library",
|
||||||
preloadFile=true,
|
preloadFile=true,
|
||||||
version=2.12,
|
version=2.13,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path="/lib/rayEngine.lua",
|
path="/lib/rayEngine.lua",
|
||||||
|
|||||||
24
lib/GUI.lua
24
lib/GUI.lua
@ -1268,10 +1268,13 @@ local function dropDownMenuItemEventHandler(mainContainer, object, eventData)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function dropDownMenuCalculateSizes(menu)
|
local function dropDownMenuCalculateSizes(menu)
|
||||||
local totalHeight = 0
|
local y, totalHeight = menu.itemsContainer.children[1].localY, 0
|
||||||
for i = 1, #menu.itemsContainer.children do
|
for i = 1, #menu.itemsContainer.children do
|
||||||
totalHeight = totalHeight + (menu.itemsContainer.children[i].type == GUI.dropDownMenuElementTypes.separator and 1 or menu.itemHeight)
|
|
||||||
menu.itemsContainer.children[i].width = menu.width
|
menu.itemsContainer.children[i].width = menu.width
|
||||||
|
menu.itemsContainer.children[i].localY = y
|
||||||
|
|
||||||
|
y = y + menu.itemsContainer.children[i].height
|
||||||
|
totalHeight = totalHeight + (menu.itemsContainer.children[i].type == GUI.dropDownMenuElementTypes.separator and 1 or menu.itemHeight)
|
||||||
end
|
end
|
||||||
menu.height = math.min(totalHeight, menu.maximumHeight, buffer.getHeight() - menu.y)
|
menu.height = math.min(totalHeight, menu.maximumHeight, buffer.getHeight() - menu.y)
|
||||||
menu.itemsContainer.width, menu.itemsContainer.height = menu.width, menu.height
|
menu.itemsContainer.width, menu.itemsContainer.height = menu.width, menu.height
|
||||||
@ -1282,8 +1285,14 @@ local function dropDownMenuCalculateSizes(menu)
|
|||||||
menu.nextButton.hidden = menu.itemsContainer.children[#menu.itemsContainer.children].localY + menu.itemsContainer.children[#menu.itemsContainer.children].height - 1 <= menu.height
|
menu.nextButton.hidden = menu.itemsContainer.children[#menu.itemsContainer.children].localY + menu.itemsContainer.children[#menu.itemsContainer.children].height - 1 <= menu.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function dropDownMenuRemoveItem(menu, index)
|
||||||
|
table.remove(menu.itemsContainer.children, index)
|
||||||
|
dropDownMenuCalculateSizes(menu)
|
||||||
|
return menu
|
||||||
|
end
|
||||||
|
|
||||||
local function dropDownMenuAddItem(menu, text, disabled, shortcut, color)
|
local function dropDownMenuAddItem(menu, text, disabled, shortcut, color)
|
||||||
local item = menu.itemsContainer:addChild(GUI.object(1, #menu.itemsContainer.children == 0 and 1 or menu.itemsContainer.children[#menu.itemsContainer.children].localY + menu.itemsContainer.children[#menu.itemsContainer.children].height, menu.width, menu.itemHeight))
|
local item = menu.itemsContainer:addChild(GUI.object(1, 1, 1, menu.itemHeight))
|
||||||
|
|
||||||
item.type = GUI.dropDownMenuElementTypes.default
|
item.type = GUI.dropDownMenuElementTypes.default
|
||||||
item.text = text
|
item.text = text
|
||||||
@ -1414,6 +1423,7 @@ function GUI.dropDownMenu(x, y, width, maximumHeight, itemHeight, backgroundColo
|
|||||||
menu.itemHeight = itemHeight
|
menu.itemHeight = itemHeight
|
||||||
menu.addSeparator = dropDownMenuAddSeparator
|
menu.addSeparator = dropDownMenuAddSeparator
|
||||||
menu.addItem = dropDownMenuAddItem
|
menu.addItem = dropDownMenuAddItem
|
||||||
|
menu.removeItem = dropDownMenuRemoveItem
|
||||||
menu.draw = dropDownMenuDraw
|
menu.draw = dropDownMenuDraw
|
||||||
menu.show = dropDownMenuShow
|
menu.show = dropDownMenuShow
|
||||||
menu.maximumHeight = maximumHeight
|
menu.maximumHeight = maximumHeight
|
||||||
@ -1505,6 +1515,13 @@ local function comboBoxGetItem(object, index)
|
|||||||
return object.dropDownMenu.itemsContainer.children[index]
|
return object.dropDownMenu.itemsContainer.children[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function comboBoxRemoveItem(object, index)
|
||||||
|
object.dropDownMenu:removeItem(index)
|
||||||
|
if object.selectedItem > #object.dropDownMenu.itemsContainer.children then
|
||||||
|
object.selectedItem = #object.dropDownMenu.itemsContainer.children
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function comboBoxCount(object)
|
local function comboBoxCount(object)
|
||||||
return #object.dropDownMenu.itemsContainer.children
|
return #object.dropDownMenu.itemsContainer.children
|
||||||
end
|
end
|
||||||
@ -1586,6 +1603,7 @@ function GUI.comboBox(x, y, width, elementHeight, backgroundColor, textColor, ar
|
|||||||
)
|
)
|
||||||
object.selectedItem = 1
|
object.selectedItem = 1
|
||||||
object.addItem = comboBoxAddItem
|
object.addItem = comboBoxAddItem
|
||||||
|
object.removeItem = comboBoxRemoveItem
|
||||||
object.addSeparator = comboBoxAddSeparator
|
object.addSeparator = comboBoxAddSeparator
|
||||||
object.draw = drawComboBox
|
object.draw = drawComboBox
|
||||||
object.selectItem = selectComboBoxItem
|
object.selectItem = selectComboBoxItem
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user