186 lines
5.7 KiB
Lua
186 lines
5.7 KiB
Lua
LUI.UIVerticalList = {}
|
|
LUI.UIVerticalNavigator = {}
|
|
LUI.UIVerticalList.AddSpacer = function ( f1_arg0, f1_arg1, f1_arg2 )
|
|
local self = LUI.UIElement.new( {
|
|
leftAnchor = true,
|
|
rightAnchor = true,
|
|
left = 0,
|
|
right = 0,
|
|
topAnchor = true,
|
|
bottomAnchor = false,
|
|
top = 0,
|
|
bottom = f1_arg1
|
|
} )
|
|
self:setPriority( f1_arg2 )
|
|
f1_arg0:addElement( self )
|
|
return self
|
|
end
|
|
|
|
LUI.UIVerticalList.build = function ( menu, controller )
|
|
local self = LUI.UIVerticalList.new( nil, controller.scrollByChildHeight, controller.disableOutsideChildren, controller.sendScrollEvents )
|
|
LUI.UIVerticalList.SetNoWrap( self, controller.noWrap )
|
|
return self
|
|
end
|
|
|
|
LUI.UIVerticalList.new = function ( f3_arg0, f3_arg1, f3_arg2, f3_arg3 )
|
|
local self = LUI.UIElement.new( f3_arg0 )
|
|
self.id = "LUIVerticalList"
|
|
self:setupUIVerticalList( f3_arg1, f3_arg2, f3_arg3 )
|
|
self.addSpacer = LUI.UIVerticalList.AddSpacer
|
|
self.addElement = LUI.UIVerticalList.AddElement
|
|
self.removeElement = LUI.UIVerticalList.RemoveElement
|
|
self.updateNavigation = LUI.UIVerticalList.UpdateNavigation
|
|
self:registerEventHandler( "gain_focus", LUI.UIVerticalList.gainFocus )
|
|
self:registerEventHandler( "update_navigation", function ( element, event )
|
|
element:updateNavigation()
|
|
end )
|
|
return self
|
|
end
|
|
|
|
LUI.UIVerticalList.SetNoWrap = function ( f5_arg0, f5_arg1 )
|
|
f5_arg0.noWrap = f5_arg1
|
|
end
|
|
|
|
LUI.UIVerticalNavigator.build = function ( f6_arg0, f6_arg1 )
|
|
return LUI.UIVerticalNavigator.new()
|
|
end
|
|
|
|
LUI.UIVerticalNavigator.new = function ( f7_arg0 )
|
|
local self = LUI.UIElement.new( f7_arg0 )
|
|
self.id = "LUIVerticalNavigator"
|
|
self.addSpacer = LUI.UIVerticalList.AddSpacer
|
|
self.addElement = LUI.UIVerticalList.AddElement
|
|
self.removeElement = LUI.UIVerticalList.RemoveElement
|
|
self.updateNavigation = LUI.UIVerticalList.UpdateNavigation
|
|
self:registerEventHandler( "gain_focus", LUI.UIVerticalList.gainFocus )
|
|
self:registerEventHandler( "update_navigation", function ( element, event )
|
|
element:updateNavigation()
|
|
end )
|
|
return self
|
|
end
|
|
|
|
LUI.UIVerticalList.AddElement = function ( f9_arg0, f9_arg1 )
|
|
LUI.UIElement.addElement( f9_arg0, f9_arg1 )
|
|
f9_arg1.navigation = {}
|
|
f9_arg0:setLayoutCached( false )
|
|
f9_arg0:updateNavigation()
|
|
end
|
|
|
|
LUI.UIVerticalList.RemoveElement = function ( f10_arg0, f10_arg1 )
|
|
LUI.UIElement.removeElement( f10_arg0, f10_arg1 )
|
|
f10_arg0:setLayoutCached( false )
|
|
f10_arg0:updateNavigation()
|
|
end
|
|
|
|
LUI.UIVerticalList.UpdateNavigation = function ( f11_arg0 )
|
|
local f11_local0, f11_local1 = nil
|
|
local f11_local2 = f11_arg0:getFirstChild()
|
|
while f11_local2 ~= nil do
|
|
if f11_local2:canFocus( FocusType.ListSelection ) then
|
|
if f11_local0 == nil then
|
|
f11_local0 = f11_local2
|
|
end
|
|
if f11_local1 ~= nil then
|
|
f11_local1.navigation.down = f11_local2
|
|
f11_local2.navigation.up = f11_local1
|
|
else
|
|
f11_local2.navigation.up = nil
|
|
end
|
|
if f11_local2.navigation ~= nil and f11_arg0.navigation ~= nil then
|
|
f11_local2.navigation.left = f11_arg0.navigation.left
|
|
f11_local2.navigation.right = f11_arg0.navigation.right
|
|
end
|
|
f11_local1 = f11_local2
|
|
end
|
|
f11_local2 = f11_local2:getNextSibling()
|
|
end
|
|
if f11_local1 ~= nil then
|
|
if f11_arg0.navigation ~= nil and f11_arg0.navigation.down ~= nil and f11_arg0.navigation.down:canFocus( FocusType.ListSelection ) == true then
|
|
f11_local1.navigation.down = f11_arg0.navigation.down
|
|
f11_arg0.navigation.down.navigation.up = f11_local1
|
|
elseif f11_local1 ~= f11_local0 and not f11_arg0.noWrap then
|
|
f11_local1.navigation.down = f11_local0
|
|
else
|
|
f11_local1.navigation.down = nil
|
|
end
|
|
if f11_arg0.navigation ~= nil and f11_arg0.navigation.up ~= nil and f11_arg0.navigation.up:canFocus( FocusType.ListSelection ) == true then
|
|
f11_local0.navigation.up = f11_arg0.navigation.up
|
|
f11_arg0.navigation.up.navigation.down = f11_local0
|
|
elseif f11_local1 ~= f11_local0 and not f11_arg0.noWrap then
|
|
f11_local0.navigation.up = f11_local1
|
|
else
|
|
f11_local0.navigation.up = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
LUI.UIVerticalList.gainFocus = function ( f12_arg0, f12_arg1 )
|
|
local f12_local0, f12_local1 = f12_arg0:restoreState()
|
|
if f12_local1 == 0 then
|
|
local f12_local2, f12_local3 = nil
|
|
local f12_local4 = f12_arg0:getFirstChild()
|
|
while f12_local4 ~= nil do
|
|
if f12_local4:canFocus( FocusType.ListSelection ) then
|
|
if f12_local2 == nil then
|
|
f12_local2 = f12_local4
|
|
end
|
|
if f12_local3 == nil and f12_local4.listDefaultFocus then
|
|
f12_local3 = f12_local4
|
|
end
|
|
end
|
|
end
|
|
if f12_local3 ~= nil then
|
|
f12_local3:processEvent( f12_arg1 )
|
|
elseif f12_local2 ~= nil then
|
|
f12_local2:processEvent( f12_arg1 )
|
|
else
|
|
|
|
end
|
|
f12_local4 = f12_local4:getNextSibling()
|
|
end
|
|
end
|
|
|
|
LUI.UIVerticalList.getHeightOfChildren = function ( f13_arg0, f13_arg1 )
|
|
local f13_local0 = f13_arg0:getRect()
|
|
local f13_local1 = f13_arg1 or 0
|
|
if f13_local0 then
|
|
local f13_local2 = f13_arg0:getFirstChild()
|
|
local f13_local3
|
|
if f13_local2 then
|
|
f13_local3 = -f13_local1
|
|
if not f13_local3 then
|
|
f13_local3 = 0
|
|
while f13_local2 do
|
|
local f13_local4 = nil
|
|
if f13_local2.getText and f13_local2:getText() then
|
|
local f13_local5 = nil
|
|
f13_local5, f13_local4 = f13_local2:getElementTextDims()
|
|
else
|
|
f13_local4 = f13_local2:getHeight()
|
|
end
|
|
f13_local3 = f13_local3 + f13_local1 + f13_local4
|
|
f13_local2 = f13_local2:getNextSibling()
|
|
end
|
|
return f13_local3
|
|
end
|
|
else
|
|
f13_local3 = 0
|
|
while f13_local2 do
|
|
local f13_local4 = nil
|
|
if f13_local2.getText and f13_local2:getText() then
|
|
local f13_local5 = nil
|
|
f13_local5, f13_local4 = f13_local2:getElementTextDims()
|
|
else
|
|
f13_local4 = f13_local2:getHeight()
|
|
end
|
|
f13_local3 = f13_local3 + f13_local1 + f13_local4
|
|
f13_local2 = f13_local2:getNextSibling()
|
|
end
|
|
return f13_local3
|
|
end
|
|
else
|
|
|
|
end
|
|
end
|
|
|