mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Добавил поддержку иконок для контекстного меню
This commit is contained in:
parent
11d83f3e2d
commit
edff33979a
@ -7,7 +7,7 @@ local system = require("System")
|
|||||||
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
||||||
local localization = system.getSystemLocalization()
|
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")
|
system.execute(paths.system.applicationPrint3D, icon.path, "-p")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -173,11 +173,11 @@ window.actionButtons.localY = 1
|
|||||||
|
|
||||||
local fileItem = menu:addContextMenuItem(localization.file)
|
local fileItem = menu:addContextMenuItem(localization.file)
|
||||||
|
|
||||||
local newItem = fileItem:addItem(localization.new, false, "^N")
|
local newItem = fileItem:addItem("➕", localization.new, false, "^N")
|
||||||
local openItem = fileItem:addItem(localization.open, false, "^O")
|
local openItem = fileItem:addItem("📂", localization.open, false, "^O")
|
||||||
fileItem:addSeparator()
|
fileItem:addSeparator()
|
||||||
local saveItem = fileItem:addItem(localization.save, true, "^S")
|
local saveItem = fileItem:addItem("💾", localization.save, true, "^S")
|
||||||
local saveAsItem = fileItem:addItem(localization.saveAs, false, "^⇧S")
|
local saveAsItem = fileItem:addItem("🖪", localization.saveAs, false, "^⇧S")
|
||||||
|
|
||||||
menu:addItem(localization.help).onTouch = function()
|
menu:addItem(localization.help).onTouch = function()
|
||||||
local container = GUI.addBackgroundContainer(workspace, true, true, localization.help)
|
local container = GUI.addBackgroundContainer(workspace, true, true, localization.help)
|
||||||
|
|||||||
@ -15,19 +15,20 @@ local config = filesystem.exists(configPath) and filesystem.readTable(configPath
|
|||||||
|
|
||||||
local colors = {
|
local colors = {
|
||||||
background = 0xF0F0F0,
|
background = 0xF0F0F0,
|
||||||
backgroundText = 0x555555,
|
backgroundText = 0x5A5A5A,
|
||||||
panel = 0x2D2D2D,
|
panel = 0x1E1E1E,
|
||||||
panelText = 0x999999,
|
panelText = 0x5A5A5A,
|
||||||
panelSeleciton = 0x444444,
|
panelSelection = 0x3C3C3C,
|
||||||
panelSelecitonText = 0xE1E1E1,
|
panelSelectionText = 0xE1E1E1,
|
||||||
selectionFrom = 0x990000,
|
selectionFrom = 0x990000,
|
||||||
selectionTo = 0x990000,
|
selectionTo = 0x990000,
|
||||||
selectionText = 0xFFFFFF,
|
selectionText = 0xE1E1E1,
|
||||||
selectionBetween = 0xD2D2D2,
|
selectionBetween = 0xD2D2D2,
|
||||||
selectionBetweenText = 0x000000,
|
selectionBetweenText = 0x000000,
|
||||||
separator = 0xCCCCCC,
|
separator = 0xE1E1E1,
|
||||||
|
title = 0x2D2D2D,
|
||||||
titleBackground = 0x990000,
|
titleBackground = 0x990000,
|
||||||
titleText = 0xFFFFFF,
|
titleText = 0xE1E1E1,
|
||||||
titleText2 = 0xE1E1E1,
|
titleText2 = 0xE1E1E1,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5)
|
|||||||
if e5 == 1 then
|
if e5 == 1 then
|
||||||
local menu = GUI.addContextMenu(workspace, math.ceil(e3), math.ceil(e4))
|
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.from = 1
|
||||||
selection.to = #bytes
|
selection.to = #bytes
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5)
|
|||||||
|
|
||||||
menu:addSeparator()
|
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 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"))
|
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()
|
workspace:draw()
|
||||||
end
|
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 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))
|
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:addSeparator()
|
||||||
|
|
||||||
menu:addItem("Delete").onTouch = function()
|
menu:addItem("🗑", "Delete").onTouch = function()
|
||||||
for i = selection.from, selection.to do
|
for i = selection.from, selection.to do
|
||||||
table.remove(bytes, selection.from)
|
table.remove(bytes, selection.from)
|
||||||
end
|
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 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))
|
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
|
local textColor = colors.panelText
|
||||||
|
|
||||||
if index > selection.from and index < selection.to then
|
if index > selection.from and index < selection.to then
|
||||||
screen.drawRectangle(object.x, object.y + y - 1, object.width, 2, colors.panelSeleciton, colors.panelSelecitonText, " ")
|
screen.drawRectangle(object.x, object.y + y - 1, object.width, 2, colors.panelSelection, colors.panelSelectionText, " ")
|
||||||
textColor = colors.panelSelecitonText
|
textColor = colors.panelSelectionText
|
||||||
end
|
end
|
||||||
|
|
||||||
if selection.from >= index and selection.from <= index + 15 or selection.to >= index and selection.to <= index + 15 then
|
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
|
for x = 1, object.width, 4 do
|
||||||
local textColor = colors.panelText
|
local textColor = colors.panelText
|
||||||
if counter + 1 > restFrom and counter + 1 < restTo then
|
if counter + 1 > restFrom and counter + 1 < restTo then
|
||||||
screen.drawRectangle(object.x + x - 2, object.y, 4, 1, colors.panelSeleciton, colors.selectionText, " ")
|
screen.drawRectangle(object.x + x - 2, object.y, 4, 1, colors.panelSelection, colors.selectionText, " ")
|
||||||
textColor = colors.panelSelecitonText
|
textColor = colors.panelSelectionText
|
||||||
elseif restFrom == counter + 1 or restTo == counter + 1 then
|
elseif restFrom == counter + 1 or restTo == counter + 1 then
|
||||||
screen.drawRectangle(object.x + x - 2, object.y, 4, 1, colors.selectionFrom, colors.selectionText, " ")
|
screen.drawRectangle(object.x + x - 2, object.y, 4, 1, colors.selectionFrom, colors.selectionText, " ")
|
||||||
textColor = 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:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
titleTextBox.eventHandler = nil
|
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 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.panelSelecitonText, colors.panelSelecitonText, colors.panel, "Open"))
|
local openFileButton = window:addChild(GUI.adaptiveRoundedButton(saveFileButton.localX - 10, 2, 2, 0, colors.panel, colors.panelSelectionText, colors.panelSelectionText, colors.panel, "Open"))
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -7,15 +7,15 @@ local system = require("System")
|
|||||||
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
||||||
local localization = system.getSystemLocalization()
|
local localization = system.getSystemLocalization()
|
||||||
|
|
||||||
menu:addItem(localization.launch).onTouch = function()
|
menu:addItem("˃", localization.launch).onTouch = function()
|
||||||
system.execute(icon.path)
|
system.execute(icon.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.launchWithArguments).onTouch = function()
|
menu:addItem("˃.", localization.launchWithArguments).onTouch = function()
|
||||||
system.launchWithArguments(icon.path)
|
system.launchWithArguments(icon.path)
|
||||||
end
|
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)
|
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)
|
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, localization.flashingEEPROM)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
|
|||||||
@ -1312,68 +1312,68 @@ local function toggleTopToolBar()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function createEditOrRightClickMenu(menu)
|
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()
|
cut()
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.copy, not codeView.selections[1], "^C").onTouch = function()
|
menu:addItem("⧉", localization.copy, not codeView.selections[1], "^C").onTouch = function()
|
||||||
copy()
|
copy()
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.paste, not clipboard, "^V").onTouch = function()
|
menu:addItem("⇲", localization.paste, not clipboard, "^V").onTouch = function()
|
||||||
paste(clipboard)
|
paste(clipboard)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
|
|
||||||
menu:addItem(localization.selectWord).onTouch = function()
|
menu:addItem("💬", localization.selectWord).onTouch = function()
|
||||||
selectWord()
|
selectWord()
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.selectAll, false, "^A").onTouch = function()
|
menu:addItem("📜", localization.selectAll, false, "^A").onTouch = function()
|
||||||
selectAll()
|
selectAll()
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
|
|
||||||
menu:addItem(localization.comment, false, "^/").onTouch = function()
|
menu:addItem("//", localization.comment, false, "^/").onTouch = function()
|
||||||
toggleComment()
|
toggleComment()
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.indent, false, "Tab").onTouch = function()
|
menu:addItem("⤷", localization.indent, false, "Tab").onTouch = function()
|
||||||
indentOrUnindent(true)
|
indentOrUnindent(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.unindent, false, "⇧Tab").onTouch = function()
|
menu:addItem("⤶", localization.unindent, false, "⇧Tab").onTouch = function()
|
||||||
indentOrUnindent(false)
|
indentOrUnindent(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.deleteLine, false, "^Del").onTouch = function()
|
menu:addItem("❌", localization.deleteLine, false, "^Del").onTouch = function()
|
||||||
deleteLine(cursorPositionLine)
|
deleteLine(cursorPositionLine)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.selectAndPasteColor, false, "^⇧C").onTouch = function()
|
menu:addItem("🎨", localization.selectAndPasteColor, false, "^⇧C").onTouch = function()
|
||||||
selectAndPasteColor()
|
selectAndPasteColor()
|
||||||
end
|
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")
|
convertCase("upper")
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.toLowerCase, false, "^▼").onTouch = function()
|
subMenu:addItem("aa", localization.toLowerCase, false, "^▼").onTouch = function()
|
||||||
convertCase("lower")
|
convertCase("lower")
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
|
|
||||||
menu:addItem(localization.addBreakpoint, false, "F9").onTouch = function()
|
menu:addItem("•", localization.addBreakpoint, false, "F9").onTouch = function()
|
||||||
addBreakpoint()
|
addBreakpoint()
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addItem(localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function()
|
menu:addItem("⚬", localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function()
|
||||||
clearBreakpoints()
|
clearBreakpoints()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1638,31 +1638,32 @@ leftTreeView.onItemSelected = function(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local fileContextMenu = menu:addContextMenuItem(localization.file)
|
local fileContextMenu = menu:addContextMenuItem(localization.file)
|
||||||
fileContextMenu:addItem(localization.new, false, "^N").onTouch = function()
|
|
||||||
|
fileContextMenu:addItem("➕", localization.new, false, "^N").onTouch = function()
|
||||||
newFile()
|
newFile()
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
fileContextMenu:addItem(localization.open, false, "^O").onTouch = function()
|
fileContextMenu:addItem("📂", localization.open, false, "^O").onTouch = function()
|
||||||
openFileWindow()
|
openFileWindow()
|
||||||
end
|
end
|
||||||
|
|
||||||
fileContextMenu:addItem(localization.getFromWeb, not component.isAvailable("internet"), "^U").onTouch = function()
|
fileContextMenu:addItem("🌍", localization.getFromWeb, not component.isAvailable("internet"), "^U").onTouch = function()
|
||||||
downloadFileFromWeb()
|
downloadFileFromWeb()
|
||||||
end
|
end
|
||||||
|
|
||||||
fileContextMenu:addSeparator()
|
fileContextMenu:addSeparator()
|
||||||
|
|
||||||
saveContextMenuItem = fileContextMenu:addItem(localization.save, not leftTreeView.selectedItem, "^S")
|
saveContextMenuItem = fileContextMenu:addItem("💾", localization.save, not leftTreeView.selectedItem, "^S")
|
||||||
saveContextMenuItem.onTouch = function()
|
saveContextMenuItem.onTouch = function()
|
||||||
saveFileWindow()
|
saveFileWindow()
|
||||||
end
|
end
|
||||||
|
|
||||||
fileContextMenu:addItem(localization.saveAs, false, "^⇧S").onTouch = function()
|
fileContextMenu:addItem("🖪", localization.saveAs, false, "^⇧S").onTouch = function()
|
||||||
saveFileAsWindow()
|
saveFileAsWindow()
|
||||||
end
|
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)
|
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)
|
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, localization.flashingEEPROM .. "...")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
@ -1675,38 +1676,40 @@ end
|
|||||||
|
|
||||||
fileContextMenu:addSeparator()
|
fileContextMenu:addSeparator()
|
||||||
|
|
||||||
fileContextMenu:addItem(localization.launchWithArguments, false, "^F5").onTouch = function()
|
fileContextMenu:addItem("˃", localization.launchWithArguments, false, "^F5").onTouch = function()
|
||||||
launchWithArgumentsWindow()
|
launchWithArgumentsWindow()
|
||||||
end
|
end
|
||||||
|
|
||||||
local topMenuEdit = menu:addContextMenuItem(localization.edit)
|
local topMenuEdit = menu:addContextMenuItem(localization.edit)
|
||||||
|
|
||||||
createEditOrRightClickMenu(topMenuEdit)
|
createEditOrRightClickMenu(topMenuEdit)
|
||||||
|
|
||||||
local gotoContextMenu = menu:addContextMenuItem(localization.gotoCyka)
|
local gotoContextMenu = menu:addContextMenuItem(localization.gotoCyka)
|
||||||
gotoContextMenu:addItem(localization.pageUp, false, "PgUp").onTouch = function()
|
|
||||||
|
gotoContextMenu:addItem("↑", localization.pageUp, false, "PgUp").onTouch = function()
|
||||||
pageUp()
|
pageUp()
|
||||||
end
|
end
|
||||||
|
|
||||||
gotoContextMenu:addItem(localization.pageDown, false, "PgDn").onTouch = function()
|
gotoContextMenu:addItem("↓", localization.pageDown, false, "PgDn").onTouch = function()
|
||||||
pageDown()
|
pageDown()
|
||||||
end
|
end
|
||||||
|
|
||||||
gotoContextMenu:addItem(localization.gotoStart, false, "Home").onTouch = function()
|
gotoContextMenu:addItem("🏠", localization.gotoStart, false, "Home").onTouch = function()
|
||||||
setCursorPositionToHome()
|
setCursorPositionToHome()
|
||||||
end
|
end
|
||||||
|
|
||||||
gotoContextMenu:addItem(localization.gotoEnd, false, "End").onTouch = function()
|
gotoContextMenu:addItem("💀", localization.gotoEnd, false, "End").onTouch = function()
|
||||||
setCursorPositionToEnd()
|
setCursorPositionToEnd()
|
||||||
end
|
end
|
||||||
|
|
||||||
gotoContextMenu:addSeparator()
|
gotoContextMenu:addSeparator()
|
||||||
|
|
||||||
gotoContextMenu:addItem(localization.gotoLine, false, "^L").onTouch = function()
|
gotoContextMenu:addItem("↩", localization.gotoLine, false, "^L").onTouch = function()
|
||||||
gotoLineWindow()
|
gotoLineWindow()
|
||||||
end
|
end
|
||||||
|
|
||||||
local propertiesContextMenu = menu:addContextMenuItem(localization.properties)
|
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 container = GUI.addBackgroundContainer(workspace, true, false, localization.colorScheme)
|
||||||
|
|
||||||
local colorSelectorsCount, colorSelectorCountX = 0, 4; for key in pairs(config.syntaxColorScheme) do colorSelectorsCount = colorSelectorsCount + 1 end
|
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()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function()
|
propertiesContextMenu:addItem("I", localization.cursorProperties).onTouch = function()
|
||||||
local container = addBackgroundContainer(localization.cursorProperties)
|
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))
|
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()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
propertiesContextMenu:addItem(localization.toggleTopToolBar).onTouch = function()
|
propertiesContextMenu:addItem("☰", localization.toggleTopToolBar).onTouch = function()
|
||||||
toggleTopToolBar()
|
toggleTopToolBar()
|
||||||
end
|
end
|
||||||
|
|
||||||
propertiesContextMenu:addSeparator()
|
propertiesContextMenu:addSeparator()
|
||||||
|
|
||||||
propertiesContextMenu:addItem(localization.toggleSyntaxHighlight).onTouch = function()
|
propertiesContextMenu:addItem("Aa", localization.toggleSyntaxHighlight).onTouch = function()
|
||||||
syntaxHighlightingButton.pressed = not syntaxHighlightingButton.pressed
|
syntaxHighlightingButton.pressed = not syntaxHighlightingButton.pressed
|
||||||
syntaxHighlightingButton.onTouch()
|
syntaxHighlightingButton.onTouch()
|
||||||
end
|
end
|
||||||
|
|
||||||
propertiesContextMenu:addItem(localization.toggleAutoBrackets, false, "^]").onTouch = function()
|
propertiesContextMenu:addItem("[]", localization.toggleAutoBrackets, false, "^]").onTouch = function()
|
||||||
config.enableAutoBrackets = not config.enableAutoBrackets
|
config.enableAutoBrackets = not config.enableAutoBrackets
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
|
|
||||||
propertiesContextMenu:addItem(localization.toggleAutocompletion, false, "^I").onTouch = function()
|
propertiesContextMenu:addItem("🔎", localization.toggleAutocompletion, false, "^I").onTouch = function()
|
||||||
toggleEnableAutocompleteDatabase()
|
toggleEnableAutocompleteDatabase()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ local system = require("System")
|
|||||||
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
||||||
local localization = system.getSystemLocalization()
|
local localization = system.getSystemLocalization()
|
||||||
|
|
||||||
menu:addItem(localization.setAsWallpaper).onTouch = function()
|
menu:addItem("💻", localization.setAsWallpaper).onTouch = function()
|
||||||
local userSettings = system.getUserSettings()
|
local userSettings = system.getUserSettings()
|
||||||
|
|
||||||
userSettings.interfaceWallpaperPath = icon.path
|
userSettings.interfaceWallpaperPath = icon.path
|
||||||
|
|||||||
@ -484,13 +484,14 @@ window.image.reposition = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local fileItem = menu:addContextMenuItem(locale.file)
|
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: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)
|
local fileItemSubMenu = fileItem:addSubMenuItem(locale.openRecent, #config.recentFiles == 0)
|
||||||
|
|
||||||
for i = 1, #config.recentFiles do
|
for i = 1, #config.recentFiles do
|
||||||
fileItemSubMenu:addItem(text.limit(config.recentFiles[i], 32, "left")).onTouch = function()
|
fileItemSubMenu:addItem(text.limit(config.recentFiles[i], 32, "left")).onTouch = function()
|
||||||
loadImage(config.recentFiles[i])
|
loadImage(config.recentFiles[i])
|
||||||
@ -499,7 +500,7 @@ for i = 1, #config.recentFiles do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fileItem:addItem(locale.openFromURL).onTouch = function()
|
fileItem:addItem("🌍", locale.openFromURL).onTouch = function()
|
||||||
local container = GUI.addBackgroundContainer(workspace, true, true, locale.openFromURL)
|
local container = GUI.addBackgroundContainer(workspace, true, true, locale.openFromURL)
|
||||||
container.panel.eventHandler = nil
|
container.panel.eventHandler = nil
|
||||||
|
|
||||||
@ -543,12 +544,12 @@ end
|
|||||||
|
|
||||||
fileItem:addSeparator()
|
fileItem:addSeparator()
|
||||||
|
|
||||||
saveItem = fileItem:addItem(locale.save, false, "^S")
|
saveItem = fileItem:addItem("💾", locale.save, false, "^S")
|
||||||
saveItem.onTouch = function()
|
saveItem.onTouch = function()
|
||||||
save(savePath)
|
save(savePath)
|
||||||
end
|
end
|
||||||
|
|
||||||
fileItem:addItem(locale.saveAs, false, "^⇧S").onTouch = saveAs
|
fileItem:addItem("🖪", locale.saveAs, false, "^⇧S").onTouch = saveAs
|
||||||
|
|
||||||
menu:addItem(locale.view).onTouch = function()
|
menu:addItem(locale.view).onTouch = function()
|
||||||
local container = GUI.addBackgroundContainer(workspace, true, true, locale.view)
|
local container = GUI.addBackgroundContainer(workspace, true, true, locale.view)
|
||||||
@ -571,31 +572,31 @@ end
|
|||||||
|
|
||||||
local imageItem = menu:addContextMenuItem(locale.image)
|
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)
|
window.image.data = image.flipVertically(window.image.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
imageItem:addItem(locale.flipHorizontal).onTouch = function()
|
imageItem:addItem("⬌", locale.flipHorizontal).onTouch = function()
|
||||||
window.image.data = image.flipHorizontally(window.image.data)
|
window.image.data = image.flipHorizontally(window.image.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
imageItem:addSeparator()
|
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.data = image.rotate(window.image.data, 90)
|
||||||
window.image.width = window.image.data[1]
|
window.image.width = window.image.data[1]
|
||||||
window.image.height = window.image.data[2]
|
window.image.height = window.image.data[2]
|
||||||
window.image.reposition()
|
window.image.reposition()
|
||||||
end
|
end
|
||||||
|
|
||||||
imageItem:addItem(locale.rotate180).onTouch = function()
|
imageItem:addItem("⤿", locale.rotate180).onTouch = function()
|
||||||
window.image.data = image.rotate(window.image.data, 180)
|
window.image.data = image.rotate(window.image.data, 180)
|
||||||
window.image.width = window.image.data[1]
|
window.image.width = window.image.data[1]
|
||||||
window.image.height = window.image.data[2]
|
window.image.height = window.image.data[2]
|
||||||
window.image.reposition()
|
window.image.reposition()
|
||||||
end
|
end
|
||||||
|
|
||||||
imageItem:addItem(locale.rotate270).onTouch = function()
|
imageItem:addItem("↺", locale.rotate270).onTouch = function()
|
||||||
window.image.data = image.rotate(window.image.data, 270)
|
window.image.data = image.rotate(window.image.data, 270)
|
||||||
window.image.width = window.image.data[1]
|
window.image.width = window.image.data[1]
|
||||||
window.image.height = window.image.data[2]
|
window.image.height = window.image.data[2]
|
||||||
@ -604,7 +605,7 @@ end
|
|||||||
|
|
||||||
local editItem = menu:addContextMenuItem(locale.edit)
|
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)
|
local container = GUI.addBackgroundContainer(workspace, true, true, locale.hueSaturation)
|
||||||
container.layout:setSpacing(1, 1, 2)
|
container.layout:setSpacing(1, 1, 2)
|
||||||
container.panel.eventHandler = nil
|
container.panel.eventHandler = nil
|
||||||
@ -628,7 +629,7 @@ editItem:addItem(locale.hueSaturation).onTouch = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
editItem:addItem(locale.colorBalance).onTouch = function()
|
editItem:addItem("🌈", locale.colorBalance).onTouch = function()
|
||||||
local container = GUI.addBackgroundContainer(workspace, true, true, locale.colorBalance)
|
local container = GUI.addBackgroundContainer(workspace, true, true, locale.colorBalance)
|
||||||
container.layout:setSpacing(1, 1, 2)
|
container.layout:setSpacing(1, 1, 2)
|
||||||
container.panel.eventHandler = nil
|
container.panel.eventHandler = nil
|
||||||
@ -652,7 +653,7 @@ editItem:addItem(locale.colorBalance).onTouch = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
editItem:addItem(locale.photoFilter).onTouch = function()
|
editItem:addItem("📷", locale.photoFilter).onTouch = function()
|
||||||
local container = GUI.addBackgroundContainer(workspace, true, true, locale.photoFilter)
|
local container = GUI.addBackgroundContainer(workspace, true, true, locale.photoFilter)
|
||||||
container.layout:setSpacing(1, 1, 2)
|
container.layout:setSpacing(1, 1, 2)
|
||||||
container.panel.eventHandler = nil
|
container.panel.eventHandler = nil
|
||||||
@ -674,17 +675,17 @@ end
|
|||||||
|
|
||||||
editItem:addSeparator()
|
editItem:addSeparator()
|
||||||
|
|
||||||
editItem:addItem(locale.invertColors).onTouch = function()
|
editItem:addItem("☻", locale.invertColors).onTouch = function()
|
||||||
window.image.data = image.invert(window.image.data)
|
window.image.data = image.invert(window.image.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
editItem:addItem(locale.blackWhite).onTouch = function()
|
editItem:addItem("🌗", locale.blackWhite).onTouch = function()
|
||||||
window.image.data = image.blackAndWhite(window.image.data)
|
window.image.data = image.blackAndWhite(window.image.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
editItem:addSeparator()
|
editItem:addSeparator()
|
||||||
|
|
||||||
editItem:addItem(locale.gaussianBlur).onTouch = function()
|
editItem:addItem("⧉", locale.gaussianBlur).onTouch = function()
|
||||||
local container = GUI.addBackgroundContainer(workspace, true, true, locale.gaussianBlur)
|
local container = GUI.addBackgroundContainer(workspace, true, true, locale.gaussianBlur)
|
||||||
container.panel.eventHandler = nil
|
container.panel.eventHandler = nil
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ local system = require("System")
|
|||||||
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...)
|
||||||
local localization = system.getSystemLocalization()
|
local localization = system.getSystemLocalization()
|
||||||
|
|
||||||
menu:addItem(localization.setAsWallpaper).onTouch = function()
|
menu:addItem("💻", localization.setAsWallpaper).onTouch = function()
|
||||||
local userSettings = system.getUserSettings()
|
local userSettings = system.getUserSettings()
|
||||||
|
|
||||||
userSettings.interfaceWallpaperPath = icon.path
|
userSettings.interfaceWallpaperPath = icon.path
|
||||||
|
|||||||
@ -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 menu = workspace:addChild(GUI.menu(1, 1, workspace.width, 0xF0F0F0, 0x787878, 0x3366CC, 0xE1E1E1))
|
||||||
local installerMenu = menu:addContextMenuItem("MineOS", 0x2D2D2D)
|
local installerMenu = menu:addContextMenuItem("MineOS", 0x2D2D2D)
|
||||||
|
|
||||||
installerMenu:addItem("Shutdown").onTouch = function()
|
installerMenu:addItem("🗘", "Reboot").onTouch = function()
|
||||||
computer.shutdown()
|
|
||||||
end
|
|
||||||
|
|
||||||
installerMenu:addItem("Reboot").onTouch = function()
|
|
||||||
computer.shutdown(true)
|
computer.shutdown(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
installerMenu:addSeparator()
|
installerMenu:addItem("⏻", "Shutdown").onTouch = function()
|
||||||
|
computer.shutdown()
|
||||||
installerMenu:addItem("Exit").onTouch = function()
|
|
||||||
workspace:stop()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Main vertical layout
|
-- Main vertical layout
|
||||||
|
|||||||
@ -35,14 +35,17 @@ local GUI = {
|
|||||||
SWITCH_ANIMATION_DURATION = 0.3,
|
SWITCH_ANIMATION_DURATION = 0.3,
|
||||||
FILESYSTEM_DIALOG_ANIMATION_DURATION = 0.5,
|
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_BACKGROUND_COLOR = 0x1E1E1E,
|
||||||
|
CONTEXT_MENU_DEFAULT_ICON_COLOR = 0x969696,
|
||||||
|
CONTEXT_MENU_DEFAULT_TEXT_COLOR = 0xD2D2D2,
|
||||||
CONTEXT_MENU_PRESSED_BACKGROUND_COLOR = 0x3366CC,
|
CONTEXT_MENU_PRESSED_BACKGROUND_COLOR = 0x3366CC,
|
||||||
|
CONTEXT_MENU_PRESSED_ICON_COLOR = 0xB4B4B4,
|
||||||
CONTEXT_MENU_PRESSED_TEXT_COLOR = 0xFFFFFF,
|
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_BACKGROUND_TRANSPARENCY = nil,
|
||||||
CONTEXT_MENU_SHADOW_TRANSPARENCY = 0.4,
|
CONTEXT_MENU_SHADOW_TRANSPARENCY = 0.4,
|
||||||
|
CONTEXT_MENU_SEPARATOR_COLOR = 0x0F0F0F,
|
||||||
|
|
||||||
BACKGROUND_CONTAINER_PANEL_COLOR = 0x0,
|
BACKGROUND_CONTAINER_PANEL_COLOR = 0x0,
|
||||||
BACKGROUND_CONTAINER_TITLE_COLOR = 0xE1E1E1,
|
BACKGROUND_CONTAINER_TITLE_COLOR = 0xE1E1E1,
|
||||||
@ -3926,20 +3929,29 @@ local function dropDownMenuItemDraw(item)
|
|||||||
local yText = item.y + math.floor(item.height / 2)
|
local yText = item.y + math.floor(item.height / 2)
|
||||||
|
|
||||||
if item.isTextItem then
|
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
|
local textColor = item.color or item.parent.parent.colors.default.text
|
||||||
|
|
||||||
if item.pressed then
|
if item.pressed then
|
||||||
|
iconColor = item.parent.parent.colors.selected.icon
|
||||||
textColor = item.parent.parent.colors.selected.text
|
textColor = item.parent.parent.colors.selected.text
|
||||||
screen.drawRectangle(item.x, yText, item.width, 1, item.parent.parent.colors.selected.background, textColor, " ")
|
screen.drawRectangle(item.x, yText, item.width, 1, item.parent.parent.colors.selected.background, textColor, " ")
|
||||||
|
|
||||||
elseif item.disabled then
|
elseif item.disabled then
|
||||||
|
iconColor = item.parent.parent.colors.disabled.icon
|
||||||
textColor = item.parent.parent.colors.disabled.text
|
textColor = item.parent.parent.colors.disabled.text
|
||||||
end
|
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)
|
screen.drawText(item.x + item.height, yText, textColor, item.text)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- shortcut
|
||||||
if item.shortcut then
|
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
|
end
|
||||||
else
|
else
|
||||||
screen.drawText(item.x, yText, item.parent.parent.colors.separator, string.rep(item.parent.parent.itemHeight % 2 == 0 and "▁" or "─", item.width))
|
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
|
return menu
|
||||||
end
|
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))
|
local item = menu.itemsContainer:addChild(GUI.object(1, 1, 1, menu.itemHeight))
|
||||||
|
|
||||||
item.text = text
|
if type(a1) == "string" and type(a2) == "string" then
|
||||||
item.disabled = disabled
|
item.icon = a1
|
||||||
item.shortcut = shortcut
|
item.text = a2
|
||||||
item.color = color
|
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.draw = dropDownMenuItemDraw
|
||||||
item.eventHandler = dropDownMenuItemEventHandler
|
item.eventHandler = dropDownMenuItemEventHandler
|
||||||
item.isTextItem = true
|
item.isTextItem = true
|
||||||
@ -4148,20 +4169,40 @@ local function dropDownMenuAdd(parentContainer, menu)
|
|||||||
return container:addChild(menu:releaseItems())
|
return container:addChild(menu:releaseItems())
|
||||||
end
|
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)
|
local menu = GUI.container(x, y, width, 1)
|
||||||
|
|
||||||
menu.colors = {
|
menu.colors = {
|
||||||
default = {
|
default = {
|
||||||
background = backgroundColor,
|
background = backgroundColor,
|
||||||
text = textColor
|
text = textColor,
|
||||||
|
icon = iconColor
|
||||||
},
|
},
|
||||||
selected = {
|
selected = {
|
||||||
background = backgroundPressedColor,
|
background = backgroundPressedColor,
|
||||||
text = textPressedColor
|
text = textPressedColor,
|
||||||
|
icon = iconPressedColor
|
||||||
},
|
},
|
||||||
disabled = {
|
disabled = {
|
||||||
text = disabledColor
|
text = disabledTextColor,
|
||||||
|
icon = disabledIconColor
|
||||||
},
|
},
|
||||||
separator = separatorColor,
|
separator = separatorColor,
|
||||||
transparency = {
|
transparency = {
|
||||||
@ -4200,24 +4241,40 @@ end
|
|||||||
|
|
||||||
local function contextMenuUpdate(menu)
|
local function contextMenuUpdate(menu)
|
||||||
if #menu.itemsContainer.children > 0 then
|
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
|
for i = 1, #menu.itemsContainer.children do
|
||||||
if menu.itemsContainer.children[i].isTextItem then
|
item = menu.itemsContainer.children[i]
|
||||||
widestItem = math.max(widestItem, unicode.wlen(menu.itemsContainer.children[i].text))
|
|
||||||
|
|
||||||
if menu.itemsContainer.children[i].shortcut then
|
if item.isTextItem then
|
||||||
widestShortcut = math.max(widestShortcut, unicode.wlen(menu.itemsContainer.children[i].shortcut))
|
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
|
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)
|
dropDownMenuReposition(menu)
|
||||||
|
|
||||||
local bufferWidth, bufferHeight = screen.getResolution()
|
local bufferWidth, bufferHeight = screen.getResolution()
|
||||||
|
|
||||||
if menu.x + menu.width + 1 >= bufferWidth then
|
if menu.x + menu.width + 1 >= bufferWidth then
|
||||||
menu.localX = bufferWidth - menu.width - 1
|
menu.localX = bufferWidth - menu.width - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if menu.y + menu.height >= bufferHeight then
|
if menu.y + menu.height >= bufferHeight then
|
||||||
menu.localY = bufferHeight - menu.height
|
menu.localY = bufferHeight - menu.height
|
||||||
end
|
end
|
||||||
@ -4226,8 +4283,15 @@ end
|
|||||||
|
|
||||||
local contextMenuCreate, contextMenuaddSubMenuItem
|
local contextMenuCreate, contextMenuaddSubMenuItem
|
||||||
|
|
||||||
contextMenuaddSubMenuItem = function(menu, text, disabled)
|
contextMenuaddSubMenuItem = function(menu, a1, a2, a3)
|
||||||
local item = menu:addItem(text, disabled, "►")
|
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 = contextMenuCreate(1, 1)
|
||||||
item.subMenu.colors = menu.colors
|
item.subMenu.colors = menu.colors
|
||||||
|
|
||||||
@ -4241,14 +4305,20 @@ contextMenuCreate = function(x, y, backgroundColor, textColor, backgroundPressed
|
|||||||
1,
|
1,
|
||||||
math.ceil(screen.getHeight() * 0.7),
|
math.ceil(screen.getHeight() * 0.7),
|
||||||
2,
|
2,
|
||||||
backgroundColor or GUI.CONTEXT_MENU_DEFAULT_BACKGROUND_COLOR,
|
GUI.CONTEXT_MENU_DEFAULT_BACKGROUND_COLOR,
|
||||||
textColor or GUI.CONTEXT_MENU_DEFAULT_TEXT_COLOR,
|
GUI.CONTEXT_MENU_DEFAULT_ICON_COLOR,
|
||||||
backgroundPressedColor or GUI.CONTEXT_MENU_PRESSED_BACKGROUND_COLOR,
|
GUI.CONTEXT_MENU_DEFAULT_TEXT_COLOR,
|
||||||
textPressedColor or GUI.CONTEXT_MENU_PRESSED_TEXT_COLOR,
|
|
||||||
disabledColor or GUI.CONTEXT_MENU_DISABLED_COLOR,
|
GUI.CONTEXT_MENU_PRESSED_BACKGROUND_COLOR,
|
||||||
separatorColor or GUI.CONTEXT_MENU_SEPARATOR_COLOR,
|
GUI.CONTEXT_MENU_PRESSED_ICON_COLOR,
|
||||||
backgroundTransparency or GUI.CONTEXT_MENU_BACKGROUND_TRANSPARENCY,
|
GUI.CONTEXT_MENU_PRESSED_TEXT_COLOR,
|
||||||
shadowTransparency or GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY
|
|
||||||
|
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
|
menu.update = contextMenuUpdate
|
||||||
@ -4368,9 +4438,12 @@ function GUI.comboBox(x, y, width, height, backgroundColor, textColor, arrowBack
|
|||||||
height == 1 and 1 or 2,
|
height == 1 and 1 or 2,
|
||||||
comboBox.colors.default.background,
|
comboBox.colors.default.background,
|
||||||
comboBox.colors.default.text,
|
comboBox.colors.default.text,
|
||||||
|
comboBox.colors.default.text,
|
||||||
comboBox.colors.selected.background,
|
comboBox.colors.selected.background,
|
||||||
comboBox.colors.selected.text,
|
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_SEPARATOR_COLOR,
|
||||||
GUI.CONTEXT_MENU_BACKGROUND_TRANSPARENCY,
|
GUI.CONTEXT_MENU_BACKGROUND_TRANSPARENCY,
|
||||||
GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY
|
GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY
|
||||||
@ -4441,7 +4514,10 @@ local function windowCheck(window, x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...)
|
local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...)
|
||||||
if window.movingEnabled then
|
if not window.movingEnabled then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if e1 == "touch" then
|
if e1 == "touch" then
|
||||||
e3, e4 = math.ceil(e3), math.ceil(e4)
|
e3, e4 = math.ceil(e3), math.ceil(e4)
|
||||||
|
|
||||||
@ -4471,7 +4547,6 @@ local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...)
|
|||||||
window.lastTouchX, window.lastTouchY = nil, nil
|
window.lastTouchX, window.lastTouchY = nil, nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local function windowResize(window, width, height, ignoreOnResizeFinished)
|
local function windowResize(window, width, height, ignoreOnResizeFinished)
|
||||||
window.width, window.height = width, height
|
window.width, window.height = width, height
|
||||||
|
|||||||
@ -337,7 +337,7 @@ end
|
|||||||
local function addMainDesktopMenuItem(menu)
|
local function addMainDesktopMenuItem(menu)
|
||||||
local item = menu:addContextMenuItem("❤", 0xF0F0F0)
|
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)
|
local container = GUI.addBackgroundContainer(workspace, true, true, localization.aboutSystem)
|
||||||
container.layout:removeChildren()
|
container.layout:removeChildren()
|
||||||
|
|
||||||
@ -383,22 +383,22 @@ local function addMainDesktopMenuItem(menu)
|
|||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
item:addItem(localization.updates).onTouch = function()
|
item:addItem("🛒", localization.updates).onTouch = function()
|
||||||
system.execute(paths.system.applicationAppMarket, "updates")
|
system.execute(paths.system.applicationAppMarket, "updates")
|
||||||
end
|
end
|
||||||
|
|
||||||
item:addSeparator()
|
item:addSeparator()
|
||||||
|
|
||||||
item:addItem(localization.logout).onTouch = function()
|
item:addItem("↩", localization.logout).onTouch = function()
|
||||||
system.authorize()
|
system.authorize()
|
||||||
end
|
end
|
||||||
|
|
||||||
item:addItem(localization.reboot).onTouch = function()
|
item:addItem("🗘", localization.reboot).onTouch = function()
|
||||||
require("Network").broadcastComputerState(false)
|
require("Network").broadcastComputerState(false)
|
||||||
computer.shutdown(true)
|
computer.shutdown(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
item:addItem(localization.shutdown).onTouch = function()
|
item:addItem("⏻", localization.shutdown).onTouch = function()
|
||||||
require("Network").broadcastComputerState(false)
|
require("Network").broadcastComputerState(false)
|
||||||
computer.shutdown()
|
computer.shutdown()
|
||||||
end
|
end
|
||||||
@ -473,7 +473,7 @@ local function uploadToPastebin(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function system.addUploadToPastebinMenuItem(menu, path)
|
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)
|
uploadToPastebin(path)
|
||||||
end
|
end
|
||||||
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))
|
local contextMenu = GUI.addContextMenu(workspace, math.ceil(e3), math.ceil(e4))
|
||||||
|
|
||||||
if #selectedIcons > 1 then
|
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)
|
local container = addBackgroundContainerWithInput("", localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")", localization.folderName)
|
||||||
|
|
||||||
container.input.onInputFinished = function()
|
container.input.onInputFinished = function()
|
||||||
@ -784,15 +784,15 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
else
|
else
|
||||||
if icon.isDirectory then
|
if icon.isDirectory then
|
||||||
if icon.extension == ".app" 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")
|
system.execute(paths.system.applicationMineCodeIDE, icon.path .. "Main.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.showPackageContent).onTouch = function()
|
contextMenu:addItem("📂", localization.showPackageContent).onTouch = function()
|
||||||
icon.parent.launchers.showPackageContent(icon)
|
icon.parent.launchers.showPackageContent(icon)
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.launchWithArguments).onTouch = function()
|
contextMenu:addItem("˃", localization.launchWithArguments).onTouch = function()
|
||||||
system.launchWithArguments(icon.path .. "Main.lua")
|
system.launchWithArguments(icon.path .. "Main.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if icon.extension ~= ".app" then
|
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 container = GUI.addBackgroundContainer(workspace, true, true, localization.addToFavourites)
|
||||||
|
|
||||||
local input = addBackgroundContainerInput(container.layout, icon.name, localization.name)
|
local input = addBackgroundContainerInput(container.layout, icon.name, localization.name)
|
||||||
@ -819,7 +819,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if icon.isShortcut then
|
if icon.isShortcut then
|
||||||
contextMenu:addItem(localization.editShortcut).onTouch = function()
|
contextMenu:addItem("🖊", localization.editShortcut).onTouch = function()
|
||||||
local text = system.readShortcut(icon.path)
|
local text = system.readShortcut(icon.path)
|
||||||
local container = addBackgroundContainerWithInput(text, localization.editShortcut, localization.rename)
|
local container = addBackgroundContainerWithInput(text, localization.editShortcut, localization.rename)
|
||||||
|
|
||||||
@ -839,21 +839,23 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.showContainingFolder).onTouch = function()
|
contextMenu:addItem("📂", localization.showContainingFolder).onTouch = function()
|
||||||
icon.parent.launchers.showContainingFolder(icon)
|
icon.parent.launchers.showContainingFolder(icon)
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addSeparator()
|
contextMenu:addSeparator()
|
||||||
else
|
else
|
||||||
local function addDefault()
|
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)
|
uploadToPastebin(icon.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addSeparator()
|
contextMenu:addSeparator()
|
||||||
end
|
end
|
||||||
|
|
||||||
if userSettings.extensions[icon.extension] then
|
if userSettings.extensions[icon.extension] then
|
||||||
local result, reason = loadfile(userSettings.extensions[icon.extension] .. "Extensions/" .. icon.extension .. "/Context menu.lua")
|
local result, reason = loadfile(userSettings.extensions[icon.extension] .. "Extensions/" .. icon.extension .. "/Context menu.lua")
|
||||||
|
|
||||||
if result then
|
if result then
|
||||||
result, reason = pcall(result, workspace, icon, contextMenu)
|
result, reason = pcall(result, workspace, icon, contextMenu)
|
||||||
|
|
||||||
@ -870,7 +872,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Open with
|
-- Open with
|
||||||
local subMenu = contextMenu:addSubMenuItem(localization.openWith)
|
local subMenu = contextMenu:addSubMenuItem("🔎", localization.openWith)
|
||||||
|
|
||||||
local function setAssociation(path)
|
local function setAssociation(path)
|
||||||
userSettings.extensions[icon.extension] = path
|
userSettings.extensions[icon.extension] = path
|
||||||
@ -883,7 +885,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
system.saveUserSettings()
|
system.saveUserSettings()
|
||||||
end
|
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, "/")
|
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)
|
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()
|
subMenu:addSeparator()
|
||||||
|
|
||||||
local list = filesystem.list(paths.system.applications)
|
local list = filesystem.list(paths.system.applications)
|
||||||
|
|
||||||
for i = 1, #list do
|
for i = 1, #list do
|
||||||
local path = paths.system.applications .. list[i]
|
local path = paths.system.applications .. list[i]
|
||||||
|
|
||||||
@ -914,10 +917,10 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not icon.isShortcut or #selectedIcons > 1 then
|
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)
|
local function addShortcutItem(icon, name, pathGetter)
|
||||||
subMenu:addItem(name).onTouch = function()
|
subMenu:addItem(icon, name).onTouch = function()
|
||||||
local selectedIcon
|
local selectedIcon
|
||||||
|
|
||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
@ -935,19 +938,20 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
addShortcutItem(localization.inCurrentDirectory, function(selectedIcon)
|
addShortcutItem("📂", localization.inCurrentDirectory, function(selectedIcon)
|
||||||
return filesystem.path(selectedIcon.path)
|
return filesystem.path(selectedIcon.path)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
addShortcutItem(localization.onDesktop, function(selectedIcon)
|
addShortcutItem("💻", localization.onDesktop, function(selectedIcon)
|
||||||
return paths.user.desktop
|
return paths.user.desktop
|
||||||
end)
|
end)
|
||||||
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 function archive(where)
|
||||||
local itemsToArchive = {}
|
local itemsToArchive = {}
|
||||||
|
|
||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
table.insert(itemsToArchive, selectedIcons[i].path)
|
table.insert(itemsToArchive, selectedIcons[i].path)
|
||||||
end
|
end
|
||||||
@ -961,16 +965,16 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
computer.pushSignal("system", "updateFileList")
|
computer.pushSignal("system", "updateFileList")
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.inCurrentDirectory).onTouch = function()
|
subMenu:addItem("📂", localization.inCurrentDirectory).onTouch = function()
|
||||||
archive(filesystem.path(icon.path))
|
archive(filesystem.path(icon.path))
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.onDesktop).onTouch = function()
|
subMenu:addItem("💻", localization.onDesktop).onTouch = function()
|
||||||
archive(paths.user.desktop)
|
archive(paths.user.desktop)
|
||||||
end
|
end
|
||||||
|
|
||||||
if #selectedIcons == 1 then
|
if #selectedIcons == 1 then
|
||||||
contextMenu:addItem(localization.addToDock).onTouch = function()
|
contextMenu:addItem("📌", localization.addToDock).onTouch = function()
|
||||||
dockContainer.addIcon(icon.path).keepInDock = true
|
dockContainer.addIcon(icon.path).keepInDock = true
|
||||||
dockContainer.saveUserSettings()
|
dockContainer.saveUserSettings()
|
||||||
end
|
end
|
||||||
@ -984,22 +988,23 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
end
|
end
|
||||||
|
|
||||||
system.clipboard = {cut = cut}
|
system.clipboard = {cut = cut}
|
||||||
|
|
||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
selectedIcons[i].cut = cut
|
selectedIcons[i].cut = cut
|
||||||
table.insert(system.clipboard, selectedIcons[i].path)
|
table.insert(system.clipboard, selectedIcons[i].path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.cut).onTouch = function()
|
contextMenu:addItem("✂", localization.cut).onTouch = function()
|
||||||
cutOrCopy(true)
|
cutOrCopy(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.copy).onTouch = function()
|
contextMenu:addItem("⧉", localization.copy).onTouch = function()
|
||||||
cutOrCopy()
|
cutOrCopy()
|
||||||
end
|
end
|
||||||
|
|
||||||
if #selectedIcons == 1 then
|
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)
|
local container = addBackgroundContainerWithInput(filesystem.name(icon.path), localization.rename, localization.newName)
|
||||||
|
|
||||||
container.input.onInputFinished = function()
|
container.input.onInputFinished = function()
|
||||||
@ -1015,16 +1020,15 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
|
|
||||||
|
|
||||||
if icon.path == paths.user.trash then
|
if icon.path == paths.user.trash then
|
||||||
contextMenu:addItem(localization.emptyTrash).onTouch = emptyTrash
|
contextMenu:addItem("🗑", localization.emptyTrash).onTouch = emptyTrash
|
||||||
else
|
else
|
||||||
contextMenu:addItem(localization.delete).onTouch = function()
|
contextMenu:addItem("🗑", localization.delete).onTouch = function()
|
||||||
moveSelectedIconsToTrash(selectedIcons)
|
moveSelectedIconsToTrash(selectedIcons)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if icon.isShortcut then
|
if icon.isShortcut then
|
||||||
contextMenu:addItem(localization.deleteWithSource).onTouch = function()
|
contextMenu:addItem("𝕩", localization.deleteWithSource).onTouch = function()
|
||||||
moveToTrash({
|
moveToTrash({
|
||||||
icon.shortcutPath,
|
icon.shortcutPath,
|
||||||
icon.path
|
icon.path
|
||||||
@ -1034,7 +1038,7 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
|
|
||||||
contextMenu:addSeparator()
|
contextMenu:addSeparator()
|
||||||
|
|
||||||
contextMenu:addItem(localization.properties).onTouch = function()
|
contextMenu:addItem("👀", localization.properties).onTouch = function()
|
||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
system.addPropertiesWindow(math.ceil(e3), math.ceil(e4), 46, selectedIcons[i])
|
system.addPropertiesWindow(math.ceil(e3), math.ceil(e4), 46, selectedIcons[i])
|
||||||
end
|
end
|
||||||
@ -1469,9 +1473,9 @@ end
|
|||||||
local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
||||||
local contextMenu = GUI.addContextMenu(workspace, math.ceil(e3), math.ceil(e4))
|
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)
|
local container = addBackgroundContainerWithInput("", localization.newFile, localization.fileName)
|
||||||
|
|
||||||
container.input.onInputFinished = function()
|
container.input.onInputFinished = function()
|
||||||
@ -1489,7 +1493,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
|||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.newFolder).onTouch = function()
|
subMenu:addItem("📂", localization.newFolder).onTouch = function()
|
||||||
local container = addBackgroundContainerWithInput("", localization.newFolder, localization.folderName)
|
local container = addBackgroundContainerWithInput("", localization.newFolder, localization.folderName)
|
||||||
|
|
||||||
container.input.onInputFinished = function()
|
container.input.onInputFinished = function()
|
||||||
@ -1505,7 +1509,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
|||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.newImage).onTouch = function()
|
subMenu:addItem("📷", localization.newImage).onTouch = function()
|
||||||
local container = addBackgroundContainerWithInput("", localization.newImage, localization.fileName)
|
local container = addBackgroundContainerWithInput("", localization.newImage, localization.fileName)
|
||||||
|
|
||||||
local layout = container.layout:addChild(GUI.layout(1, 1, 36, 3, 1, 1))
|
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()
|
workspace:draw()
|
||||||
end
|
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 container = addBackgroundContainerWithInput("", localization.newFileFromURL, localization.fileName)
|
||||||
|
|
||||||
local inputURL = addBackgroundContainerInput(container.layout, "", "URL", false)
|
local inputURL = addBackgroundContainerInput(container.layout, "", "URL", false)
|
||||||
@ -1592,7 +1596,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
|||||||
|
|
||||||
subMenu:addSeparator()
|
subMenu:addSeparator()
|
||||||
|
|
||||||
subMenu:addItem(localization.newApplication).onTouch = function()
|
subMenu:addItem("💻", localization.newApplication).onTouch = function()
|
||||||
local container = addBackgroundContainerWithInput("", localization.newApplication, localization.applicationName)
|
local container = addBackgroundContainerWithInput("", localization.newApplication, localization.applicationName)
|
||||||
|
|
||||||
container.panel.eventHandler = function(workspace, panel, e1)
|
container.panel.eventHandler = function(workspace, panel, e1)
|
||||||
@ -1620,7 +1624,7 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
|||||||
|
|
||||||
contextMenu:addSeparator()
|
contextMenu:addSeparator()
|
||||||
|
|
||||||
local subMenu = contextMenu:addSubMenuItem(localization.sortBy)
|
local subMenu = contextMenu:addSubMenuItem("⇊", localization.sortBy)
|
||||||
|
|
||||||
local function sortAutomatically()
|
local function sortAutomatically()
|
||||||
if iconField.iconConfigEnabled then
|
if iconField.iconConfigEnabled then
|
||||||
@ -1637,27 +1641,27 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
|||||||
sortAutomatically()
|
sortAutomatically()
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.sortByName).onTouch = function()
|
subMenu:addItem("Aa", localization.sortByName).onTouch = function()
|
||||||
setSortingMethod(filesystem.SORTING_NAME)
|
setSortingMethod(filesystem.SORTING_NAME)
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.sortByDate).onTouch = function()
|
subMenu:addItem("🗓", localization.sortByDate).onTouch = function()
|
||||||
setSortingMethod(filesystem.SORTING_DATE)
|
setSortingMethod(filesystem.SORTING_DATE)
|
||||||
end
|
end
|
||||||
|
|
||||||
subMenu:addItem(localization.sortByType).onTouch = function()
|
subMenu:addItem("🖹", localization.sortByType).onTouch = function()
|
||||||
setSortingMethod(filesystem.SORTING_TYPE)
|
setSortingMethod(filesystem.SORTING_TYPE)
|
||||||
end
|
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()
|
iconField:updateFileList()
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addSeparator()
|
contextMenu:addSeparator()
|
||||||
|
|
||||||
contextMenu:addItem(localization.paste, not system.clipboard).onTouch = function()
|
contextMenu:addItem("⇲", localization.paste, not system.clipboard).onTouch = function()
|
||||||
local i = 1
|
local i = 1
|
||||||
while i <= #system.clipboard do
|
while i <= #system.clipboard do
|
||||||
if filesystem.exists(system.clipboard[i]) then
|
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 name = filesystem.hideExtension(filesystem.name(dockPath))
|
||||||
local contextMenu = window.menu:addContextMenuItem(name, 0xD2D2D2)
|
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()
|
window:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2626,11 +2630,11 @@ function system.updateDesktop()
|
|||||||
if icon.windows then
|
if icon.windows then
|
||||||
local eventData = {...}
|
local eventData = {...}
|
||||||
|
|
||||||
contextMenu:addItem(localization.newWindow).onTouch = function()
|
contextMenu:addItem("➕", localization.newWindow).onTouch = function()
|
||||||
iconOnDoubleClick(icon, e1, e2, e3, e4, table.unpack(eventData))
|
iconOnDoubleClick(icon, e1, e2, e3, e4, table.unpack(eventData))
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.closeAllWindows).onTouch = function()
|
contextMenu:addItem("⛌",localization.closeAllWindows).onTouch = function()
|
||||||
for window in pairs(icon.windows) do
|
for window in pairs(icon.windows) do
|
||||||
window:remove()
|
window:remove()
|
||||||
end
|
end
|
||||||
@ -2639,17 +2643,17 @@ function system.updateDesktop()
|
|||||||
end
|
end
|
||||||
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))
|
system.execute(paths.system.applicationFinder, "-o", filesystem.path(icon.shortcutPath or icon.path))
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addSeparator()
|
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)
|
moveDockIcon(indexOf, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.moveLeft, indexOf <= 1).onTouch = function()
|
contextMenu:addItem("˲", localization.moveLeft, indexOf <= 1).onTouch = function()
|
||||||
moveDockIcon(indexOf, -1)
|
moveDockIcon(indexOf, -1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2657,7 +2661,7 @@ function system.updateDesktop()
|
|||||||
|
|
||||||
if icon.keepInDock then
|
if icon.keepInDock then
|
||||||
if #dockContainer.children > 1 then
|
if #dockContainer.children > 1 then
|
||||||
contextMenu:addItem(localization.removeFromDock).onTouch = function()
|
contextMenu:addItem("📌", localization.removeFromDock).onTouch = function()
|
||||||
if icon.windows then
|
if icon.windows then
|
||||||
icon.keepInDock = nil
|
icon.keepInDock = nil
|
||||||
else
|
else
|
||||||
@ -2671,7 +2675,7 @@ function system.updateDesktop()
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if icon.windows then
|
if icon.windows then
|
||||||
contextMenu:addItem(localization.keepInDock).onTouch = function()
|
contextMenu:addItem("📌", localization.keepInDock).onTouch = function()
|
||||||
icon.keepInDock = true
|
icon.keepInDock = true
|
||||||
dockContainer.saveUserSettings()
|
dockContainer.saveUserSettings()
|
||||||
end
|
end
|
||||||
@ -2709,7 +2713,7 @@ function system.updateDesktop()
|
|||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.emptyTrash).onTouch = emptyTrash
|
contextMenu:addItem("🗑️", localization.emptyTrash).onTouch = emptyTrash
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
@ -2868,11 +2872,11 @@ function system.updateDesktop()
|
|||||||
system.execute(userSettings.interfaceScreensaverPath)
|
system.execute(userSettings.interfaceScreensaverPath)
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
screensaverUptime = computer.uptime()
|
screensaverUptime = computer.uptime()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
system.menuInitialChildren = desktopMenu.children
|
system.menuInitialChildren = desktopMenu.children
|
||||||
system.consoleWindow = nil
|
system.consoleWindow = nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user