mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Фух, ну, вроде бы всё
This commit is contained in:
parent
d5e50e6928
commit
8399b5ac1b
@ -103,7 +103,7 @@ end
|
|||||||
|
|
||||||
local function setVerticalScroll(value)
|
local function setVerticalScroll(value)
|
||||||
if config.gridMode then
|
if config.gridMode then
|
||||||
local iconsCount = #iconField.children
|
local iconsCount = #iconField.children - 1
|
||||||
local rows = math.ceil((iconsCount - 1) / iconField.iconCount.horizontal)
|
local rows = math.ceil((iconsCount - 1) / iconField.iconCount.horizontal)
|
||||||
local minimumOffset = (rows - 1) * (userSettings.iconHeight + userSettings.iconVerticalSpace) - userSettings.iconVerticalSpace
|
local minimumOffset = (rows - 1) * (userSettings.iconHeight + userSettings.iconVerticalSpace) - userSettings.iconVerticalSpace
|
||||||
|
|
||||||
@ -112,13 +112,13 @@ local function setVerticalScroll(value)
|
|||||||
local delta = iconField.yOffset - value
|
local delta = iconField.yOffset - value
|
||||||
iconField.yOffset = value
|
iconField.yOffset = value
|
||||||
|
|
||||||
local iconsCount, child = #iconField.children
|
|
||||||
|
|
||||||
if iconsCount < 2 then
|
if iconsCount < 2 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, iconsCount do
|
local child
|
||||||
|
|
||||||
|
for i = 2, iconsCount do
|
||||||
child = iconField.children[i]
|
child = iconField.children[i]
|
||||||
|
|
||||||
if child ~= iconField.backgroundObject then
|
if child ~= iconField.backgroundObject then
|
||||||
@ -507,8 +507,6 @@ local function updateIconField()
|
|||||||
updateFileListAndDraw()
|
updateFileListAndDraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local overrideIconFieldEventHandler = iconField.eventHandler
|
|
||||||
|
|
||||||
iconField.eventHandler = function(workspace, self, e1, e2, e3, e4, e5, ...)
|
iconField.eventHandler = function(workspace, self, e1, e2, e3, e4, e5, ...)
|
||||||
if e1 == "scroll" then
|
if e1 == "scroll" then
|
||||||
setVerticalScroll(getVerticalScroll() + (config.gridMode and e5 * 2 or e5))
|
setVerticalScroll(getVerticalScroll() + (config.gridMode and e5 * 2 or e5))
|
||||||
@ -527,8 +525,6 @@ local function updateIconField()
|
|||||||
updateSidebar()
|
updateSidebar()
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
else
|
|
||||||
overrideIconFieldEventHandler(workspace, self, e1, e2, e3, e4, e5, ...)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1060,11 +1060,12 @@ local function iconFieldIconEventHandler(workspace, icon, e1, e2, e3, e4, e5, ..
|
|||||||
icon.lastTouchY = e4
|
icon.lastTouchY = e4
|
||||||
|
|
||||||
workspace.focusedObject = iconField
|
workspace.focusedObject = iconField
|
||||||
workspace.capturedObject = icon
|
|
||||||
|
|
||||||
icon:moveToFront()
|
icon:moveToFront()
|
||||||
|
|
||||||
if e5 == 0 then
|
if e5 == 0 then
|
||||||
|
workspace.capturedObject = icon
|
||||||
|
|
||||||
iconDeselectAndSelect(icon)
|
iconDeselectAndSelect(icon)
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
@ -1271,7 +1272,7 @@ local function iconFieldCheckSelection(iconField)
|
|||||||
if selection and selection.x2 then
|
if selection and selection.x2 then
|
||||||
local child, xCenter, yCenter
|
local child, xCenter, yCenter
|
||||||
|
|
||||||
for i = 1, #iconField.children do
|
for i = 2, #iconField.children do
|
||||||
child = iconField.children[i]
|
child = iconField.children[i]
|
||||||
|
|
||||||
xCenter, yCenter = child.x + userSettings.iconWidth / 2, child.y + userSettings.iconHeight / 2
|
xCenter, yCenter = child.x + userSettings.iconWidth / 2, child.y + userSettings.iconHeight / 2
|
||||||
@ -1342,7 +1343,6 @@ local function iconFieldUpdateFileList(iconField)
|
|||||||
|
|
||||||
anyIconFieldAddIcon(iconField, icon)
|
anyIconFieldAddIcon(iconField, icon)
|
||||||
|
|
||||||
icon.ignoresCapturedObject = true
|
|
||||||
icon.eventHandler = iconFieldIconEventHandler
|
icon.eventHandler = iconFieldIconEventHandler
|
||||||
|
|
||||||
iconField:addChild(icon)
|
iconField:addChild(icon)
|
||||||
@ -1356,7 +1356,7 @@ local function iconFieldUpdateFileList(iconField)
|
|||||||
iconField.iconCount.total = iconField.iconCount.horizontal * iconField.iconCount.vertical
|
iconField.iconCount.total = iconField.iconCount.horizontal * iconField.iconCount.vertical
|
||||||
|
|
||||||
-- Clearing eblo
|
-- Clearing eblo
|
||||||
iconField:removeChildren()
|
iconField:removeChildren(2)
|
||||||
|
|
||||||
-- Updating icon config if possible
|
-- Updating icon config if possible
|
||||||
if iconField.iconConfigEnabled then
|
if iconField.iconConfigEnabled then
|
||||||
@ -1390,11 +1390,11 @@ local function iconFieldUpdateFileList(iconField)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #configList > 0 then
|
if #configList > 0 then
|
||||||
for i = 1, #iconField.children do
|
for i = 2, #iconField.children do
|
||||||
y = math.max(y, iconField.children[i].localY)
|
y = math.max(y, iconField.children[i].localY)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #iconField.children do
|
for i = 2, #iconField.children do
|
||||||
if iconField.children[i].localY == y then
|
if iconField.children[i].localY == y then
|
||||||
x = math.max(x, iconField.children[i].localX)
|
x = math.max(x, iconField.children[i].localX)
|
||||||
end
|
end
|
||||||
@ -1728,7 +1728,7 @@ end
|
|||||||
local function gridIconFieldGetSelectedIcons(iconField)
|
local function gridIconFieldGetSelectedIcons(iconField)
|
||||||
local selectedIcons, icon = {}
|
local selectedIcons, icon = {}
|
||||||
|
|
||||||
for i = 1, #iconField.children do
|
for i = 2, #iconField.children do
|
||||||
icon = iconField.children[i]
|
icon = iconField.children[i]
|
||||||
|
|
||||||
if icon.selected then
|
if icon.selected then
|
||||||
@ -1739,17 +1739,22 @@ local function gridIconFieldGetSelectedIcons(iconField)
|
|||||||
return selectedIcons
|
return selectedIcons
|
||||||
end
|
end
|
||||||
|
|
||||||
local function gridIconFieldEventHandler(workspace, iconField, e1, e2, e3, e4, e5, ...)
|
local function gridIconFieldBackgroundObjectEventHandler(workspace, backgroundObject, e1, e2, e3, e4, e5, ...)
|
||||||
if e1 == "touch" then
|
if e1 == "touch" then
|
||||||
|
local iconField = backgroundObject.parent
|
||||||
|
|
||||||
workspace.focusedObject = iconField
|
workspace.focusedObject = iconField
|
||||||
workspace.capturedObject = iconField
|
|
||||||
|
|
||||||
if e5 == 0 then
|
if e5 == 0 then
|
||||||
|
workspace.capturedObject = backgroundObject
|
||||||
|
|
||||||
iconField:clearSelection()
|
iconField:clearSelection()
|
||||||
|
|
||||||
iconField.selection = {
|
iconField.selection = {
|
||||||
x1Raw = e3,
|
x1Raw = e3,
|
||||||
y1Raw = e4
|
y1Raw = e4
|
||||||
}
|
}
|
||||||
|
|
||||||
iconFieldCheckSelection(iconField)
|
iconFieldCheckSelection(iconField)
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
@ -1757,7 +1762,8 @@ local function gridIconFieldEventHandler(workspace, iconField, e1, e2, e3, e4, e
|
|||||||
iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif e1 == "drag" then
|
elseif e1 == "drag" and workspace.capturedObject == backgroundObject then
|
||||||
|
local iconField = backgroundObject.parent
|
||||||
local selection = iconField.selection
|
local selection = iconField.selection
|
||||||
|
|
||||||
if not selection then
|
if not selection then
|
||||||
@ -1771,7 +1777,6 @@ local function gridIconFieldEventHandler(workspace, iconField, e1, e2, e3, e4, e
|
|||||||
selection.y1,
|
selection.y1,
|
||||||
selection.x2,
|
selection.x2,
|
||||||
selection.y2 =
|
selection.y2 =
|
||||||
|
|
||||||
math.ceil(selection.x1Raw),
|
math.ceil(selection.x1Raw),
|
||||||
math.ceil(selection.y1Raw),
|
math.ceil(selection.y1Raw),
|
||||||
math.ceil(selection.x2Raw),
|
math.ceil(selection.x2Raw),
|
||||||
@ -1789,16 +1794,25 @@ local function gridIconFieldEventHandler(workspace, iconField, e1, e2, e3, e4, e
|
|||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
|
|
||||||
elseif e1 == "drop" then
|
elseif e1 == "drop" and workspace.capturedObject == backgroundObject then
|
||||||
workspace.focusedObject = nil
|
workspace.focusedObject = nil
|
||||||
workspace.capturedObject = nil
|
workspace.capturedObject = nil
|
||||||
|
|
||||||
|
local iconField = backgroundObject.parent
|
||||||
|
local selection = iconField.selection
|
||||||
|
|
||||||
|
if not selection or not selection.x2 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
iconField.selection = nil
|
iconField.selection = nil
|
||||||
iconFieldCheckSelection(iconField)
|
iconFieldCheckSelection(iconField)
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
|
|
||||||
elseif e1 == "key_down" then
|
elseif e1 == "key_down" then
|
||||||
|
local iconField = backgroundObject.parent
|
||||||
|
|
||||||
if workspace.focusedObject ~= iconField then
|
if workspace.focusedObject ~= iconField then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -1808,7 +1822,7 @@ local function gridIconFieldEventHandler(workspace, iconField, e1, e2, e3, e4, e
|
|||||||
-- Если при нажатии энтера была выделенна ровно одна иконка, она попытается открыться
|
-- Если при нажатии энтера была выделенна ровно одна иконка, она попытается открыться
|
||||||
local icon, selectedIcon
|
local icon, selectedIcon
|
||||||
|
|
||||||
for i = 1, #iconField.children do
|
for i = 2, #iconField.children do
|
||||||
icon = iconField.children[i]
|
icon = iconField.children[i]
|
||||||
|
|
||||||
if icon.selected then
|
if icon.selected then
|
||||||
@ -1894,6 +1908,7 @@ function system.gridIconField(x, y, width, height, xOffset, yOffset, path, defau
|
|||||||
selectionFrame = selectionFrameColor,
|
selectionFrame = selectionFrameColor,
|
||||||
selectionTransparency = selectionTransparency,
|
selectionTransparency = selectionTransparency,
|
||||||
}
|
}
|
||||||
|
|
||||||
iconField.iconConfigEnabled = false
|
iconField.iconConfigEnabled = false
|
||||||
iconField.xOffset = xOffset
|
iconField.xOffset = xOffset
|
||||||
iconField.initialYOffset = yOffset
|
iconField.initialYOffset = yOffset
|
||||||
@ -1901,15 +1916,26 @@ function system.gridIconField(x, y, width, height, xOffset, yOffset, path, defau
|
|||||||
iconField.iconCount = {}
|
iconField.iconCount = {}
|
||||||
iconField.iconConfig = {}
|
iconField.iconConfig = {}
|
||||||
|
|
||||||
|
iconField.clearSelection = iconFieldClearSelection
|
||||||
|
iconField.loadIconConfig = iconFieldLoadIconConfig
|
||||||
|
iconField.saveIconConfig = iconFieldSaveIconConfig
|
||||||
|
iconField.deleteIconConfig = iconFieldDeleteIconConfig
|
||||||
|
iconField.updateFileList = iconFieldUpdateFileList
|
||||||
|
iconField.getSelectedIcons = gridIconFieldGetSelectedIcons
|
||||||
|
|
||||||
local overrideDraw = iconField.draw
|
local overrideDraw = iconField.draw
|
||||||
iconField.draw = function(...)
|
iconField.draw = function(iconField)
|
||||||
overrideDraw(...)
|
overrideDraw(iconField)
|
||||||
|
|
||||||
|
iconField.backgroundObject.width, iconField.backgroundObject.height = iconField.width, iconField.height
|
||||||
|
|
||||||
local selection = iconField.selection
|
local selection = iconField.selection
|
||||||
|
|
||||||
if selection and iconField.selection.x2 then
|
if not selection or not selection.x2 then
|
||||||
local y1, y2
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local y1, y2
|
||||||
if selection.y1Raw < selection.y2Raw then
|
if selection.y1Raw < selection.y2Raw then
|
||||||
y1, y2 = selection.y1 + iconField.yOffset - iconField.initialYOffset, selection.y2
|
y1, y2 = selection.y1 + iconField.yOffset - iconField.initialYOffset, selection.y2
|
||||||
else
|
else
|
||||||
@ -1922,16 +1948,9 @@ function system.gridIconField(x, y, width, height, xOffset, yOffset, path, defau
|
|||||||
screen.drawFrame(selection.x1, y1, selection.x2 - selection.x1 + 1, y2 - y1 + 1, iconField.colors.selectionFrame)
|
screen.drawFrame(selection.x1, y1, selection.x2 - selection.x1 + 1, y2 - y1 + 1, iconField.colors.selectionFrame)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
iconField.clearSelection = iconFieldClearSelection
|
iconField.backgroundObject = iconField:addChild(GUI.object(1, 1, width, height))
|
||||||
iconField.loadIconConfig = iconFieldLoadIconConfig
|
iconField.backgroundObject.eventHandler = gridIconFieldBackgroundObjectEventHandler
|
||||||
iconField.saveIconConfig = iconFieldSaveIconConfig
|
|
||||||
iconField.deleteIconConfig = iconFieldDeleteIconConfig
|
|
||||||
iconField.updateFileList = iconFieldUpdateFileList
|
|
||||||
|
|
||||||
iconField.getSelectedIcons = gridIconFieldGetSelectedIcons
|
|
||||||
iconField.eventHandler = gridIconFieldEventHandler
|
|
||||||
|
|
||||||
anyIconFieldAddInfo(iconField, path)
|
anyIconFieldAddInfo(iconField, path)
|
||||||
|
|
||||||
@ -1941,7 +1960,7 @@ end
|
|||||||
local function listIconFieldGetSelectedIcons(iconField)
|
local function listIconFieldGetSelectedIcons(iconField)
|
||||||
local selectedIcons, icon = {}
|
local selectedIcons, icon = {}
|
||||||
|
|
||||||
for i = 1, #iconField.children do
|
for i = 2, #iconField.children do
|
||||||
icon = iconField.children[i]
|
icon = iconField.children[i]
|
||||||
|
|
||||||
if icon.selected and icon.path then
|
if icon.selected and icon.path then
|
||||||
@ -2499,8 +2518,7 @@ local function dockIconEventHandler(workspace, icon, e1, e2, e3, e4, e5, e6, ...
|
|||||||
end
|
end
|
||||||
|
|
||||||
function system.updateDesktop()
|
function system.updateDesktop()
|
||||||
desktopIconField = workspace:addChild(
|
desktopIconField = workspace:addChild(system.gridIconField(
|
||||||
system.gridIconField(
|
|
||||||
1, 2, 1, 1, 3, 2,
|
1, 2, 1, 1, 3, 2,
|
||||||
paths.user.desktop,
|
paths.user.desktop,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
@ -2508,8 +2526,7 @@ function system.updateDesktop()
|
|||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
0xD2D2D2,
|
0xD2D2D2,
|
||||||
0.5
|
0.5
|
||||||
)
|
))
|
||||||
)
|
|
||||||
|
|
||||||
desktopIconField.iconConfigEnabled = true
|
desktopIconField.iconConfigEnabled = true
|
||||||
|
|
||||||
@ -2943,7 +2960,6 @@ end
|
|||||||
function system.updateWorkspace()
|
function system.updateWorkspace()
|
||||||
-- Clearing workspace
|
-- Clearing workspace
|
||||||
workspace:removeChildren()
|
workspace:removeChildren()
|
||||||
|
|
||||||
workspace.ignoresCapturedObject = true
|
workspace.ignoresCapturedObject = true
|
||||||
|
|
||||||
-- Creating desktop background object
|
-- Creating desktop background object
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user