2023-12-26 14:48:33 +03:00
|
|
|
Parent = {
|
2024-07-12 13:32:01 +03:00
|
|
|
_id = "parent",
|
2023-12-26 14:48:33 +03:00
|
|
|
}
|
|
|
|
|
2024-07-12 13:32:01 +03:00
|
|
|
function Parent:new(area, tab)
|
|
|
|
return setmetatable({
|
|
|
|
_area = area,
|
|
|
|
_tab = tab,
|
|
|
|
_folder = tab.parent,
|
|
|
|
}, { __index = self })
|
|
|
|
end
|
2023-12-26 14:48:33 +03:00
|
|
|
|
2024-10-30 14:06:06 +03:00
|
|
|
function Parent:reflow() return { self } end
|
|
|
|
|
|
|
|
function Parent:redraw()
|
2024-07-12 13:32:01 +03:00
|
|
|
if not self._folder then
|
2023-12-26 14:48:33 +03:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2024-10-30 14:06:06 +03:00
|
|
|
local entities = {}
|
2024-07-12 13:32:01 +03:00
|
|
|
for _, f in ipairs(self._folder.window) do
|
2024-10-30 14:06:06 +03:00
|
|
|
entities[#entities + 1] = Entity:new(f):redraw()
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
|
|
|
|
2024-07-12 13:32:01 +03:00
|
|
|
return {
|
2024-10-30 14:06:06 +03:00
|
|
|
ui.List(entities):area(self._area),
|
2024-02-15 15:20:28 +03:00
|
|
|
}
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
2024-06-03 09:31:55 +03:00
|
|
|
|
2024-07-12 13:32:01 +03:00
|
|
|
-- Mouse events
|
2024-06-03 09:31:55 +03:00
|
|
|
function Parent:click(event, up)
|
|
|
|
if up or not event.is_left then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2024-07-12 13:32:01 +03:00
|
|
|
local y = event.y - self._area.y + 1
|
|
|
|
local window = self._folder and self._folder.window or {}
|
|
|
|
if window[y] then
|
|
|
|
ya.manager_emit("reveal", { window[y].url })
|
2024-06-03 09:31:55 +03:00
|
|
|
else
|
|
|
|
ya.manager_emit("leave", {})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Parent:scroll(event, step) end
|
|
|
|
|
|
|
|
function Parent:touch(event, step) end
|