mirror of
https://github.com/airstruck/luigi.git
synced 2026-01-09 15:58:22 +00:00
cleanup
This commit is contained in:
@@ -16,11 +16,6 @@ local function unhook (item)
|
|||||||
if hooks[item.host][item.key] == item then
|
if hooks[item.host][item.key] == item then
|
||||||
hooks[item.host][item.key] = item.next
|
hooks[item.host][item.key] = item.next
|
||||||
end
|
end
|
||||||
|
|
||||||
item.host = nil
|
|
||||||
item.prev = nil
|
|
||||||
item.next = nil
|
|
||||||
item.func = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hook (host, key, func, atEnd)
|
local function hook (host, key, func, atEnd)
|
||||||
@@ -81,17 +76,14 @@ function Hooker.hook (host, key, func, atEnd)
|
|||||||
local item = hooks[host][key]
|
local item = hooks[host][key]
|
||||||
|
|
||||||
while item do
|
while item do
|
||||||
local nextItem = item.next
|
local result = item.func(...)
|
||||||
if item.func then
|
if result ~= nil then
|
||||||
local result = item.func(...)
|
return result
|
||||||
if result ~= nil then
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
item = nextItem
|
item = item.next
|
||||||
end
|
end -- while
|
||||||
end
|
end -- function
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
return hook(host, key, func, atEnd)
|
return hook(host, key, func, atEnd)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -166,10 +166,12 @@ function Input:handlePressStart (layout, button, x, y, widget, accelerator)
|
|||||||
hit = nil
|
hit = nil
|
||||||
widget = layout.root
|
widget = layout.root
|
||||||
end
|
end
|
||||||
widget.pressed = true
|
if hit then
|
||||||
self.pressedWidgets[button] = widget
|
widget.pressed = true
|
||||||
self.passedWidgets[button] = widget
|
self.pressedWidgets[button] = widget
|
||||||
widget:focus()
|
self.passedWidgets[button] = widget
|
||||||
|
widget:focus()
|
||||||
|
end
|
||||||
widget:bubbleEvent('PressStart', {
|
widget:bubbleEvent('PressStart', {
|
||||||
hit = hit,
|
hit = hit,
|
||||||
button = button,
|
button = button,
|
||||||
@@ -188,7 +190,9 @@ function Input:handlePressEnd (layout, button, x, y, widget, accelerator)
|
|||||||
end
|
end
|
||||||
local originWidget = self.pressedWidgets[button]
|
local originWidget = self.pressedWidgets[button]
|
||||||
if not originWidget then return end
|
if not originWidget then return end
|
||||||
originWidget.pressed = nil
|
if hit then
|
||||||
|
originWidget.pressed = nil
|
||||||
|
end
|
||||||
widget:bubbleEvent('PressEnd', {
|
widget:bubbleEvent('PressEnd', {
|
||||||
hit = hit,
|
hit = hit,
|
||||||
origin = originWidget,
|
origin = originWidget,
|
||||||
@@ -203,8 +207,10 @@ function Input:handlePressEnd (layout, button, x, y, widget, accelerator)
|
|||||||
x = x, y = y
|
x = x, y = y
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
self.pressedWidgets[button] = nil
|
if hit then
|
||||||
self.passedWidgets[button] = nil
|
self.pressedWidgets[button] = nil
|
||||||
|
self.passedWidgets[button] = nil
|
||||||
|
end
|
||||||
return hit
|
return hit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ show = function (self)
|
|||||||
local tw = child.fontData:getAdvance(child[2].text)
|
local tw = child.fontData:getAdvance(child[2].text)
|
||||||
+ pad * 2 + h
|
+ pad * 2 + h
|
||||||
local kw = child.fontData:getAdvance(child[3].text)
|
local kw = child.fontData:getAdvance(child[3].text)
|
||||||
+ pad * 2
|
+ pad * 4
|
||||||
textWidth = math.max(textWidth, tw)
|
textWidth = math.max(textWidth, tw)
|
||||||
keyWidth = math.max(keyWidth, kw)
|
keyWidth = math.max(keyWidth, kw)
|
||||||
end
|
end
|
||||||
@@ -144,6 +144,7 @@ return function (self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if isSubmenu then
|
if isSubmenu then
|
||||||
|
key = #self.items > 0 and '>' or key
|
||||||
self.height = self.fontData:getLineHeight() + pad * 2
|
self.height = self.fontData:getLineHeight() + pad * 2
|
||||||
self.flow = 'x'
|
self.flow = 'x'
|
||||||
self:addChild({ icon = icon, width = self.height })
|
self:addChild({ icon = icon, width = self.height })
|
||||||
|
|||||||
Reference in New Issue
Block a user