Navigation/scroll fix for Finder

This commit is contained in:
IgorTimofeev 2023-10-09 19:09:39 +03:00
parent 6c8ad59cda
commit c8c9745df6
3 changed files with 56 additions and 34 deletions

View File

@ -321,6 +321,7 @@ end
local function tryToDownload(...) local function tryToDownload(...)
local success, reason = internet.download(...) local success, reason = internet.download(...)
if not success then if not success then
GUI.alert(reason) GUI.alert(reason)
end end
@ -666,7 +667,8 @@ local function addApplicationInfo(container, publication, limit)
container.rating = container:addChild(newRatingWidget(13, 4, publication.average_rating and number.round(publication.average_rating) or 0)) container.rating = container:addChild(newRatingWidget(13, 4, publication.average_rating and number.round(publication.average_rating) or 0))
local updateState = getUpdateState(publication.file_id, publication.version) local updateState = getUpdateState(publication.file_id, publication.version)
container.downloadButton = container:addChild(GUI.adaptiveRoundedButton(13, 5, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x969696, 0xFFFFFF, updateState == 4 and localization.installed or updateState == 3 and localization.update or localization.install))
container.downloadButton = container:addChild(GUI.adaptiveRoundedButton(13, 5, 2, 0, 0xC3C3C3, 0xFFFFFF, 0x969696, 0xFFFFFF, updateState == 4 and localization.installed or updateState == 3 and localization.update or localization.install))
container.downloadButton.onTouch = function() container.downloadButton.onTouch = function()
download(publication) download(publication)
@ -677,8 +679,7 @@ local function addApplicationInfo(container, publication, limit)
container.downloadButton.disabled = updateState == 4 container.downloadButton.disabled = updateState == 4
if updateState > 2 then if updateState > 2 then
container.downloadButton.width = container.downloadButton.width + 1 container:addChild(GUI.adaptiveRoundedButton(container.downloadButton.localX + container.downloadButton.width - 2, container.downloadButton.localY, 1, 0, 0xF0F0F0, 0x969696, 0x969696, 0xFFFFFF, " x")).onTouch = function()
container:addChild(GUI.adaptiveRoundedButton(container.downloadButton.localX + container.downloadButton.width, container.downloadButton.localY, 1, 0, 0xF0F0F0, 0x969696, 0x969696, 0xFFFFFF, "x")).onTouch = function()
local versionsTable = getVersionsTable(publication.file_id) local versionsTable = getVersionsTable(publication.file_id)
filesystem.remove(getApplicationPathFromVersions(versionsTable[publication.file_id].path)) filesystem.remove(getApplicationPathFromVersions(versionsTable[publication.file_id].path))
filesystem.remove(paths.user.desktop .. publication.publication_name .. ".lnk") filesystem.remove(paths.user.desktop .. publication.publication_name .. ".lnk")
@ -688,6 +689,8 @@ local function addApplicationInfo(container, publication, limit)
computer.pushSignal("system", "updateFileList") computer.pushSignal("system", "updateFileList")
saveVersions() saveVersions()
end end
container.downloadButton:moveToFront()
end end
end end
@ -1030,7 +1033,7 @@ local function settings()
local buttonsLayout = layout:addChild(newButtonsLayout(1, 1, layout.width, 2)) local buttonsLayout = layout:addChild(newButtonsLayout(1, 1, layout.width, 2))
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.changePassword)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.changePassword)).onTouch = function()
addAccountShit(false, false, true) addAccountShit(false, false, true)
end end
@ -1068,11 +1071,11 @@ local function settings()
end end
local buttonsLayout = layout:addChild(newButtonsLayout(1, 1, layout.width, 2)) local buttonsLayout = layout:addChild(newButtonsLayout(1, 1, layout.width, 2))
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.open)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.open)).onTouch = function()
newPublicationInfo(result[comboBox.selectedItem].file_id) newPublicationInfo(result[comboBox.selectedItem].file_id)
end end
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.edit)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.edit)).onTouch = function()
local result = fieldAPIRequest("result", "publication", { local result = fieldAPIRequest("result", "publication", {
file_id = result[comboBox.selectedItem].file_id, file_id = result[comboBox.selectedItem].file_id,
language_id = config.language_id, language_id = config.language_id,
@ -1262,8 +1265,6 @@ newPublicationInfo = function(file_id)
}) })
if publication then if publication then
workspace:draw()
local reviews = fieldAPIRequest("result", "reviews", { local reviews = fieldAPIRequest("result", "reviews", {
file_id = file_id, file_id = file_id,
offset = 0, offset = 0,
@ -1324,15 +1325,15 @@ newPublicationInfo = function(file_id)
local buttonsLayout = ratingsContainer:addChild(GUI.layout(1, y, ratingsContainer.width, 3, 1, 1)) local buttonsLayout = ratingsContainer:addChild(GUI.layout(1, y, ratingsContainer.width, 3, 1, 1))
if publication.user_name == user.name then if publication.user_name == user.name then
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.edit)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.edit)).onTouch = function()
editPublication(publication) editPublication(publication)
end end
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.remove)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.remove)).onTouch = function()
deletePublication(publication) deletePublication(publication)
end end
else else
buttonsLayout:addChild(GUI.adaptiveRoundedButton(2, 1, 1, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.newMessageToDeveloper)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(2, 1, 2, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.newMessageToDeveloper)).onTouch = function()
dialogGUI(publication.user_name) dialogGUI(publication.user_name)
end end
@ -1346,7 +1347,7 @@ newPublicationInfo = function(file_id)
end end
end end
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, existingReviewText and localization.changeReview or localization.writeReview)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, existingReviewText and localization.changeReview or localization.writeReview)).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, existingReviewText and localization.changeReview or localization.writeReview) local container = GUI.addBackgroundContainer(workspace, true, true, existingReviewText and localization.changeReview or localization.writeReview)
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xFFFFFF, 0x696969, 0xB4B4B4, 0xFFFFFF, 0x2D2D2D, existingReviewText or "", localization.writeReviewHere)) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xFFFFFF, 0x696969, 0xB4B4B4, 0xFFFFFF, 0x2D2D2D, existingReviewText or "", localization.writeReviewHere))
@ -1549,6 +1550,8 @@ newPublicationInfo = function(file_id)
layout:update() layout:update()
layout.height = layout.children[#layout.children].localY + layout.children[#layout.children].height - 1 layout.height = layout.children[#layout.children].localY + layout.children[#layout.children].height - 1
workspace:draw()
end end
end end
end end
@ -1952,7 +1955,7 @@ updateFileList = function(category_id, updates)
orderDirectionComboBox.onItemSelected = orderByComboBox.onItemSelected orderDirectionComboBox.onItemSelected = orderByComboBox.onItemSelected
if user.token then if user.token then
layout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0x696969, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.publish)).onTouch = function() layout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0x696969, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.publish)).onTouch = function()
editPublication(nil, category_id) editPublication(nil, category_id)
end end
end end
@ -1969,7 +1972,7 @@ updateFileList = function(category_id, updates)
updateFileList(category_id, updates) updateFileList(category_id, updates)
end end
local backButton = navigationLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xFFFFFF, 0x696969, 0xA5A5A5, 0xFFFFFF, "<")) local backButton = navigationLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xFFFFFF, 0x696969, 0xA5A5A5, 0xFFFFFF, "<"))
backButton.colors.disabled.background = 0xE1E1E1 backButton.colors.disabled.background = 0xE1E1E1
backButton.colors.disabled.text = 0xC3C3C3 backButton.colors.disabled.text = 0xC3C3C3
backButton.disabled = currentPage == 0 backButton.disabled = currentPage == 0
@ -1978,7 +1981,7 @@ updateFileList = function(category_id, updates)
end end
navigationLayout:addChild(GUI.text(1, 1, 0x696969, localization.page .. " " .. (currentPage + 1))) navigationLayout:addChild(GUI.text(1, 1, 0x696969, localization.page .. " " .. (currentPage + 1)))
local nextButton = navigationLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 1, 0, 0xFFFFFF, 0x696969, 0xA5A5A5, 0xFFFFFF, ">")) local nextButton = navigationLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xFFFFFF, 0x696969, 0xA5A5A5, 0xFFFFFF, ">"))
nextButton.colors.disabled = backButton.colors.disabled nextButton.colors.disabled = backButton.colors.disabled
nextButton.disabled = #result <= appsPerPage nextButton.disabled = #result <= appsPerPage
nextButton.onTouch = function() nextButton.onTouch = function()

View File

@ -4854,6 +4854,29 @@ local function tableDraw(self)
layoutDraw(self) layoutDraw(self)
end end
local function tableGetVerticalScroll(self)
local horizontalMargin, verticalMargin = self:getMargin(1, 2)
return verticalMargin
end
local function tableSetVerticalScroll(self, value)
local horizontalMargin = self:getMargin(1, 2)
local columnCount = #self.columnSizes
local maxValue = -self.itemHeight * (#self.children - columnCount) / columnCount + 1
for i = 1, columnCount do
self:setMargin(i, 2, horizontalMargin,
math.max(
maxValue,
math.min(
0,
value
)
)
)
end
end
function GUI.tableEventHandler(workspace, self, e1, e2, e3, e4, e5, ...) function GUI.tableEventHandler(workspace, self, e1, e2, e3, e4, e5, ...)
if e1 == "touch" then if e1 == "touch" then
local itemTouched = false local itemTouched = false
@ -4868,22 +4891,9 @@ function GUI.tableEventHandler(workspace, self, e1, e2, e3, e4, e5, ...)
if not itemTouched then if not itemTouched then
self.onBackgroundTouch(workspace, self, e1, e2, e3, e4, e5, ...) self.onBackgroundTouch(workspace, self, e1, e2, e3, e4, e5, ...)
end end
elseif e1 == "scroll" then elseif e1 == "scroll" then
local columnCount = #self.columnSizes self:setVerticalScroll(self:getVerticalScroll() + e5)
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() workspace:draw()
end end
end end
@ -4902,6 +4912,8 @@ function GUI.table(x, y, width, height, itemHeight, backgroundColor, headerBackg
table.addColumn = tableAddColumn table.addColumn = tableAddColumn
table.addRow = tableAddRow table.addRow = tableAddRow
table.setVerticalScroll = tableSetVerticalScroll
table.getVerticalScroll = tableGetVerticalScroll
table.clear = tableClear table.clear = tableClear
table.draw = tableDraw table.draw = tableDraw
table.eventHandler = GUI.tableEventHandler table.eventHandler = GUI.tableEventHandler

View File

@ -1215,7 +1215,7 @@ local function iconFieldUpdateFileList(iconField)
end end
-- Updating sizes -- Updating sizes
iconField.yOffset = iconField.yOffsetInitial iconField.yOffset = iconField.initialYOffset
iconField.backgroundObject.width, iconField.backgroundObject.height = iconField.width, iconField.height iconField.backgroundObject.width, iconField.backgroundObject.height = iconField.width, iconField.height
@ -1712,9 +1712,9 @@ local function iconFieldBackgroundObjectDraw(object)
local y1, y2 local y1, y2
if selection.y1Raw < selection.y2Raw then if selection.y1Raw < selection.y2Raw then
y1, y2 = selection.y1 + object.parent.yOffset - object.parent.yOffsetInitial, selection.y2 y1, y2 = selection.y1 + object.parent.yOffset - object.parent.initialYOffset, selection.y2
else else
y1, y2 = selection.y1, selection.y2 + object.parent.yOffset - object.parent.yOffsetInitial y1, y2 = selection.y1, selection.y2 + object.parent.yOffset - object.parent.initialYOffset
end end
if userSettings.interfaceTransparencyEnabled then if userSettings.interfaceTransparencyEnabled then
@ -1753,6 +1753,12 @@ local function anyIconFieldAddInfo(iconField, path)
end end
end end
local function gridIconFieldSetVerticalScroll(iconField, value)
iconField.verticalScroll = math.max(
)
end
function system.gridIconField(x, y, width, height, xOffset, yOffset, path, defaultTextColor, selectionBackgroundColor, selectionTextColor, selectionFrameColor, selectionTransparency) function system.gridIconField(x, y, width, height, xOffset, yOffset, path, defaultTextColor, selectionBackgroundColor, selectionTextColor, selectionFrameColor, selectionTransparency)
local iconField = GUI.container(x, y, width, height) local iconField = GUI.container(x, y, width, height)
@ -1765,7 +1771,7 @@ function system.gridIconField(x, y, width, height, xOffset, yOffset, path, defau
} }
iconField.iconConfigEnabled = false iconField.iconConfigEnabled = false
iconField.xOffset = xOffset iconField.xOffset = xOffset
iconField.yOffsetInitial = yOffset iconField.initialYOffset = yOffset
iconField.yOffset = yOffset iconField.yOffset = yOffset
iconField.iconCount = {} iconField.iconCount = {}
iconField.iconConfig = {} iconField.iconConfig = {}
@ -2791,6 +2797,7 @@ function system.updateDesktop()
end end
local lastWindowHandled local lastWindowHandled
workspace.eventHandler = function(workspace, object, e1, e2, e3, e4) workspace.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "key_down" then if e1 == "key_down" then
local windowCount = #desktopWindowsContainer.children local windowCount = #desktopWindowsContainer.children