Добавил поддержку иконок для контекстного меню

This commit is contained in:
IgorTimofeev 2024-01-03 15:12:36 +03:00
parent 11d83f3e2d
commit edff33979a
11 changed files with 277 additions and 199 deletions

View File

@ -7,7 +7,7 @@ local system = require("System")
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
local localization = system.getSystemLocalization()
menu:addItem(localization.print3D, not component.isAvailable("printer3d")).onTouch = function()
menu:addItem("🖨", localization.print3D, not component.isAvailable("printer3d")).onTouch = function()
system.execute(paths.system.applicationPrint3D, icon.path, "-p")
end

View File

@ -173,11 +173,11 @@ window.actionButtons.localY = 1
local fileItem = menu:addContextMenuItem(localization.file)
local newItem = fileItem:addItem(localization.new, false, "^N")
local openItem = fileItem:addItem(localization.open, false, "^O")
local newItem = fileItem:addItem("", localization.new, false, "^N")
local openItem = fileItem:addItem("📂", localization.open, false, "^O")
fileItem:addSeparator()
local saveItem = fileItem:addItem(localization.save, true, "^S")
local saveAsItem = fileItem:addItem(localization.saveAs, false, "^⇧S")
local saveItem = fileItem:addItem("💾", localization.save, true, "^S")
local saveAsItem = fileItem:addItem("🖪", localization.saveAs, false, "^⇧S")
menu:addItem(localization.help).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, localization.help)

View File

@ -15,19 +15,20 @@ local config = filesystem.exists(configPath) and filesystem.readTable(configPath
local colors = {
background = 0xF0F0F0,
backgroundText = 0x555555,
panel = 0x2D2D2D,
panelText = 0x999999,
panelSeleciton = 0x444444,
panelSelecitonText = 0xE1E1E1,
backgroundText = 0x5A5A5A,
panel = 0x1E1E1E,
panelText = 0x5A5A5A,
panelSelection = 0x3C3C3C,
panelSelectionText = 0xE1E1E1,
selectionFrom = 0x990000,
selectionTo = 0x990000,
selectionText = 0xFFFFFF,
selectionText = 0xE1E1E1,
selectionBetween = 0xD2D2D2,
selectionBetweenText = 0x000000,
separator = 0xCCCCCC,
separator = 0xE1E1E1,
title = 0x2D2D2D,
titleBackground = 0x990000,
titleText = 0xFFFFFF,
titleText = 0xE1E1E1,
titleText2 = 0xE1E1E1,
}
@ -112,7 +113,7 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5)
if e5 == 1 then
local menu = GUI.addContextMenu(workspace, math.ceil(e3), math.ceil(e4))
menu:addItem("Select all").onTouch = function()
menu:addItem("", "Select all").onTouch = function()
selection.from = 1
selection.to = #bytes
@ -121,7 +122,7 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5)
menu:addSeparator()
menu:addItem("Edit").onTouch = function()
menu:addItem("🖊", "Edit").onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, "Fill byte range [" .. selection.from .. "; " .. selection.to .. "]")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, string.format("%02X" , bytes[selection.from]), "Type byte value"))
@ -141,7 +142,7 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5)
workspace:draw()
end
menu:addItem("Insert").onTouch = function()
menu:addItem("", "Insert").onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, "Insert bytes at position " .. selection.from .. "")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, "", "Type byte values separated by space", true))
@ -171,7 +172,7 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5)
menu:addSeparator()
menu:addItem("Delete").onTouch = function()
menu:addItem("🗑", "Delete").onTouch = function()
for i = selection.from, selection.to do
table.remove(bytes, selection.from)
end
@ -235,7 +236,7 @@ end
------------------------------------------------------------------------------------------------------------------
window:addChild(GUI.panel(1, 1, window.width, 3, 0x3C3C3C)):moveToBack()
window:addChild(GUI.panel(1, 1, window.width, 3, colors.title)):moveToBack()
local byteField = window:addChild(newByteField(13, 6, 64, 4, 2, false))
local charField = window:addChild(newByteField(byteField.localX + byteField.width + 3, 6, 16, 1, 2, true))
@ -258,8 +259,8 @@ verticalCounter.draw = function(object)
local textColor = colors.panelText
if index > selection.from and index < selection.to then
screen.drawRectangle(object.x, object.y + y - 1, object.width, 2, colors.panelSeleciton, colors.panelSelecitonText, " ")
textColor = colors.panelSelecitonText
screen.drawRectangle(object.x, object.y + y - 1, object.width, 2, colors.panelSelection, colors.panelSelectionText, " ")
textColor = colors.panelSelectionText
end
if selection.from >= index and selection.from <= index + 15 or selection.to >= index and selection.to <= index + 15 then
@ -280,8 +281,8 @@ window:addChild(GUI.object(13, 4, 62, 1)).draw = function(object)
for x = 1, object.width, 4 do
local textColor = colors.panelText
if counter + 1 > restFrom and counter + 1 < restTo then
screen.drawRectangle(object.x + x - 2, object.y, 4, 1, colors.panelSeleciton, colors.selectionText, " ")
textColor = colors.panelSelecitonText
screen.drawRectangle(object.x + x - 2, object.y, 4, 1, colors.panelSelection, colors.selectionText, " ")
textColor = colors.panelSelectionText
elseif restFrom == counter + 1 or restTo == counter + 1 then
screen.drawRectangle(object.x + x - 2, object.y, 4, 1, colors.selectionFrom, colors.selectionText, " ")
textColor = colors.selectionText
@ -312,8 +313,8 @@ titleTextBox.localX = math.floor(window.width / 2 - titleTextBox.width / 2)
titleTextBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
titleTextBox.eventHandler = nil
local saveFileButton = window:addChild(GUI.adaptiveRoundedButton(titleTextBox.localX - 11, 2, 2, 0, colors.panel, colors.panelSelecitonText, colors.panelSelecitonText, colors.panel, "Save"))
local openFileButton = window:addChild(GUI.adaptiveRoundedButton(saveFileButton.localX - 10, 2, 2, 0, colors.panel, colors.panelSelecitonText, colors.panelSelecitonText, colors.panel, "Open"))
local saveFileButton = window:addChild(GUI.adaptiveRoundedButton(titleTextBox.localX - 11, 2, 2, 0, colors.panel, colors.panelSelectionText, colors.panelSelectionText, colors.panel, "Save"))
local openFileButton = window:addChild(GUI.adaptiveRoundedButton(saveFileButton.localX - 10, 2, 2, 0, colors.panel, colors.panelSelectionText, colors.panelSelectionText, colors.panel, "Open"))
------------------------------------------------------------------------------------------------------------------

View File

@ -7,15 +7,15 @@ local system = require("System")
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
local localization = system.getSystemLocalization()
menu:addItem(localization.launch).onTouch = function()
menu:addItem("˃", localization.launch).onTouch = function()
system.execute(icon.path)
end
menu:addItem(localization.launchWithArguments).onTouch = function()
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()
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)
workspace:draw()

View File

@ -1312,68 +1312,68 @@ local function toggleTopToolBar()
end
local function createEditOrRightClickMenu(menu)
menu:addItem(localization.cut, not codeView.selections[1], "^X").onTouch = function()
menu:addItem("", localization.cut, not codeView.selections[1], "^X").onTouch = function()
cut()
end
menu:addItem(localization.copy, not codeView.selections[1], "^C").onTouch = function()
menu:addItem("", localization.copy, not codeView.selections[1], "^C").onTouch = function()
copy()
end
menu:addItem(localization.paste, not clipboard, "^V").onTouch = function()
menu:addItem("", localization.paste, not clipboard, "^V").onTouch = function()
paste(clipboard)
end
menu:addSeparator()
menu:addItem(localization.selectWord).onTouch = function()
menu:addItem("💬", localization.selectWord).onTouch = function()
selectWord()
end
menu:addItem(localization.selectAll, false, "^A").onTouch = function()
menu:addItem("📜", localization.selectAll, false, "^A").onTouch = function()
selectAll()
end
menu:addSeparator()
menu:addItem(localization.comment, false, "^/").onTouch = function()
menu:addItem("//", localization.comment, false, "^/").onTouch = function()
toggleComment()
end
menu:addItem(localization.indent, false, "Tab").onTouch = function()
menu:addItem("", localization.indent, false, "Tab").onTouch = function()
indentOrUnindent(true)
end
menu:addItem(localization.unindent, false, "⇧Tab").onTouch = function()
menu:addItem("", localization.unindent, false, "⇧Tab").onTouch = function()
indentOrUnindent(false)
end
menu:addItem(localization.deleteLine, false, "^Del").onTouch = function()
menu:addItem("", localization.deleteLine, false, "^Del").onTouch = function()
deleteLine(cursorPositionLine)
end
menu:addItem(localization.selectAndPasteColor, false, "^⇧C").onTouch = function()
menu:addItem("🎨", localization.selectAndPasteColor, false, "^⇧C").onTouch = function()
selectAndPasteColor()
end
local subMenu = menu:addSubMenuItem(localization.convertCase)
local subMenu = menu:addSubMenuItem("Aa", localization.convertCase)
subMenu:addItem(localization.toUpperCase, false, "^▲").onTouch = function()
subMenu:addItem("AA", localization.toUpperCase, false, "^▲").onTouch = function()
convertCase("upper")
end
subMenu:addItem(localization.toLowerCase, false, "^▼").onTouch = function()
subMenu:addItem("aa", localization.toLowerCase, false, "^▼").onTouch = function()
convertCase("lower")
end
menu:addSeparator()
menu:addItem(localization.addBreakpoint, false, "F9").onTouch = function()
menu:addItem("", localization.addBreakpoint, false, "F9").onTouch = function()
addBreakpoint()
workspace:draw()
end
menu:addItem(localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function()
menu:addItem("", localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function()
clearBreakpoints()
end
end
@ -1638,31 +1638,32 @@ leftTreeView.onItemSelected = function(path)
end
local fileContextMenu = menu:addContextMenuItem(localization.file)
fileContextMenu:addItem(localization.new, false, "^N").onTouch = function()
fileContextMenu:addItem("", localization.new, false, "^N").onTouch = function()
newFile()
workspace:draw()
end
fileContextMenu:addItem(localization.open, false, "^O").onTouch = function()
fileContextMenu:addItem("📂", localization.open, false, "^O").onTouch = function()
openFileWindow()
end
fileContextMenu:addItem(localization.getFromWeb, not component.isAvailable("internet"), "^U").onTouch = function()
fileContextMenu:addItem("🌍", localization.getFromWeb, not component.isAvailable("internet"), "^U").onTouch = function()
downloadFileFromWeb()
end
fileContextMenu:addSeparator()
saveContextMenuItem = fileContextMenu:addItem(localization.save, not leftTreeView.selectedItem, "^S")
saveContextMenuItem = fileContextMenu:addItem("💾", localization.save, not leftTreeView.selectedItem, "^S")
saveContextMenuItem.onTouch = function()
saveFileWindow()
end
fileContextMenu:addItem(localization.saveAs, false, "^⇧S").onTouch = function()
fileContextMenu:addItem("🖪", localization.saveAs, false, "^⇧S").onTouch = function()
saveFileAsWindow()
end
fileContextMenu:addItem(localization.flashEEPROM, not component.isAvailable("eeprom")).onTouch = function()
fileContextMenu:addItem("", localization.flashEEPROM, not component.isAvailable("eeprom")).onTouch = function()
local container = addBackgroundContainer(localization.flashEEPROM)
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, localization.flashingEEPROM .. "...")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
workspace:draw()
@ -1675,38 +1676,40 @@ end
fileContextMenu:addSeparator()
fileContextMenu:addItem(localization.launchWithArguments, false, "^F5").onTouch = function()
fileContextMenu:addItem("˃", localization.launchWithArguments, false, "^F5").onTouch = function()
launchWithArgumentsWindow()
end
local topMenuEdit = menu:addContextMenuItem(localization.edit)
createEditOrRightClickMenu(topMenuEdit)
local gotoContextMenu = menu:addContextMenuItem(localization.gotoCyka)
gotoContextMenu:addItem(localization.pageUp, false, "PgUp").onTouch = function()
gotoContextMenu:addItem("", localization.pageUp, false, "PgUp").onTouch = function()
pageUp()
end
gotoContextMenu:addItem(localization.pageDown, false, "PgDn").onTouch = function()
gotoContextMenu:addItem("", localization.pageDown, false, "PgDn").onTouch = function()
pageDown()
end
gotoContextMenu:addItem(localization.gotoStart, false, "Home").onTouch = function()
gotoContextMenu:addItem("🏠", localization.gotoStart, false, "Home").onTouch = function()
setCursorPositionToHome()
end
gotoContextMenu:addItem(localization.gotoEnd, false, "End").onTouch = function()
gotoContextMenu:addItem("💀", localization.gotoEnd, false, "End").onTouch = function()
setCursorPositionToEnd()
end
gotoContextMenu:addSeparator()
gotoContextMenu:addItem(localization.gotoLine, false, "^L").onTouch = function()
gotoContextMenu:addItem("", localization.gotoLine, false, "^L").onTouch = function()
gotoLineWindow()
end
local propertiesContextMenu = menu:addContextMenuItem(localization.properties)
propertiesContextMenu:addItem(localization.colorScheme).onTouch = function()
propertiesContextMenu:addItem("🎨", localization.colorScheme).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, false, localization.colorScheme)
local colorSelectorsCount, colorSelectorCountX = 0, 4; for key in pairs(config.syntaxColorScheme) do colorSelectorsCount = colorSelectorsCount + 1 end
@ -1740,7 +1743,7 @@ propertiesContextMenu:addItem(localization.colorScheme).onTouch = function()
workspace:draw()
end
propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function()
propertiesContextMenu:addItem("I", localization.cursorProperties).onTouch = function()
local container = addBackgroundContainer(localization.cursorProperties)
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xC3C3C3, 0x787878, 0x787878, 0xC3C3C3, 0x2D2D2D, config.cursorSymbol, localization.cursorSymbol))
@ -1766,23 +1769,23 @@ propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function(
workspace:draw()
end
propertiesContextMenu:addItem(localization.toggleTopToolBar).onTouch = function()
propertiesContextMenu:addItem("", localization.toggleTopToolBar).onTouch = function()
toggleTopToolBar()
end
propertiesContextMenu:addSeparator()
propertiesContextMenu:addItem(localization.toggleSyntaxHighlight).onTouch = function()
propertiesContextMenu:addItem("Aa", localization.toggleSyntaxHighlight).onTouch = function()
syntaxHighlightingButton.pressed = not syntaxHighlightingButton.pressed
syntaxHighlightingButton.onTouch()
end
propertiesContextMenu:addItem(localization.toggleAutoBrackets, false, "^]").onTouch = function()
propertiesContextMenu:addItem("[]", localization.toggleAutoBrackets, false, "^]").onTouch = function()
config.enableAutoBrackets = not config.enableAutoBrackets
saveConfig()
end
propertiesContextMenu:addItem(localization.toggleAutocompletion, false, "^I").onTouch = function()
propertiesContextMenu:addItem("🔎", localization.toggleAutocompletion, false, "^I").onTouch = function()
toggleEnableAutocompleteDatabase()
end

View File

@ -7,7 +7,7 @@ local system = require("System")
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
local localization = system.getSystemLocalization()
menu:addItem(localization.setAsWallpaper).onTouch = function()
menu:addItem("💻", localization.setAsWallpaper).onTouch = function()
local userSettings = system.getUserSettings()
userSettings.interfaceWallpaperPath = icon.path

View File

@ -484,13 +484,14 @@ window.image.reposition = function()
end
local fileItem = menu:addContextMenuItem(locale.file)
fileItem:addItem(locale.new, false, "^N").onTouch = new
fileItem:addItem("", locale.new, false, "^N").onTouch = new
fileItem:addSeparator()
fileItem:addItem(locale.open, false, "^O").onTouch = open
fileItem:addItem("📂", locale.open, false, "^O").onTouch = open
local fileItemSubMenu = fileItem:addSubMenuItem(locale.openRecent, #config.recentFiles == 0)
for i = 1, #config.recentFiles do
fileItemSubMenu:addItem(text.limit(config.recentFiles[i], 32, "left")).onTouch = function()
loadImage(config.recentFiles[i])
@ -499,7 +500,7 @@ for i = 1, #config.recentFiles do
end
end
fileItem:addItem(locale.openFromURL).onTouch = function()
fileItem:addItem("🌍", locale.openFromURL).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, locale.openFromURL)
container.panel.eventHandler = nil
@ -543,12 +544,12 @@ end
fileItem:addSeparator()
saveItem = fileItem:addItem(locale.save, false, "^S")
saveItem = fileItem:addItem("💾", locale.save, false, "^S")
saveItem.onTouch = function()
save(savePath)
end
fileItem:addItem(locale.saveAs, false, "^⇧S").onTouch = saveAs
fileItem:addItem("🖪", locale.saveAs, false, "^⇧S").onTouch = saveAs
menu:addItem(locale.view).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, locale.view)
@ -571,31 +572,31 @@ end
local imageItem = menu:addContextMenuItem(locale.image)
imageItem:addItem(locale.flipVertical).onTouch = function()
imageItem:addItem("", locale.flipVertical).onTouch = function()
window.image.data = image.flipVertically(window.image.data)
end
imageItem:addItem(locale.flipHorizontal).onTouch = function()
imageItem:addItem("", locale.flipHorizontal).onTouch = function()
window.image.data = image.flipHorizontally(window.image.data)
end
imageItem:addSeparator()
imageItem:addItem(locale.rotate90).onTouch = function()
imageItem:addItem("", locale.rotate90).onTouch = function()
window.image.data = image.rotate(window.image.data, 90)
window.image.width = window.image.data[1]
window.image.height = window.image.data[2]
window.image.reposition()
end
imageItem:addItem(locale.rotate180).onTouch = function()
imageItem:addItem("⤿", locale.rotate180).onTouch = function()
window.image.data = image.rotate(window.image.data, 180)
window.image.width = window.image.data[1]
window.image.height = window.image.data[2]
window.image.reposition()
end
imageItem:addItem(locale.rotate270).onTouch = function()
imageItem:addItem("", locale.rotate270).onTouch = function()
window.image.data = image.rotate(window.image.data, 270)
window.image.width = window.image.data[1]
window.image.height = window.image.data[2]
@ -604,7 +605,7 @@ end
local editItem = menu:addContextMenuItem(locale.edit)
editItem:addItem(locale.hueSaturation).onTouch = function()
editItem:addItem("🎨", locale.hueSaturation).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, locale.hueSaturation)
container.layout:setSpacing(1, 1, 2)
container.panel.eventHandler = nil
@ -628,7 +629,7 @@ editItem:addItem(locale.hueSaturation).onTouch = function()
end
end
editItem:addItem(locale.colorBalance).onTouch = function()
editItem:addItem("🌈", locale.colorBalance).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, locale.colorBalance)
container.layout:setSpacing(1, 1, 2)
container.panel.eventHandler = nil
@ -652,7 +653,7 @@ editItem:addItem(locale.colorBalance).onTouch = function()
end
end
editItem:addItem(locale.photoFilter).onTouch = function()
editItem:addItem("📷", locale.photoFilter).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, locale.photoFilter)
container.layout:setSpacing(1, 1, 2)
container.panel.eventHandler = nil
@ -674,17 +675,17 @@ end
editItem:addSeparator()
editItem:addItem(locale.invertColors).onTouch = function()
editItem:addItem("", locale.invertColors).onTouch = function()
window.image.data = image.invert(window.image.data)
end
editItem:addItem(locale.blackWhite).onTouch = function()
editItem:addItem("🌗", locale.blackWhite).onTouch = function()
window.image.data = image.blackAndWhite(window.image.data)
end
editItem:addSeparator()
editItem:addItem(locale.gaussianBlur).onTouch = function()
editItem:addItem("", locale.gaussianBlur).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, locale.gaussianBlur)
container.panel.eventHandler = nil

View File

@ -7,7 +7,7 @@ local system = require("System")
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
local localization = system.getSystemLocalization()
menu:addItem(localization.setAsWallpaper).onTouch = function()
menu:addItem("💻", localization.setAsWallpaper).onTouch = function()
local userSettings = system.getUserSettings()
userSettings.interfaceWallpaperPath = icon.path

View File

@ -244,18 +244,12 @@ window:addChild(GUI.panel(1, 1, window.width, window.height, 0xE1E1E1))
local menu = workspace:addChild(GUI.menu(1, 1, workspace.width, 0xF0F0F0, 0x787878, 0x3366CC, 0xE1E1E1))
local installerMenu = menu:addContextMenuItem("MineOS", 0x2D2D2D)
installerMenu:addItem("Shutdown").onTouch = function()
computer.shutdown()
end
installerMenu:addItem("Reboot").onTouch = function()
installerMenu:addItem("🗘", "Reboot").onTouch = function()
computer.shutdown(true)
end
installerMenu:addSeparator()
installerMenu:addItem("Exit").onTouch = function()
workspace:stop()
installerMenu:addItem("", "Shutdown").onTouch = function()
computer.shutdown()
end
-- Main vertical layout

View File

@ -35,14 +35,17 @@ local GUI = {
SWITCH_ANIMATION_DURATION = 0.3,
FILESYSTEM_DIALOG_ANIMATION_DURATION = 0.5,
CONTEXT_MENU_SEPARATOR_COLOR = 0x0F0F0F,
CONTEXT_MENU_DEFAULT_TEXT_COLOR = 0xD2D2D2,
CONTEXT_MENU_DEFAULT_BACKGROUND_COLOR = 0x1E1E1E,
CONTEXT_MENU_DEFAULT_ICON_COLOR = 0x969696,
CONTEXT_MENU_DEFAULT_TEXT_COLOR = 0xD2D2D2,
CONTEXT_MENU_PRESSED_BACKGROUND_COLOR = 0x3366CC,
CONTEXT_MENU_PRESSED_ICON_COLOR = 0xB4B4B4,
CONTEXT_MENU_PRESSED_TEXT_COLOR = 0xFFFFFF,
CONTEXT_MENU_DISABLED_COLOR = 0x5A5A5A,
CONTEXT_MENU_DISABLED_ICON_COLOR = 0x5A5A5A,
CONTEXT_MENU_DISABLED_TEXT_COLOR = 0x5A5A5A,
CONTEXT_MENU_BACKGROUND_TRANSPARENCY = nil,
CONTEXT_MENU_SHADOW_TRANSPARENCY = 0.4,
CONTEXT_MENU_SEPARATOR_COLOR = 0x0F0F0F,
BACKGROUND_CONTAINER_PANEL_COLOR = 0x0,
BACKGROUND_CONTAINER_TITLE_COLOR = 0xE1E1E1,
@ -3926,20 +3929,29 @@ local function dropDownMenuItemDraw(item)
local yText = item.y + math.floor(item.height / 2)
if item.isTextItem then
local iconColor = item.color or item.parent.parent.colors.default.icon
local textColor = item.color or item.parent.parent.colors.default.text
if item.pressed then
iconColor = item.parent.parent.colors.selected.icon
textColor = item.parent.parent.colors.selected.text
screen.drawRectangle(item.x, yText, item.width, 1, item.parent.parent.colors.selected.background, textColor, " ")
elseif item.disabled then
iconColor = item.parent.parent.colors.disabled.icon
textColor = item.parent.parent.colors.disabled.text
end
-- Icon & text
if item.icon then
screen.drawText(item.x + item.height, yText, iconColor, item.icon)
screen.drawText(item.x + item.height * 2 + 2, yText, textColor, item.text)
else
screen.drawText(item.x + item.height, yText, textColor, item.text)
end
-- shortcut
if item.shortcut then
screen.drawText(item.x + item.width - unicode.wlen(item.shortcut) - 1, yText, textColor, item.shortcut)
screen.drawText(item.x + item.width - unicode.wlen(item.shortcut) - item.height, yText, textColor, item.shortcut)
end
else
screen.drawText(item.x, yText, item.parent.parent.colors.separator, string.rep(item.parent.parent.itemHeight % 2 == 0 and "" or "", item.width))
@ -4051,13 +4063,22 @@ local function dropDownMenuRemoveItem(menu, index)
return menu
end
local function dropDownMenuAddItem(menu, text, disabled, shortcut, color)
local function dropDownMenuAddItem(menu, a1, a2, a3, a4, a5)
local item = menu.itemsContainer:addChild(GUI.object(1, 1, 1, menu.itemHeight))
item.text = text
item.disabled = disabled
item.shortcut = shortcut
item.color = color
if type(a1) == "string" and type(a2) == "string" then
item.icon = a1
item.text = a2
item.disabled = a3
item.shortcut = a4
item.color = a5
else
item.text = a1
item.disabled = a2
item.shortcut = a3
item.color = a4
end
item.draw = dropDownMenuItemDraw
item.eventHandler = dropDownMenuItemEventHandler
item.isTextItem = true
@ -4148,20 +4169,40 @@ local function dropDownMenuAdd(parentContainer, menu)
return container:addChild(menu:releaseItems())
end
function GUI.dropDownMenu(x, y, width, maximumHeight, itemHeight, backgroundColor, textColor, backgroundPressedColor, textPressedColor, disabledColor, separatorColor, backgroundTransparency, shadowTransparency)
function GUI.dropDownMenu(
x,
y,
width,
maximumHeight,
itemHeight,
backgroundColor,
iconColor,
textColor,
backgroundPressedColor,
iconPressedColor,
textPressedColor,
disabledIconColor,
disabledTextColor,
separatorColor,
backgroundTransparency,
shadowTransparency
)
local menu = GUI.container(x, y, width, 1)
menu.colors = {
default = {
background = backgroundColor,
text = textColor
text = textColor,
icon = iconColor
},
selected = {
background = backgroundPressedColor,
text = textPressedColor
text = textPressedColor,
icon = iconPressedColor
},
disabled = {
text = disabledColor
text = disabledTextColor,
icon = disabledIconColor
},
separator = separatorColor,
transparency = {
@ -4200,24 +4241,40 @@ end
local function contextMenuUpdate(menu)
if #menu.itemsContainer.children > 0 then
local widestItem, widestShortcut = 0, 0
local widestItem, widestShortcut, haveIcon, item = 0, 0, false
for i = 1, #menu.itemsContainer.children do
if menu.itemsContainer.children[i].isTextItem then
widestItem = math.max(widestItem, unicode.wlen(menu.itemsContainer.children[i].text))
item = menu.itemsContainer.children[i]
if menu.itemsContainer.children[i].shortcut then
widestShortcut = math.max(widestShortcut, unicode.wlen(menu.itemsContainer.children[i].shortcut))
if item.isTextItem then
if item.icon then
haveIcon = true
end
widestItem = math.max(widestItem, unicode.wlen(item.text))
if item.shortcut then
widestShortcut = math.max(widestShortcut, unicode.wlen(item.shortcut))
end
end
end
menu.width, menu.height = menu.itemHeight * 2 + widestItem + (widestShortcut > 0 and 3 + widestShortcut or 0), math.min(dropDownMenuGetHeight(menu), menu.maximumHeight)
menu.width =
menu.itemHeight * 2 +
(haveIcon and menu.itemHeight + 2 or 0) +
widestItem +
(widestShortcut > 0 and widestShortcut + menu.itemHeight + 1 or 0)
menu.height = math.min(dropDownMenuGetHeight(menu), menu.maximumHeight)
dropDownMenuReposition(menu)
local bufferWidth, bufferHeight = screen.getResolution()
if menu.x + menu.width + 1 >= bufferWidth then
menu.localX = bufferWidth - menu.width - 1
end
if menu.y + menu.height >= bufferHeight then
menu.localY = bufferHeight - menu.height
end
@ -4226,8 +4283,15 @@ end
local contextMenuCreate, contextMenuaddSubMenuItem
contextMenuaddSubMenuItem = function(menu, text, disabled)
local item = menu:addItem(text, disabled, "")
contextMenuaddSubMenuItem = function(menu, a1, a2, a3)
local item
if type(a1) == "string" and type(a2) == "string" then
item = menu:addItem(a1, a2, a3, "")
else
item = menu:addItem(a1, a2, "")
end
item.subMenu = contextMenuCreate(1, 1)
item.subMenu.colors = menu.colors
@ -4241,14 +4305,20 @@ contextMenuCreate = function(x, y, backgroundColor, textColor, backgroundPressed
1,
math.ceil(screen.getHeight() * 0.7),
2,
backgroundColor or GUI.CONTEXT_MENU_DEFAULT_BACKGROUND_COLOR,
textColor or GUI.CONTEXT_MENU_DEFAULT_TEXT_COLOR,
backgroundPressedColor or GUI.CONTEXT_MENU_PRESSED_BACKGROUND_COLOR,
textPressedColor or GUI.CONTEXT_MENU_PRESSED_TEXT_COLOR,
disabledColor or GUI.CONTEXT_MENU_DISABLED_COLOR,
separatorColor or GUI.CONTEXT_MENU_SEPARATOR_COLOR,
backgroundTransparency or GUI.CONTEXT_MENU_BACKGROUND_TRANSPARENCY,
shadowTransparency or GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY
GUI.CONTEXT_MENU_DEFAULT_BACKGROUND_COLOR,
GUI.CONTEXT_MENU_DEFAULT_ICON_COLOR,
GUI.CONTEXT_MENU_DEFAULT_TEXT_COLOR,
GUI.CONTEXT_MENU_PRESSED_BACKGROUND_COLOR,
GUI.CONTEXT_MENU_PRESSED_ICON_COLOR,
GUI.CONTEXT_MENU_PRESSED_TEXT_COLOR,
GUI.CONTEXT_MENU_DISABLED_ICON_COLOR,
GUI.CONTEXT_MENU_DISABLED_TEXT_COLOR,
GUI.CONTEXT_MENU_SEPARATOR_COLOR,
GUI.CONTEXT_MENU_BACKGROUND_TRANSPARENCY,
GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY
)
menu.update = contextMenuUpdate
@ -4368,9 +4438,12 @@ function GUI.comboBox(x, y, width, height, backgroundColor, textColor, arrowBack
height == 1 and 1 or 2,
comboBox.colors.default.background,
comboBox.colors.default.text,
comboBox.colors.default.text,
comboBox.colors.selected.background,
comboBox.colors.selected.text,
GUI.CONTEXT_MENU_DISABLED_COLOR,
comboBox.colors.selected.text,
GUI.CONTEXT_MENU_DISABLED_ICON_COLOR,
GUI.CONTEXT_MENU_DISABLED_TEXT_COLOR,
GUI.CONTEXT_MENU_SEPARATOR_COLOR,
GUI.CONTEXT_MENU_BACKGROUND_TRANSPARENCY,
GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY
@ -4441,7 +4514,10 @@ local function windowCheck(window, x, y)
end
local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...)
if window.movingEnabled then
if not window.movingEnabled then
return
end
if e1 == "touch" then
e3, e4 = math.ceil(e3), math.ceil(e4)
@ -4470,7 +4546,6 @@ local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...)
elseif e1 == "drop" then
window.lastTouchX, window.lastTouchY = nil, nil
end
end
end
local function windowResize(window, width, height, ignoreOnResizeFinished)

View File

@ -337,7 +337,7 @@ end
local function addMainDesktopMenuItem(menu)
local item = menu:addContextMenuItem("", 0xF0F0F0)
item:addItem(localization.aboutSystem).onTouch = function()
item:addItem("🛈", localization.aboutSystem).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, localization.aboutSystem)
container.layout:removeChildren()
@ -383,22 +383,22 @@ local function addMainDesktopMenuItem(menu)
workspace:draw()
end
item:addItem(localization.updates).onTouch = function()
item:addItem("🛒", localization.updates).onTouch = function()
system.execute(paths.system.applicationAppMarket, "updates")
end
item:addSeparator()
item:addItem(localization.logout).onTouch = function()
item:addItem("", localization.logout).onTouch = function()
system.authorize()
end
item:addItem(localization.reboot).onTouch = function()
item:addItem("🗘", localization.reboot).onTouch = function()
require("Network").broadcastComputerState(false)
computer.shutdown(true)
end
item:addItem(localization.shutdown).onTouch = function()
item:addItem("", localization.shutdown).onTouch = function()
require("Network").broadcastComputerState(false)
computer.shutdown()
end
@ -473,7 +473,7 @@ local function uploadToPastebin(path)
end
function system.addUploadToPastebinMenuItem(menu, path)
menu:addItem(localization.uploadToPastebin, not component.isAvailable("internet")).onTouch = function()
menu:addItem("", localization.uploadToPastebin, not component.isAvailable("internet")).onTouch = function()
uploadToPastebin(path)
end
end
@ -758,7 +758,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
local contextMenu = GUI.addContextMenu(workspace, math.ceil(e3), math.ceil(e4))
if #selectedIcons > 1 then
contextMenu:addItem(localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")").onTouch = function()
contextMenu:addItem("📂", localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")").onTouch = function()
local container = addBackgroundContainerWithInput("", localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")", localization.folderName)
container.input.onInputFinished = function()
@ -784,15 +784,15 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
else
if icon.isDirectory then
if icon.extension == ".app" then
contextMenu:addItem(localization.edit .. " Main.lua").onTouch = function()
contextMenu:addItem("🖊", localization.edit .. " Main.lua").onTouch = function()
system.execute(paths.system.applicationMineCodeIDE, icon.path .. "Main.lua")
end
contextMenu:addItem(localization.showPackageContent).onTouch = function()
contextMenu:addItem("📂", localization.showPackageContent).onTouch = function()
icon.parent.launchers.showPackageContent(icon)
end
contextMenu:addItem(localization.launchWithArguments).onTouch = function()
contextMenu:addItem("˃", localization.launchWithArguments).onTouch = function()
system.launchWithArguments(icon.path .. "Main.lua")
end
@ -800,7 +800,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
end
if icon.extension ~= ".app" then
contextMenu:addItem(localization.addToFavourites).onTouch = function()
contextMenu:addItem("", localization.addToFavourites).onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, localization.addToFavourites)
local input = addBackgroundContainerInput(container.layout, icon.name, localization.name)
@ -819,7 +819,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
end
else
if icon.isShortcut then
contextMenu:addItem(localization.editShortcut).onTouch = function()
contextMenu:addItem("🖊", localization.editShortcut).onTouch = function()
local text = system.readShortcut(icon.path)
local container = addBackgroundContainerWithInput(text, localization.editShortcut, localization.rename)
@ -839,21 +839,23 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
workspace:draw()
end
contextMenu:addItem(localization.showContainingFolder).onTouch = function()
contextMenu:addItem("📂", localization.showContainingFolder).onTouch = function()
icon.parent.launchers.showContainingFolder(icon)
end
contextMenu:addSeparator()
else
local function addDefault()
contextMenu:addItem(localization.uploadToPastebin, not component.isAvailable("internet")).onTouch = function()
contextMenu:addItem("", localization.uploadToPastebin, not component.isAvailable("internet")).onTouch = function()
uploadToPastebin(icon.path)
end
contextMenu:addSeparator()
end
if userSettings.extensions[icon.extension] then
local result, reason = loadfile(userSettings.extensions[icon.extension] .. "Extensions/" .. icon.extension .. "/Context menu.lua")
if result then
result, reason = pcall(result, workspace, icon, contextMenu)
@ -870,7 +872,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
end
-- Open with
local subMenu = contextMenu:addSubMenuItem(localization.openWith)
local subMenu = contextMenu:addSubMenuItem("🔎", localization.openWith)
local function setAssociation(path)
userSettings.extensions[icon.extension] = path
@ -883,7 +885,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
system.saveUserSettings()
end
subMenu:addItem(localization.select).onTouch = function()
subMenu:addItem("🗸", localization.select).onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), localization.open, localization.cancel, localization.fileName, "/")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_DIRECTORY)
@ -900,6 +902,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
subMenu:addSeparator()
local list = filesystem.list(paths.system.applications)
for i = 1, #list do
local path = paths.system.applications .. list[i]
@ -914,10 +917,10 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
end
if not icon.isShortcut or #selectedIcons > 1 then
local subMenu = contextMenu:addSubMenuItem(localization.createShortcut)
local subMenu = contextMenu:addSubMenuItem("🔖", localization.createShortcut)
local function addShortcutItem(name, pathGetter)
subMenu:addItem(name).onTouch = function()
local function addShortcutItem(icon, name, pathGetter)
subMenu:addItem(icon, name).onTouch = function()
local selectedIcon
for i = 1, #selectedIcons do
@ -935,19 +938,20 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
end
end
addShortcutItem(localization.inCurrentDirectory, function(selectedIcon)
addShortcutItem("📂", localization.inCurrentDirectory, function(selectedIcon)
return filesystem.path(selectedIcon.path)
end)
addShortcutItem(localization.onDesktop, function(selectedIcon)
addShortcutItem("💻", localization.onDesktop, function(selectedIcon)
return paths.user.desktop
end)
end
local subMenu = contextMenu:addSubMenuItem(localization.archive .. (#selectedIcons > 1 and " (" .. #selectedIcons .. ")" or ""))
local subMenu = contextMenu:addSubMenuItem("📦", localization.archive .. (#selectedIcons > 1 and " (" .. #selectedIcons .. ")" or ""))
local function archive(where)
local itemsToArchive = {}
for i = 1, #selectedIcons do
table.insert(itemsToArchive, selectedIcons[i].path)
end
@ -961,16 +965,16 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
computer.pushSignal("system", "updateFileList")
end
subMenu:addItem(localization.inCurrentDirectory).onTouch = function()
subMenu:addItem("📂", localization.inCurrentDirectory).onTouch = function()
archive(filesystem.path(icon.path))
end
subMenu:addItem(localization.onDesktop).onTouch = function()
subMenu:addItem("💻", localization.onDesktop).onTouch = function()
archive(paths.user.desktop)
end
if #selectedIcons == 1 then
contextMenu:addItem(localization.addToDock).onTouch = function()
contextMenu:addItem("📌", localization.addToDock).onTouch = function()
dockContainer.addIcon(icon.path).keepInDock = true
dockContainer.saveUserSettings()
end
@ -984,22 +988,23 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
end
system.clipboard = {cut = cut}
for i = 1, #selectedIcons do
selectedIcons[i].cut = cut
table.insert(system.clipboard, selectedIcons[i].path)
end
end
contextMenu:addItem(localization.cut).onTouch = function()
contextMenu:addItem("", localization.cut).onTouch = function()
cutOrCopy(true)
end
contextMenu:addItem(localization.copy).onTouch = function()
contextMenu:addItem("", localization.copy).onTouch = function()
cutOrCopy()
end
if #selectedIcons == 1 then
contextMenu:addItem(localization.rename).onTouch = function()
contextMenu:addItem("Aa", localization.rename).onTouch = function()
local container = addBackgroundContainerWithInput(filesystem.name(icon.path), localization.rename, localization.newName)
container.input.onInputFinished = function()
@ -1015,16 +1020,15 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
if icon.path == paths.user.trash then
contextMenu:addItem(localization.emptyTrash).onTouch = emptyTrash
contextMenu:addItem("🗑", localization.emptyTrash).onTouch = emptyTrash
else
contextMenu:addItem(localization.delete).onTouch = function()
contextMenu:addItem("🗑", localization.delete).onTouch = function()
moveSelectedIconsToTrash(selectedIcons)
end
end
if icon.isShortcut then
contextMenu:addItem(localization.deleteWithSource).onTouch = function()
contextMenu:addItem("𝕩", localization.deleteWithSource).onTouch = function()
moveToTrash({
icon.shortcutPath,
icon.path
@ -1034,7 +1038,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
contextMenu:addSeparator()
contextMenu:addItem(localization.properties).onTouch = function()
contextMenu:addItem("👀", localization.properties).onTouch = function()
for i = 1, #selectedIcons do
system.addPropertiesWindow(math.ceil(e3), math.ceil(e4), 46, selectedIcons[i])
end
@ -1469,9 +1473,9 @@ end
local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
local contextMenu = GUI.addContextMenu(workspace, math.ceil(e3), math.ceil(e4))
local subMenu = contextMenu:addSubMenuItem(localization.create)
local subMenu = contextMenu:addSubMenuItem("", localization.create)
subMenu:addItem(localization.newFile).onTouch = function()
subMenu:addItem("🗎", localization.newFile).onTouch = function()
local container = addBackgroundContainerWithInput("", localization.newFile, localization.fileName)
container.input.onInputFinished = function()
@ -1489,7 +1493,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
workspace:draw()
end
subMenu:addItem(localization.newFolder).onTouch = function()
subMenu:addItem("📂", localization.newFolder).onTouch = function()
local container = addBackgroundContainerWithInput("", localization.newFolder, localization.folderName)
container.input.onInputFinished = function()
@ -1505,7 +1509,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
workspace:draw()
end
subMenu:addItem(localization.newImage).onTouch = function()
subMenu:addItem("📷", localization.newImage).onTouch = function()
local container = addBackgroundContainerWithInput("", localization.newImage, localization.fileName)
local layout = container.layout:addChild(GUI.layout(1, 1, 36, 3, 1, 1))
@ -1550,7 +1554,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
workspace:draw()
end
subMenu:addItem(localization.newFileFromURL, not component.isAvailable("internet")).onTouch = function()
subMenu:addItem("🌍", localization.newFileFromURL, not component.isAvailable("internet")).onTouch = function()
local container = addBackgroundContainerWithInput("", localization.newFileFromURL, localization.fileName)
local inputURL = addBackgroundContainerInput(container.layout, "", "URL", false)
@ -1592,7 +1596,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
subMenu:addSeparator()
subMenu:addItem(localization.newApplication).onTouch = function()
subMenu:addItem("💻", localization.newApplication).onTouch = function()
local container = addBackgroundContainerWithInput("", localization.newApplication, localization.applicationName)
container.panel.eventHandler = function(workspace, panel, e1)
@ -1620,7 +1624,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
contextMenu:addSeparator()
local subMenu = contextMenu:addSubMenuItem(localization.sortBy)
local subMenu = contextMenu:addSubMenuItem("", localization.sortBy)
local function sortAutomatically()
if iconField.iconConfigEnabled then
@ -1637,27 +1641,27 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
sortAutomatically()
end
subMenu:addItem(localization.sortByName).onTouch = function()
subMenu:addItem("Aa", localization.sortByName).onTouch = function()
setSortingMethod(filesystem.SORTING_NAME)
end
subMenu:addItem(localization.sortByDate).onTouch = function()
subMenu:addItem("🗓", localization.sortByDate).onTouch = function()
setSortingMethod(filesystem.SORTING_DATE)
end
subMenu:addItem(localization.sortByType).onTouch = function()
subMenu:addItem("🖹", localization.sortByType).onTouch = function()
setSortingMethod(filesystem.SORTING_TYPE)
end
contextMenu:addItem(localization.sortAutomatically).onTouch = sortAutomatically
contextMenu:addItem("🗓", localization.sortAutomatically).onTouch = sortAutomatically
contextMenu:addItem(localization.update).onTouch = function()
contextMenu:addItem("🗘", localization.update).onTouch = function()
iconField:updateFileList()
end
contextMenu:addSeparator()
contextMenu:addItem(localization.paste, not system.clipboard).onTouch = function()
contextMenu:addItem("", localization.paste, not system.clipboard).onTouch = function()
local i = 1
while i <= #system.clipboard do
if filesystem.exists(system.clipboard[i]) then
@ -2082,7 +2086,7 @@ function system.addWindow(window, dontAddToDock, preserveCoordinates)
local name = filesystem.hideExtension(filesystem.name(dockPath))
local contextMenu = window.menu:addContextMenuItem(name, 0xD2D2D2)
contextMenu:addItem(localization.closeWindow .. " " .. name, false, "^W").onTouch = function()
contextMenu:addItem("", localization.closeWindow .. " " .. name, false, "^W").onTouch = function()
window:remove()
end
@ -2626,11 +2630,11 @@ function system.updateDesktop()
if icon.windows then
local eventData = {...}
contextMenu:addItem(localization.newWindow).onTouch = function()
contextMenu:addItem("", localization.newWindow).onTouch = function()
iconOnDoubleClick(icon, e1, e2, e3, e4, table.unpack(eventData))
end
contextMenu:addItem(localization.closeAllWindows).onTouch = function()
contextMenu:addItem("",localization.closeAllWindows).onTouch = function()
for window in pairs(icon.windows) do
window:remove()
end
@ -2639,17 +2643,17 @@ function system.updateDesktop()
end
end
contextMenu:addItem(localization.showContainingFolder).onTouch = function()
contextMenu:addItem("📂", localization.showContainingFolder).onTouch = function()
system.execute(paths.system.applicationFinder, "-o", filesystem.path(icon.shortcutPath or icon.path))
end
contextMenu:addSeparator()
contextMenu:addItem(localization.moveRight, indexOf >= #dockContainer.children - 1).onTouch = function()
contextMenu:addItem("˱", localization.moveRight, indexOf >= #dockContainer.children - 1).onTouch = function()
moveDockIcon(indexOf, 1)
end
contextMenu:addItem(localization.moveLeft, indexOf <= 1).onTouch = function()
contextMenu:addItem("˲", localization.moveLeft, indexOf <= 1).onTouch = function()
moveDockIcon(indexOf, -1)
end
@ -2657,7 +2661,7 @@ function system.updateDesktop()
if icon.keepInDock then
if #dockContainer.children > 1 then
contextMenu:addItem(localization.removeFromDock).onTouch = function()
contextMenu:addItem("📌", localization.removeFromDock).onTouch = function()
if icon.windows then
icon.keepInDock = nil
else
@ -2671,7 +2675,7 @@ function system.updateDesktop()
end
else
if icon.windows then
contextMenu:addItem(localization.keepInDock).onTouch = function()
contextMenu:addItem("📌", localization.keepInDock).onTouch = function()
icon.keepInDock = true
dockContainer.saveUserSettings()
end
@ -2709,7 +2713,7 @@ function system.updateDesktop()
workspace:draw()
end
contextMenu:addItem(localization.emptyTrash).onTouch = emptyTrash
contextMenu:addItem("🗑️", localization.emptyTrash).onTouch = emptyTrash
workspace:draw()
end
@ -2868,11 +2872,11 @@ function system.updateDesktop()
system.execute(userSettings.interfaceScreensaverPath)
workspace:draw()
end
end
screensaverUptime = computer.uptime()
end
end
end
system.menuInitialChildren = desktopMenu.children
system.consoleWindow = nil