mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Added List View mode for Finder, instant launch feature for .lua extension and some improvements for icons selection
This commit is contained in:
parent
4817e76d65
commit
7e1475e32a
@ -27,6 +27,7 @@ local config = {
|
||||
{ name = "Trash", path = paths.user.trash },
|
||||
},
|
||||
sidebarWidth = 20,
|
||||
gridMode = 1,
|
||||
}
|
||||
|
||||
if filesystem.exists(configPath) then
|
||||
@ -36,15 +37,12 @@ end
|
||||
local sidebarTitleColor = 0xC3C3C3
|
||||
local sidebarItemColor = 0x696969
|
||||
|
||||
local iconFieldYOffset = 2
|
||||
local scrollTimerHandler
|
||||
|
||||
local workpathHistory = {}
|
||||
local workpathHistoryCurrent = 0
|
||||
local pathHistory = {}
|
||||
local pathHistoryCurrent = 0
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 100, 26, 0xE1E1E1))
|
||||
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 100, 26, 0xF0F0F0))
|
||||
|
||||
local titlePanel = window:addChild(GUI.panel(1, 1, 1, 3, 0x3C3C3C))
|
||||
|
||||
@ -56,10 +54,12 @@ local nextButton = window:addChild(GUI.adaptiveRoundedButton(14, 2, 1, 0, 0x5A5A
|
||||
nextButton.colors.disabled = prevButton.colors.disabled
|
||||
|
||||
local FTPButton = window:addChild(GUI.adaptiveRoundedButton(nextButton.localX + nextButton.width + 2, 2, 1, 0, 0x5A5A5A, 0xC3C3C3, 0xE1E1E1, 0x3C3C3C, "FTP"))
|
||||
|
||||
FTPButton.colors.disabled = prevButton.colors.disabled
|
||||
FTPButton.disabled = not network.internetProxy
|
||||
|
||||
local modeList = window:addChild(GUI.list(FTPButton.localX + FTPButton.width + 2, 2, 10, 1, 2, 0, 0x4B4B4B, 0xE1E1E1, 0x4B4B4B, 0xE1E1E1, 0xE1E1E1, 0x4B4B4B, true))
|
||||
modeList:setDirection(GUI.DIRECTION_HORIZONTAL)
|
||||
|
||||
local sidebarContainer = window:addChild(GUI.container(1, 4, config.sidebarWidth, 1))
|
||||
local sidebarPanel = sidebarContainer:addChild(GUI.object(1, 1, 1, 1, 0xFFFFFF))
|
||||
sidebarPanel.draw = function(object)
|
||||
@ -71,14 +71,11 @@ itemsLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERT
|
||||
itemsLayout:setSpacing(1, 1, 0)
|
||||
itemsLayout:setMargin(1, 1, 0, 0)
|
||||
|
||||
local searchInput = window:addChild(GUI.input(1, 2, 20, 1, 0x4B4B4B, 0xC3C3C3, 0x878787, 0x4B4B4B, 0xE1E1E1, nil, localization.search, true))
|
||||
local searchInput = window:addChild(GUI.input(1, 2, 16, 1, 0x4B4B4B, 0xC3C3C3, 0x878787, 0x4B4B4B, 0xE1E1E1, nil, localization.search, true))
|
||||
|
||||
local iconField = window:addChild(system.iconField(1, 4, 1, 1, 2, 2, 0x3C3C3C, 0x969696, paths.user.desktop))
|
||||
local iconField
|
||||
|
||||
local scrollBar = window:addChild(GUI.scrollBar(1, 4, 1, 1, 0xC3C3C3, 0x4B4B4B, iconFieldYOffset, 1, 1, 1, 1, true))
|
||||
scrollBar.eventHandler = nil
|
||||
|
||||
local statusContainer = window:addChild(GUI.container(FTPButton.localX + FTPButton.width + 2, 2, 1, 1))
|
||||
local statusContainer = window:addChild(GUI.container(modeList.localX + modeList.width + 1, 2, 1, 1))
|
||||
local statusPanel = statusContainer:addChild(GUI.panel(1, 1, 1, 1, 0x4B4B4B))
|
||||
|
||||
local gotoButton = window:addChild(GUI.button(1, 2, 3, 1, 0x5A5A5A, 0xC3C3C3, 0xE1E1E1, 0x3C3C3C, "→"))
|
||||
@ -98,47 +95,45 @@ local function updateFileListAndDraw()
|
||||
workspace:draw()
|
||||
end
|
||||
|
||||
local function workpathHistoryButtonsUpdate()
|
||||
prevButton.disabled = workpathHistoryCurrent <= 1
|
||||
nextButton.disabled = workpathHistoryCurrent >= #workpathHistory
|
||||
local function pathHistoryButtonsUpdate()
|
||||
prevButton.disabled = pathHistoryCurrent <= 1
|
||||
nextButton.disabled = pathHistoryCurrent >= #pathHistory
|
||||
end
|
||||
|
||||
local function prevOrNextWorkpath(next)
|
||||
local function prevOrNextpath(next)
|
||||
if next then
|
||||
if workpathHistoryCurrent < #workpathHistory then
|
||||
workpathHistoryCurrent = workpathHistoryCurrent + 1
|
||||
if pathHistoryCurrent < #pathHistory then
|
||||
pathHistoryCurrent = pathHistoryCurrent + 1
|
||||
end
|
||||
else
|
||||
if workpathHistoryCurrent > 1 then
|
||||
workpathHistoryCurrent = workpathHistoryCurrent - 1
|
||||
if pathHistoryCurrent > 1 then
|
||||
pathHistoryCurrent = pathHistoryCurrent - 1
|
||||
end
|
||||
end
|
||||
|
||||
workpathHistoryButtonsUpdate()
|
||||
iconField.yOffset = iconFieldYOffset
|
||||
iconField:setWorkpath(workpathHistory[workpathHistoryCurrent])
|
||||
pathHistoryButtonsUpdate()
|
||||
iconField:setPath(pathHistory[pathHistoryCurrent])
|
||||
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
local function addWorkpath(path)
|
||||
workpathHistoryCurrent = workpathHistoryCurrent + 1
|
||||
table.insert(workpathHistory, workpathHistoryCurrent, path)
|
||||
for i = workpathHistoryCurrent + 1, #workpathHistory do
|
||||
workpathHistory[i] = nil
|
||||
local function addpath(path)
|
||||
pathHistoryCurrent = pathHistoryCurrent + 1
|
||||
table.insert(pathHistory, pathHistoryCurrent, path)
|
||||
for i = pathHistoryCurrent + 1, #pathHistory do
|
||||
pathHistory[i] = nil
|
||||
end
|
||||
|
||||
workpathHistoryButtonsUpdate()
|
||||
pathHistoryButtonsUpdate()
|
||||
searchInput.text = ""
|
||||
iconField.yOffset = iconFieldYOffset
|
||||
iconField:setWorkpath(path)
|
||||
iconField:setPath(path)
|
||||
end
|
||||
|
||||
local function sidebarItemDraw(object)
|
||||
local textColor, limit = object.textColor, object.width - 2
|
||||
if object.path == iconField.workpath then
|
||||
if object.path == iconField.path then
|
||||
textColor = 0x5A5A5A
|
||||
screen.drawRectangle(object.x, object.y, object.width, 1, 0xE1E1E1, textColor, " ")
|
||||
screen.drawRectangle(object.x, object.y, object.width, 1, 0xF0F0F0, textColor, " ")
|
||||
|
||||
if object.onRemove then
|
||||
limit = limit - 2
|
||||
@ -185,7 +180,7 @@ local function addSidebarSeparator()
|
||||
end
|
||||
|
||||
local function onFavouriteTouch(path)
|
||||
addWorkpath(path)
|
||||
addpath(path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
@ -194,7 +189,7 @@ local openFTP, updateSidebar
|
||||
openFTP = function(...)
|
||||
local mountPath = network.mountPaths.FTP .. network.getFTPProxyName(...) .. "/"
|
||||
|
||||
addWorkpath(mountPath)
|
||||
addpath(mountPath)
|
||||
workspace:draw()
|
||||
|
||||
local proxy, reason = network.connectToFTP(...)
|
||||
@ -241,7 +236,7 @@ updateSidebar = function()
|
||||
end
|
||||
|
||||
addSidebarItem(" " .. network.getModemProxyName(proxy), path).onTouch = function()
|
||||
addWorkpath(path)
|
||||
addpath(path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
end
|
||||
@ -317,41 +312,17 @@ itemsLayout.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
|
||||
end
|
||||
end
|
||||
|
||||
local function updateScrollBar()
|
||||
local shownFilesCount = #iconField.fileList - iconField.fromFile + 1
|
||||
|
||||
local horizontalLines = math.ceil(shownFilesCount / iconField.iconCount.horizontal)
|
||||
local minimumOffset = 3 - (horizontalLines - 1) * (userSettings.iconHeight + userSettings.iconVerticalSpace) - userSettings.iconVerticalSpace
|
||||
|
||||
if iconField.yOffset > iconFieldYOffset then
|
||||
iconField.yOffset = iconFieldYOffset
|
||||
elseif iconField.yOffset < minimumOffset then
|
||||
iconField.yOffset = minimumOffset
|
||||
end
|
||||
|
||||
if shownFilesCount > iconField.iconCount.total then
|
||||
scrollBar.hidden = false
|
||||
scrollBar.maximumValue = math.abs(minimumOffset)
|
||||
scrollBar.value = math.abs(iconField.yOffset - iconFieldYOffset)
|
||||
else
|
||||
scrollBar.hidden = true
|
||||
end
|
||||
end
|
||||
|
||||
searchInput.onInputFinished = function()
|
||||
iconField.filenameMatcher = searchInput.text
|
||||
iconField.fromFile = 1
|
||||
iconField.yOffset = iconFieldYOffset
|
||||
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
nextButton.onTouch = function()
|
||||
prevOrNextWorkpath(true)
|
||||
prevOrNextpath(true)
|
||||
end
|
||||
|
||||
prevButton.onTouch = function()
|
||||
prevOrNextWorkpath(false)
|
||||
prevOrNextpath(false)
|
||||
end
|
||||
|
||||
FTPButton.onTouch = function()
|
||||
@ -405,127 +376,6 @@ FTPButton.onTouch = function()
|
||||
workspace:draw()
|
||||
end
|
||||
|
||||
iconField.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
|
||||
if e1 == "scroll" then
|
||||
iconField.yOffset = iconField.yOffset + e5 * 2
|
||||
|
||||
updateScrollBar()
|
||||
|
||||
local delta = iconField.yOffset - iconField.iconsContainer.children[1].localY
|
||||
for i = 1, #iconField.iconsContainer.children do
|
||||
iconField.iconsContainer.children[i].localY = iconField.iconsContainer.children[i].localY + delta
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
|
||||
if scrollTimerHandler then
|
||||
event.removeHandler(scrollTimerHandler)
|
||||
scrollTimerHandler = nil
|
||||
end
|
||||
|
||||
scrollTimerHandler = event.addHandler(function()
|
||||
computer.pushSignal("Finder", "updateFileList")
|
||||
end, 0.3, 1)
|
||||
elseif e1 == "system" or e1 == "Finder" then
|
||||
if e2 == "updateFileList" then
|
||||
if e1 == "system" then
|
||||
iconField.yOffset = iconFieldYOffset
|
||||
end
|
||||
|
||||
updateFileListAndDraw()
|
||||
elseif e2 == "updateFavourites" then
|
||||
if e3 then
|
||||
table.insert(config.favourites, e3)
|
||||
end
|
||||
|
||||
saveConfig()
|
||||
updateSidebar()
|
||||
workspace:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
iconField.launchers.directory = function(icon)
|
||||
addWorkpath(icon.path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
iconField.launchers.showPackageContent = function(icon)
|
||||
addWorkpath(icon.path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
iconField.launchers.showContainingFolder = function(icon)
|
||||
addWorkpath(filesystem.path(system.readShortcut(icon.path)))
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
local overrideUpdateFileList = iconField.updateFileList
|
||||
iconField.updateFileList = function(...)
|
||||
statusContainer:removeChildren(2)
|
||||
|
||||
local x, path = 2, "/"
|
||||
|
||||
local function addNode(text, path)
|
||||
statusContainer:addChild(GUI.adaptiveButton(x, 1, 0, 0, nil, 0xB4B4B4, nil, 0xFFFFFF, text)).onTouch = function()
|
||||
addWorkpath(path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
x = x + unicode.len(text)
|
||||
end
|
||||
|
||||
addNode("root", "/")
|
||||
|
||||
for node in iconField.workpath:gsub("/$", ""):gmatch("[^/]+") do
|
||||
statusContainer:addChild(GUI.text(x, 1, 0x696969, " ► "))
|
||||
x = x + 3
|
||||
|
||||
path = path .. node .. "/"
|
||||
addNode(node, path)
|
||||
end
|
||||
|
||||
if x > statusContainer.width then
|
||||
for i = 2, #statusContainer.children do
|
||||
statusContainer.children[i].localX = statusContainer.children[i].localX - (x - statusContainer.width)
|
||||
end
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
overrideUpdateFileList(...)
|
||||
updateScrollBar()
|
||||
end
|
||||
|
||||
gotoButton.onTouch = function()
|
||||
local input = window:addChild(GUI.input(statusContainer.localX, statusContainer.localY, statusContainer.width, 1, 0x4B4B4B, 0xC3C3C3, 0xC3C3C3, 0x4B4B4B, 0xC3C3C3, nil, nil))
|
||||
|
||||
input.onInputFinished = function()
|
||||
input:remove()
|
||||
statusContainer.hidden = false
|
||||
input.text = ("/" .. input.text .. "/"):gsub("/+", "/")
|
||||
|
||||
if filesystem.exists(input.text) and filesystem.isDirectory(input.text) then
|
||||
addWorkpath(input.text)
|
||||
iconField:updateFileList()
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
end
|
||||
|
||||
statusContainer.hidden = true
|
||||
input:startInput()
|
||||
end
|
||||
|
||||
local overrideMaximize = window.actionButtons.maximize.onTouch
|
||||
window.actionButtons.maximize.onTouch = function()
|
||||
iconField.yOffset = iconFieldYOffset
|
||||
overrideMaximize()
|
||||
end
|
||||
|
||||
window.actionButtons.close.onTouch = function()
|
||||
window:remove()
|
||||
end
|
||||
|
||||
local function calculateSizes()
|
||||
sidebarContainer.height = window.height - 3
|
||||
|
||||
@ -549,7 +399,7 @@ local function calculateSizes()
|
||||
titlePanel.width = window.width
|
||||
searchInput.localX = window.width - searchInput.width
|
||||
|
||||
statusContainer.width = window.width - searchInput.width - FTPButton.width - 25
|
||||
statusContainer.width = window.width - searchInput.width - FTPButton.width - modeList.width - 26
|
||||
statusPanel.width = statusContainer.width
|
||||
|
||||
gotoButton.localX = statusContainer.localX + statusContainer.width
|
||||
@ -557,10 +407,154 @@ local function calculateSizes()
|
||||
iconField.width = window.backgroundPanel.width
|
||||
iconField.height = window.height + 3
|
||||
iconField.localX = window.backgroundPanel.localX
|
||||
end
|
||||
|
||||
scrollBar.localX = window.width
|
||||
scrollBar.height = window.backgroundPanel.height
|
||||
scrollBar.shownValueCount = scrollBar.height - 1
|
||||
local function updateIconField(gridMode)
|
||||
local path
|
||||
if iconField then
|
||||
path = iconField.path
|
||||
iconField:remove()
|
||||
else
|
||||
path = paths.user.desktop
|
||||
end
|
||||
|
||||
iconField = window:addChild(
|
||||
gridMode and
|
||||
system.gridIconField(
|
||||
1, 4, 1, 1, 2, 2, path,
|
||||
0x3C3C3C,
|
||||
0xC3C3C3,
|
||||
0x3C3C3C,
|
||||
0x696969,
|
||||
nil
|
||||
) or
|
||||
system.listIconField(
|
||||
1, 4, 1, 1, path,
|
||||
0xF0F0F0,
|
||||
0xFFFFFF,
|
||||
0x000000
|
||||
)
|
||||
)
|
||||
|
||||
iconField.launchers.directory = function(icon)
|
||||
addpath(icon.path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
iconField.launchers.showPackageContent = function(icon)
|
||||
addpath(icon.path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
iconField.launchers.showContainingFolder = function(icon)
|
||||
addpath(filesystem.path(system.readShortcut(icon.path)))
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
iconField.eventHandler = function(workspace, self, e1, e2, e3, e4, e5)
|
||||
if e1 == "scroll" then
|
||||
if gridMode then
|
||||
local rows = math.ceil((#iconField.children - 1) / iconField.iconCount.horizontal)
|
||||
local minimumOffset = (rows - 1) * (userSettings.iconHeight + userSettings.iconVerticalSpace) - userSettings.iconVerticalSpace
|
||||
|
||||
iconField.yOffset = math.max(-minimumOffset + 1, math.min(iconField.yOffsetInitial, iconField.yOffset + e5 * 2))
|
||||
|
||||
-- Moving icons upper or lower
|
||||
local delta, child = iconField.yOffset - iconField.children[2].localY
|
||||
for i = 1, #iconField.children do
|
||||
child = iconField.children[i]
|
||||
|
||||
if child ~= iconField.backgroundObject then
|
||||
child.localY = child.localY + delta
|
||||
end
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
else
|
||||
GUI.tableEventHandler(workspace, self, e1, e2, e3, e4, e5)
|
||||
end
|
||||
elseif e1 == "system" or e1 == "Finder" then
|
||||
if e2 == "updateFileList" then
|
||||
updateFileListAndDraw()
|
||||
elseif e2 == "updateFavourites" then
|
||||
if e3 then
|
||||
table.insert(config.favourites, e3)
|
||||
end
|
||||
|
||||
saveConfig()
|
||||
updateSidebar()
|
||||
workspace:draw()
|
||||
end
|
||||
else
|
||||
GUI.tableEventHandler(workspace, self, e1, e2, e3, e4, e5)
|
||||
end
|
||||
end
|
||||
|
||||
local overrideUpdateFileList = iconField.updateFileList
|
||||
iconField.updateFileList = function(...)
|
||||
statusContainer:removeChildren(2)
|
||||
|
||||
local x, path = 2, "/"
|
||||
|
||||
local function addNode(text, path)
|
||||
statusContainer:addChild(GUI.adaptiveButton(x, 1, 0, 0, nil, 0xB4B4B4, nil, 0xFFFFFF, text)).onTouch = function()
|
||||
addpath(path)
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
x = x + unicode.len(text)
|
||||
end
|
||||
|
||||
addNode("root", "/")
|
||||
|
||||
for node in iconField.path:gsub("/$", ""):gmatch("[^/]+") do
|
||||
statusContainer:addChild(GUI.text(x, 1, 0x696969, " ► "))
|
||||
x = x + 3
|
||||
|
||||
path = path .. node .. "/"
|
||||
addNode(node, path)
|
||||
end
|
||||
|
||||
if x > statusContainer.width then
|
||||
for i = 2, #statusContainer.children do
|
||||
statusContainer.children[i].localX = statusContainer.children[i].localX - (x - statusContainer.width)
|
||||
end
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
overrideUpdateFileList(...)
|
||||
end
|
||||
|
||||
calculateSizes()
|
||||
end
|
||||
|
||||
gotoButton.onTouch = function()
|
||||
local input = window:addChild(GUI.input(statusContainer.localX, statusContainer.localY, statusContainer.width, 1, 0x4B4B4B, 0xC3C3C3, 0xC3C3C3, 0x4B4B4B, 0xC3C3C3, nil, nil))
|
||||
|
||||
input.onInputFinished = function()
|
||||
input:remove()
|
||||
statusContainer.hidden = false
|
||||
input.text = ("/" .. input.text .. "/"):gsub("/+", "/")
|
||||
|
||||
if filesystem.exists(input.text) and filesystem.isDirectory(input.text) then
|
||||
addpath(input.text)
|
||||
iconField:updateFileList()
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
end
|
||||
|
||||
statusContainer.hidden = true
|
||||
input:startInput()
|
||||
end
|
||||
|
||||
local overrideMaximize = window.actionButtons.maximize.onTouch
|
||||
window.actionButtons.maximize.onTouch = function()
|
||||
overrideMaximize()
|
||||
end
|
||||
|
||||
window.actionButtons.close.onTouch = function()
|
||||
window:remove()
|
||||
end
|
||||
|
||||
window.onResize = function(width, height)
|
||||
@ -588,12 +582,31 @@ resizer.onResizeFinished = function()
|
||||
saveConfig()
|
||||
end
|
||||
|
||||
local function saveMode(gridMode)
|
||||
updateIconField(gridMode)
|
||||
updateFileListAndDraw()
|
||||
|
||||
config.gridMode = gridMode
|
||||
saveConfig()
|
||||
end
|
||||
|
||||
modeList:addItem("☷").onTouch = function()
|
||||
saveMode(true)
|
||||
end
|
||||
|
||||
modeList:addItem("☰").onTouch = function()
|
||||
saveMode(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
updateIconField(config.gridMode)
|
||||
modeList.selectedItem = config.gridMode and 1 or 2
|
||||
|
||||
if (options.o or options.open) and args[1] and filesystem.isDirectory(args[1]) then
|
||||
addWorkpath(args[1])
|
||||
addpath(args[1])
|
||||
else
|
||||
addWorkpath("/")
|
||||
addpath("/")
|
||||
end
|
||||
|
||||
updateSidebar()
|
||||
|
||||
@ -7,6 +7,14 @@ local system = require("System")
|
||||
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
||||
local localization = system.getSystemLocalization()
|
||||
|
||||
menu:addItem(localization.launch).onTouch = function()
|
||||
system.execute(icon.path)
|
||||
end
|
||||
|
||||
menu:addItem(localization.launchWithArguments).onTouch = function()
|
||||
system.launchWithArguments(icon.path)
|
||||
end
|
||||
|
||||
menu:addItem(localization.flashEEPROM, not component.isAvailable("eeprom") or filesystem.size(icon.path) > 4096).onTouch = function()
|
||||
local container = GUI.addBackgroundContainer(workspace, true, true, localization.flashEEPROM)
|
||||
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, localization.flashingEEPROM)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
@ -18,8 +26,4 @@ menu:addItem(localization.flashEEPROM, not component.isAvailable("eeprom") or fi
|
||||
workspace:draw()
|
||||
end
|
||||
|
||||
menu:addItem(localization.launchWithArguments).onTouch = function()
|
||||
system.launchWithArguments(icon.path)
|
||||
end
|
||||
|
||||
system.addUploadToPastebinMenuItem(menu, icon.path)
|
||||
|
||||
@ -4526,6 +4526,241 @@ function GUI.progressIndicator(x, y, passiveColor, primaryColor, secondaryColor)
|
||||
return object
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
local function tableHeaderDraw(self)
|
||||
screen.drawRectangle(self.x, self.y, self.width, self.height, self.parent.colors.headerBackground, self.parent.colors.headerText, " ")
|
||||
screen.drawText(self.x + 1, self.y, self.parent.colors.headerText, self.text)
|
||||
end
|
||||
|
||||
local function tableAddColumn(self, headerText, sizePolicy, size)
|
||||
layoutAddColumn(self, sizePolicy, size)
|
||||
|
||||
local lastColumn = #self.columnSizes
|
||||
|
||||
local header = self:setPosition(lastColumn, 1, self:addChild(GUI.object(1, 1, 1, self.itemHeight)))
|
||||
header.text = headerText
|
||||
header.draw = tableHeaderDraw
|
||||
|
||||
for row = 1, 2 do
|
||||
self:setAlignment(lastColumn, row, GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
self:setSpacing(lastColumn, row, 0)
|
||||
self:setFitting(lastColumn, row, true, false)
|
||||
end
|
||||
end
|
||||
|
||||
local function tableAddRow(self, ...)
|
||||
local objects, columnCount = {...}, #self.columnSizes
|
||||
local index = #self.children - columnCount + 1
|
||||
|
||||
if #objects == columnCount then
|
||||
for i = #objects, 1, -1 do
|
||||
local object = self:setPosition(i, 2, self:addChild(objects[i], index))
|
||||
|
||||
object.height = self.itemHeight
|
||||
object.alternative = self.nextRowAlternative
|
||||
end
|
||||
|
||||
self.nextRowAlternative = not self.nextRowAlternative
|
||||
else
|
||||
error("Failed to add row: count of columns ~= count of objects in row")
|
||||
end
|
||||
end
|
||||
|
||||
local function tableUpdateSelection(self)
|
||||
local columnCount, row = #self.columnSizes, 1
|
||||
|
||||
for i = 1, #self.children - columnCount, columnCount do
|
||||
for j = i, i + columnCount - 1 do
|
||||
self.children[j].selected = self.selectedRows[row]
|
||||
end
|
||||
|
||||
row = row + 1
|
||||
end
|
||||
end
|
||||
|
||||
local function tableClear(self)
|
||||
local columnCount, childrenCount = #self.columnSizes, #self.children
|
||||
if childrenCount > columnCount then
|
||||
self:removeChildren(1, childrenCount - columnCount)
|
||||
end
|
||||
|
||||
self.selectedRows, self.nextRowAlternative = {}, nil
|
||||
end
|
||||
|
||||
function GUI.tableCellEventHandler(workspace, self, e1, e2, e3, e4, e5, ...)
|
||||
if e1 == "touch" or e1 == "drag" or e1 == "double_touch" then
|
||||
local row = math.ceil(self:indexOf() / #self.parent.columnSizes)
|
||||
|
||||
-- Deselecting all rows
|
||||
if (e5 == 0 or not self.parent.selectedRows[row]) and not (keyboard.isControlDown() or keyboard.isCommandDown()) then
|
||||
self.parent.selectedRows = {}
|
||||
end
|
||||
|
||||
-- Selecting this row
|
||||
self.parent.selectedRows[row] = true
|
||||
tableUpdateSelection(self.parent)
|
||||
|
||||
if self.parent.onCellTouch then
|
||||
self.parent.onCellTouch(workspace, self, e1, e2, e3, e4, e5, ...)
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
end
|
||||
end
|
||||
|
||||
function GUI.tableCellDraw(self)
|
||||
local background, foreground
|
||||
if self.selected then
|
||||
background, foreground = self.colors.selectionBackground, self.colors.selectionText
|
||||
elseif self.alternative then
|
||||
background, foreground = self.colors.alternativeBackground, self.colors.alternativeText
|
||||
else
|
||||
background, foreground = self.colors.defaultBackground, self.colors.defaultText
|
||||
end
|
||||
|
||||
if background then
|
||||
screen.drawRectangle(self.x, self.y, self.width, self.height,
|
||||
background,
|
||||
foreground,
|
||||
" ")
|
||||
end
|
||||
|
||||
return foreground
|
||||
end
|
||||
|
||||
function GUI.tableCell(colors)
|
||||
local cell = GUI.object(1, 1, 1, 1)
|
||||
|
||||
cell.colors = colors
|
||||
cell.draw = GUI.tableCellDraw
|
||||
cell.eventHandler = GUI.tableCellEventHandler
|
||||
|
||||
return cell
|
||||
end
|
||||
|
||||
local function tableTextCellDraw(self)
|
||||
screen.drawText(self.x + 1, self.y, GUI.tableCellDraw(self), self.text)
|
||||
end
|
||||
|
||||
function GUI.tableTextCell(colors, text)
|
||||
local cell = GUI.tableCell(colors)
|
||||
|
||||
cell.text = text
|
||||
cell.draw = tableTextCellDraw
|
||||
|
||||
return cell
|
||||
end
|
||||
|
||||
local function tableDraw(self)
|
||||
-- Items background
|
||||
screen.drawRectangle(self.x, self.y + self.itemHeight, self.width, self.height - self.itemHeight, self.colors.background, 0x0, " ")
|
||||
-- Content
|
||||
layoutDraw(self)
|
||||
end
|
||||
|
||||
function GUI.tableEventHandler(workspace, self, e1, e2, e3, e4, e5, ...)
|
||||
if e1 == "touch" then
|
||||
local itemTouched = false
|
||||
for i = 1, #self.children do
|
||||
if self.children[i]:isPointInside(e3, e4) then
|
||||
itemTouched = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not itemTouched then
|
||||
self.onBackgroundTouch(workspace, self, e1, e2, e3, e4, e5, ...)
|
||||
end
|
||||
elseif e1 == "scroll" then
|
||||
local columnCount = #self.columnSizes
|
||||
local horizontalMargin, verticalMargin = self:getMargin(1, 2)
|
||||
|
||||
for i = 1, columnCount do
|
||||
self:setMargin(i, 2, horizontalMargin,
|
||||
math.max(
|
||||
-self.itemHeight * (#self.children - columnCount) / columnCount + 1,
|
||||
math.min(
|
||||
0,
|
||||
verticalMargin + e5
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
workspace:draw()
|
||||
end
|
||||
end
|
||||
|
||||
function GUI.table(x, y, width, height, itemHeight, backgroundColor, headerBackgroundColor, headerTextColor)
|
||||
local table = GUI.layout(x, y, width, height, 0, 2)
|
||||
|
||||
table.colors = {
|
||||
background = backgroundColor,
|
||||
headerBackground = headerBackgroundColor,
|
||||
headerText = headerTextColor
|
||||
}
|
||||
|
||||
table.itemHeight = itemHeight
|
||||
table.selectedRows = {}
|
||||
|
||||
table.addColumn = tableAddColumn
|
||||
table.addRow = tableAddRow
|
||||
table.clear = tableClear
|
||||
table.draw = tableDraw
|
||||
table.eventHandler = GUI.tableEventHandler
|
||||
|
||||
table:setRowHeight(1, GUI.SIZE_POLICY_ABSOLUTE, itemHeight)
|
||||
table:setRowHeight(2, GUI.SIZE_POLICY_RELATIVE, 1.0)
|
||||
|
||||
return table
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
-- local workspace = GUI.workspace()
|
||||
|
||||
-- workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))
|
||||
|
||||
-- local t = workspace:addChild(GUI.table(3, 2, 80, 30, 1,
|
||||
-- 0xF0F0F0,
|
||||
-- 0xFFFFFF,
|
||||
-- 0x000000
|
||||
-- ))
|
||||
|
||||
-- t:addColumn("Name", GUI.SIZE_POLICY_RELATIVE, 0.6)
|
||||
-- t:addColumn("Date", GUI.SIZE_POLICY_RELATIVE, 0.4)
|
||||
-- t:addColumn("Size", GUI.SIZE_POLICY_ABSOLUTE, 16)
|
||||
-- t:addColumn("Type", GUI.SIZE_POLICY_ABSOLUTE, 10)
|
||||
|
||||
-- local colors1 = {
|
||||
-- defaultBackground = nil,
|
||||
-- defaultText = 0x3C3C3C,
|
||||
-- alternativeBackground = 0xE1E1E1,
|
||||
-- alternativeText = 0x3C3C3C,
|
||||
-- selectionBackground = 0xCC2440,
|
||||
-- selectionText = 0xFFFFFF,
|
||||
-- }
|
||||
|
||||
-- local colors2 = {}
|
||||
-- for key, value in pairs(colors1) do
|
||||
-- colors2[key] = value
|
||||
-- end
|
||||
-- colors2.defaultText, colors2.alternativeText = 0xA5A5A5, 0xA5A5A5
|
||||
|
||||
-- for i = 1, 10 do
|
||||
-- t:addRow(
|
||||
-- GUI.tableTextCell(colors1, "Ehehehe " .. i),
|
||||
-- GUI.tableTextCell(colors2, "12.02.2018"),
|
||||
-- GUI.tableTextCell(colors2, "114.23 KB"),
|
||||
-- GUI.tableTextCell(colors2, ".lua")
|
||||
-- )
|
||||
-- end
|
||||
|
||||
-- workspace:draw()
|
||||
-- workspace:start()
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
return GUI
|
||||
|
||||
1696
Libraries/System.lua
1696
Libraries/System.lua
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,7 @@
|
||||
closeAllWindows = "Close all windows",
|
||||
closeWindow = "Close",
|
||||
newWindow = "New window",
|
||||
launch = "Launch",
|
||||
launchWithArguments = "Launch with arguments",
|
||||
dontShowAnymore = "Don't show again",
|
||||
newName = "New name",
|
||||
@ -34,14 +35,14 @@
|
||||
file = "File",
|
||||
notExists = "not exists",
|
||||
alreadyExists = "already exists",
|
||||
inDirectory = "in directory",
|
||||
inDirectory = "in folder",
|
||||
needReplace = "Replace it?",
|
||||
yes = "Yes",
|
||||
no = "No",
|
||||
cancel = "Cancel",
|
||||
open = "Open",
|
||||
applyToAll = "Apply to all",
|
||||
toDirectory = "to directory",
|
||||
toDirectory = "to folder",
|
||||
copying = "Copying",
|
||||
faylaBlyad = "file",
|
||||
|
||||
@ -50,6 +51,7 @@
|
||||
type = "Type",
|
||||
size = "Size",
|
||||
date = "Date",
|
||||
name = "Name",
|
||||
path = "Path",
|
||||
folder = "Folder",
|
||||
unknown = "Unknown",
|
||||
@ -101,7 +103,7 @@
|
||||
shortcutIsCorrupted = "Shortcut is linked to non-existent file",
|
||||
sortAutomatically = "Align to grid",
|
||||
onDesktop = "On desktop",
|
||||
inCurrentDirectory = "In current directory",
|
||||
inCurrentDirectory = "In current folder",
|
||||
|
||||
errorWhileRunningProgram = "Error while running ",
|
||||
sendedFeedback = "Feedback was sent",
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
closeAllWindows = "Fermez toutes les fenêtres",
|
||||
closeWindow = "Fermer",
|
||||
newWindow = "Nouvelle fenetre",
|
||||
launch = "Lancement",
|
||||
launchWithArguments = "Lancement avec des arguments",
|
||||
dontShowAnymore = "Ne plus afficher",
|
||||
newName = "Renommé",
|
||||
@ -50,6 +51,7 @@
|
||||
type = "Type",
|
||||
size = "Taille",
|
||||
date = "Date",
|
||||
name = "Prénom",
|
||||
path = "Chemin d'accès",
|
||||
folder = "Dossier",
|
||||
unknown = "Inconnu",
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
closeAllWindows = "Alle Fenster schließen",
|
||||
closeWindow = "Schließen",
|
||||
newWindow = "Neues Fenster",
|
||||
launch = "Starten",
|
||||
launchWithArguments = "Starten mit Argumenten",
|
||||
dontShowAnymore = "Nicht wieder anzeigen",
|
||||
newName = "Neuer name",
|
||||
@ -50,6 +51,7 @@
|
||||
type = "Art",
|
||||
size = "Größe",
|
||||
date = "Datum",
|
||||
name = "Name",
|
||||
path = "Pfad",
|
||||
folder = "Ordner",
|
||||
unknown = "Unbekannt",
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
closeAllWindows = "CHIUDI tutte le finestre",
|
||||
closeWindow = "Vicino",
|
||||
newWindow = "Nuova finestra",
|
||||
launch = "Avvia",
|
||||
launchWithArguments = "Avvia con argomenti",
|
||||
dontShowAnymore = "Non farti più vedere.",
|
||||
newName = "Nuovo nome",
|
||||
@ -50,6 +51,7 @@
|
||||
type = "Tipo",
|
||||
size = "Dimensione",
|
||||
date = "Data",
|
||||
name = "Nome",
|
||||
path = "Percorso",
|
||||
folder = "Cartella",
|
||||
unknown = "Sconosciuto",
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
closeAllWindows = "Закрыть все окна",
|
||||
closeWindow = "Закрыть",
|
||||
newWindow = "Новое окно",
|
||||
launch = "Запустить",
|
||||
launchWithArguments = "Запустить с аргументами",
|
||||
dontShowAnymore = "Больше не показывать",
|
||||
newName = "Новое имя",
|
||||
@ -50,6 +51,7 @@
|
||||
type = "Тип",
|
||||
size = "Размер",
|
||||
date = "Дата",
|
||||
name = "Имя",
|
||||
path = "Путь",
|
||||
folder = "Папка",
|
||||
unknown = "Неизвестно",
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
closeAllWindows = "Закрити всі вікна",
|
||||
closeWindow = "Закривати",
|
||||
newWindow = "Нове вікно",
|
||||
launch = "Запуск",
|
||||
launchWithArguments = "Запуск з аргументами",
|
||||
dontShowAnymore = "Більше не показувати ",
|
||||
newName = "Нове ім'я",
|
||||
@ -50,6 +51,7 @@
|
||||
type = "Тип",
|
||||
size = "Розмір",
|
||||
date = "Дата",
|
||||
name = "Ім'я",
|
||||
path = "Шлях",
|
||||
folder = "Папка",
|
||||
unknown = "Невідомий",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user