This commit is contained in:
Igor Timofeev 2017-01-16 06:50:08 +03:00
parent 4bdf05ed5f
commit e2cac07ae3
6 changed files with 58 additions and 63 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -300,13 +300,13 @@
name="lib/GUI.lua",
url="IgorTimofeev/OpenComputers/master/lib/GUI.lua",
type="Library",
version=1.34,
version=1.35,
},
{
name="lib/windows.lua",
url="IgorTimofeev/OpenComputers/master/lib/windows.lua",
type="Library",
version=1.14,
version=1.15,
},
{
name="lib/rayEngine.lua",
@ -886,7 +886,7 @@
icon="IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic",
createShortcut="dock",
forceDownload=true,
version=1.21,
version=1.22,
resources={
{
name="Localization/Russian.lang",

BIN
Applications/.DS_Store vendored

Binary file not shown.

View File

@ -44,8 +44,8 @@ local config = {
},
title = {
default = {
background = 0xCCCCCC,
text = 0x444444
background = 0x3C3C3C,
text = 0xEEEEEE
},
warning = {
background = 0x880000,
@ -650,6 +650,7 @@ end
local function toggleBottomToolBar()
mainWindow.bottomToolBar.isHidden = not mainWindow.bottomToolBar.isHidden
mainWindow.toggleBottomToolBarButton.pressed = not mainWindow.bottomToolBar.isHidden
calculateSizes()
if not mainWindow.bottomToolBar.isHidden then
@ -661,11 +662,13 @@ end
local function toggleTopToolBar()
mainWindow.topToolBar.isHidden = not mainWindow.topToolBar.isHidden
mainWindow.toggleTopToolBarButton.pressed = not mainWindow.topToolBar.isHidden
calculateSizes()
end
local function toggleLeftToolBar()
mainWindow.leftTreeView.isHidden = not mainWindow.leftTreeView.isHidden
mainWindow.toggleLeftToolBarButton.pressed = not mainWindow.leftTreeView.isHidden
calculateSizes()
end
@ -801,30 +804,37 @@ local function createWindow()
mainWindow.topToolBar = mainWindow:addContainer(1, 2, 1, 3)
mainWindow.topToolBar.backgroundPanel = mainWindow.topToolBar:addPanel(1, 1, 1, 3, config.colorScheme.topToolBar)
mainWindow.titleTextBox = mainWindow.topToolBar:addTextBox(1, 1, 1, 3, 0x0, 0x0, {}, 1):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
mainWindow.runButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0xBBBBBB, 0x2D2D2D, "")
mainWindow.runButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0x4B4B4B, 0xEEEEEE, 0xCCCCCC, 0x444444, "")
mainWindow.runButton.onTouch = function()
run()
end
mainWindow.toggleSyntaxHighlightingButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0xBBBBBB, 0x2D2D2D, "*")
mainWindow.toggleSyntaxHighlightingButton.switchMode = true
mainWindow.toggleSyntaxHighlightingButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x5A5A5A, 0xEEEEEE, "*")
mainWindow.toggleSyntaxHighlightingButton.switchMode, mainWindow.toggleSyntaxHighlightingButton.pressed = true, true
mainWindow.toggleSyntaxHighlightingButton.onTouch = function()
mainWindow.codeView.highlightLuaSyntax = not mainWindow.codeView.highlightLuaSyntax
end
mainWindow.toggleLeftToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0xBBBBBB, 0x2D2D2D, "")
mainWindow.toggleLeftToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x4B4B4B, 0xEEEEEE, "")
mainWindow.toggleLeftToolBarButton.switchMode, mainWindow.toggleLeftToolBarButton.pressed = true, true
mainWindow.toggleLeftToolBarButton.onTouch = function()
toggleLeftToolBar()
mainWindow.leftTreeView.isHidden = not mainWindow.toggleLeftToolBarButton.pressed
calculateSizes()
end
mainWindow.toggleBottomToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0xBBBBBB, 0x2D2D2D, "")
mainWindow.toggleBottomToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x5A5A5A, 0xEEEEEE, "")
mainWindow.toggleBottomToolBarButton.switchMode, mainWindow.toggleBottomToolBarButton.pressed = true, false
mainWindow.toggleBottomToolBarButton.onTouch = function()
toggleBottomToolBar()
mainWindow.bottomToolBar.isHidden = not mainWindow.toggleBottomToolBarButton.pressed
calculateSizes()
end
mainWindow.toggleTopToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0xBBBBBB, 0x2D2D2D, "")
mainWindow.toggleTopToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x696969, 0xEEEEEE, "")
mainWindow.toggleTopToolBarButton.switchMode, mainWindow.toggleTopToolBarButton.pressed = true, true
mainWindow.toggleTopToolBarButton.onTouch = function()
toggleTopToolBar()
mainWindow.topToolBar.isHidden = not mainWindow.toggleTopToolBarButton.pressed
calculateSizes()
end
mainWindow.bottomToolBar = mainWindow:addContainer(1, 1, 1, 1)

View File

@ -1664,40 +1664,23 @@ end
----------------------------------------- Color Selector object -----------------------------------------
local function updateFileList(xOffset, path, fileList, fileListIndex)
local fileCounter = 1
local function updateFileList(treeView, xOffset, path)
for file in fs.list(path) do
if fileList[fileListIndex] then
if fileList[fileListIndex].path == path .. file then
if fileList[fileListIndex].showDirectoryContent then
fileListIndex = updateFileList(xOffset + 2, path .. file, fileList, fileListIndex + 1) - 1
end
else
fileList[fileListIndex] = {}
fileList[fileListIndex].path = path .. file
fileList[fileListIndex].isDirectory = fs.isDirectory(fileList[fileListIndex].path)
fileList[fileListIndex].xOffset = xOffset
end
else
fileList[fileListIndex] = {}
fileList[fileListIndex].path = path .. file
fileList[fileListIndex].isDirectory = fs.isDirectory(fileList[fileListIndex].path)
fileList[fileListIndex].xOffset = xOffset
end
local element = {}
element.path = path .. file
element.xOffset = xOffset
element.isDirectory = fs.isDirectory(element.path)
table.insert(treeView.fileList, element)
fileListIndex = fileListIndex + 1
if treeView.directoriesToShowContent[element.path] then
updateFileList(treeView, xOffset + 2, path .. file)
end
end
return fileListIndex
end
local function treeViewUpdateFileList(treeView)
local fileListIndex = updateFileList(1, treeView.path, treeView.fileList, 1)
for i = fileListIndex, #treeView.fileList do
treeView.fileList[i] = nil
end
treeView.fileList = {}
updateFileList(treeView, 1, treeView.workPath)
return treeView
end
@ -1705,38 +1688,35 @@ end
local function treeViewDraw(treeView)
local y = treeView.y + 1
local showScrollBar = #treeView.fileList > treeView.height
local textLimit = treeView.width - (showScrollBar and 2 or 1)
if treeView.colors.default.background then
buffer.square(treeView.x, treeView.y, treeView.width, treeView.height, treeView.colors.default.background, treeView.colors.default.text, " ")
end
local drawLimit = buffer.getDrawLimit(); buffer.setDrawLimit(treeView.x, treeView.y, treeView.width - (showScrollBar and 1 or 0), treeView.height)
for fileListIndex = treeView.fromFile, #treeView.fileList do
for fileIndex = treeView.fromFile, #treeView.fileList do
local textColor = treeView.colors.default.text
if treeView.fileList[fileListIndex].path == treeView.currentFile then
if treeView.fileList[fileIndex].path == treeView.currentFile then
textColor = treeView.colors.selected.text
buffer.square(treeView.x, y, treeView.width, 1, treeView.colors.selected.background, textColor, " ")
end
if treeView.fileList[fileListIndex].isDirectory then
if treeView.fileList[fileListIndex].showDirectoryContent then
buffer.text(treeView.x + treeView.fileList[fileListIndex].xOffset, y, treeView.colors.arrow, "")
buffer.text(treeView.x + treeView.fileList[fileListIndex].xOffset + 2, y, textColor, "" .. fs.name(treeView.fileList[fileListIndex].path))
if treeView.fileList[fileIndex].isDirectory then
if treeView.fileList[fileIndex].showDirectoryContent then
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset, y, treeView.colors.arrow, "")
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset + 2, y, textColor, unicode.sub("" .. fs.name(treeView.fileList[fileIndex].path), 1, textLimit - treeView.fileList[fileIndex].xOffset - 2))
else
buffer.text(treeView.x + treeView.fileList[fileListIndex].xOffset, y, treeView.colors.arrow, "")
buffer.text(treeView.x + treeView.fileList[fileListIndex].xOffset + 2, y, textColor, "" .. fs.name(treeView.fileList[fileListIndex].path))
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset, y, treeView.colors.arrow, "")
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset + 2, y, textColor, unicode.sub("" .. fs.name(treeView.fileList[fileIndex].path), 1, textLimit - treeView.fileList[fileIndex].xOffset - 2))
end
else
buffer.text(treeView.x + treeView.fileList[fileListIndex].xOffset, y, textColor, "" .. fs.name(treeView.fileList[fileListIndex].path))
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset, y, textColor, unicode.sub("" .. fs.name(treeView.fileList[fileIndex].path), 1, textLimit - treeView.fileList[fileIndex].xOffset))
end
y = y + 1
if y > treeView.y + treeView.height - 2 then break end
end
buffer.setDrawLimit(drawLimit)
if showScrollBar then
GUI.scrollBar(
treeView.x + treeView.width - 1,
@ -1774,8 +1754,9 @@ function GUI.treeView(x, y, width, height, backgroundColor, textColor, selection
},
arrow = arrowColor
}
treeView.directoriesToShowContent = {}
treeView.fileList = {}
treeView.path = workPath
treeView.workPath = workPath
treeView.updateFileList = treeViewUpdateFileList
treeView.draw = treeViewDraw

View File

@ -144,16 +144,20 @@ end
local function treeViewHandler(window, object, objectIndex, eventData)
if eventData[1] == "touch" then
local fileListIndex = eventData[4] - object.y + object.fromFile - 1
if object.fileList[fileListIndex] then
if object.fileList[fileListIndex].isDirectory then
object.fileList[fileListIndex].showDirectoryContent = not object.fileList[fileListIndex].showDirectoryContent
local fileIndex = eventData[4] - object.y + object.fromFile - 1
if object.fileList[fileIndex] then
if object.fileList[fileIndex].isDirectory then
if object.directoriesToShowContent[object.fileList[fileIndex].path] then
object.directoriesToShowContent[object.fileList[fileIndex].path] = nil
else
object.directoriesToShowContent[object.fileList[fileIndex].path] = true
end
object:updateFileList()
object:draw(); buffer.draw()
else
object.currentFile = object.fileList[fileListIndex].path
executeObjectMethod(object.onFileSelected, object.currentFile)
object.currentFile = object.fileList[fileIndex].path
object:draw(); buffer.draw()
executeObjectMethod(object.onFileSelected, object.currentFile)
end
end
elseif eventData[1] == "scroll" then
@ -326,7 +330,7 @@ end
-- buffer.clear(0xFF8888)
-- buffer.draw(true)
-- local myWindow = windows.empty(2, 2, 40, 30, 30, 40)
-- local myWindow = windows.empty(2, 2, 20, 40, 20, 40)
-- myWindow:addTreeView(1, 1, myWindow.width, myWindow.height, 0xDDDDDD, 0x2D2D2D, 0x2D2D2D, 0xEEEEEE, 0x555555, 0x444444, 0x00DBFF, "/")
-- myWindow:draw()
-- buffer.draw()