diff --git a/.DS_Store b/.DS_Store index 02c3c691..c0c64dbb 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Applications.txt b/Applications.txt index 1f5904b5..e84bceb2 100644 --- a/Applications.txt +++ b/Applications.txt @@ -300,13 +300,13 @@ name="lib/GUI.lua", url="IgorTimofeev/OpenComputers/master/lib/GUI.lua", type="Library", - version=1.37, + version=1.38, }, { name="lib/windows.lua", url="IgorTimofeev/OpenComputers/master/lib/windows.lua", type="Library", - version=1.16, + version=1.17, }, { name="lib/rayEngine.lua", @@ -886,7 +886,7 @@ icon="IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic", createShortcut="dock", forceDownload=true, - version=1.32, + version=1.33, resources={ { name="Localization/Russian.lang", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 9c8b9fcb..bbba48f7 100644 Binary files a/Applications/.DS_Store and b/Applications/.DS_Store differ diff --git a/Applications/MineCodeIDE/Localization/English.lang b/Applications/MineCodeIDE/Localization/English.lang index b26434ae..31256262 100755 --- a/Applications/MineCodeIDE/Localization/English.lang +++ b/Applications/MineCodeIDE/Localization/English.lang @@ -1,4 +1,5 @@ { + pathToFile = "Path to file", selectWord = "Select current word", gotoCyka = "Goto", gotoEnd = "Scroll to end", diff --git a/Applications/MineCodeIDE/Localization/Russian.lang b/Applications/MineCodeIDE/Localization/Russian.lang index 3b72685d..3ae9351c 100755 --- a/Applications/MineCodeIDE/Localization/Russian.lang +++ b/Applications/MineCodeIDE/Localization/Russian.lang @@ -1,4 +1,5 @@ { + pathToFile = "Путь к файлу", selectWord = "Выделить текущее слово", gotoCyka = "Переход", gotoEnd = "В конец", diff --git a/Applications/MineCodeIDE/MineCodeIDE.lua b/Applications/MineCodeIDE/MineCodeIDE.lua index 18730696..c7f63fea 100755 --- a/Applications/MineCodeIDE/MineCodeIDE.lua +++ b/Applications/MineCodeIDE/MineCodeIDE.lua @@ -23,6 +23,7 @@ local unicode = require("unicode") local ecs = require("ECSAPI") local image = require("image") local keyboard = require("keyboard") +local palette = require("palette") ---------------------------------------------------- Constants ---------------------------------------------------- @@ -43,7 +44,7 @@ local colors = { }, title = { default = { - sides = 0x555555, + sides = 0x4B4B4B, background = 0x3C3C3C, text = 0xEEEEEE }, @@ -65,6 +66,7 @@ local config = { cursorSymbol = "┃", cursorBlinkDelay = 0.4, doubleClickDelay = 0.4, + screenScale = 1, } local cursor = { @@ -100,6 +102,7 @@ local function loadConfig() end local function calculateSizes() + mainWindow.width, mainWindow.height = buffer.screen.width, buffer.screen.height mainWindow.leftTreeView.width = math.floor(mainWindow.width * 0.16) if mainWindow.leftTreeView.isHidden then @@ -126,6 +129,8 @@ local function calculateSizes() mainWindow.codeView.height = mainWindow.codeView.height - 3 end + mainWindow.settingsContainer.width, mainWindow.settingsContainer.height = mainWindow.width, mainWindow.height + mainWindow.settingsContainer.backgroundPanel.width, mainWindow.settingsContainer.backgroundPanel.height = mainWindow.settingsContainer.width, mainWindow.settingsContainer.height mainWindow.bottomToolBar.localPosition.y = mainWindow.height - 2 mainWindow.bottomToolBar.findButton.localPosition.x = mainWindow.bottomToolBar.width - mainWindow.bottomToolBar.findButton.width + 1 @@ -139,6 +144,9 @@ local function calculateSizes() mainWindow.toggleLeftToolBarButton.localPosition.x = mainWindow.titleTextBox.localPosition.x + mainWindow.titleTextBox.width + 2 mainWindow.toggleBottomToolBarButton.localPosition.x = mainWindow.toggleLeftToolBarButton.localPosition.x + mainWindow.toggleLeftToolBarButton.width + 2 mainWindow.toggleTopToolBarButton.localPosition.x = mainWindow.toggleBottomToolBarButton.localPosition.x + mainWindow.toggleBottomToolBarButton.width + 2 + + mainWindow.RAMUsageProgressBar.localPosition.x = mainWindow.toggleTopToolBarButton.localPosition.x + mainWindow.toggleTopToolBarButton.width + 3 + mainWindow.RAMUsageProgressBar.width = mainWindow.topToolBar.width - mainWindow.RAMUsageProgressBar.localPosition.x - 3 mainWindow.errorMessage.localPosition.x, mainWindow.errorMessage.width = mainWindow.titleTextBox.localPosition.x, mainWindow.titleTextBox.width mainWindow.errorMessage.backgroundPanel.width, mainWindow.errorMessage.errorTextBox.width = mainWindow.errorMessage.width, mainWindow.errorMessage.width - 4 @@ -146,6 +154,16 @@ local function calculateSizes() mainWindow.topMenu.width = mainWindow.width end +local function changeScale(newScale) + ecs.setScale(newScale) + buffer.start() + calculateSizes() + mainWindow:draw() + buffer.draw() + config.screenScale = newScale + saveConfig() +end + local function showErrorMessage(text) mainWindow.errorMessage.errorTextBox.lines = string.wrap({text}, mainWindow.errorMessage.errorTextBox.width) mainWindow.errorMessage.height = 2 + #mainWindow.errorMessage.errorTextBox.lines @@ -163,6 +181,11 @@ local function hideErrorMessage() mainWindow.errorMessage.isHidden = true end +local function hideSettingsContainer() + for childIndex = 2, #mainWindow.settingsContainer.children do mainWindow.settingsContainer.children[childIndex] = nil end + mainWindow.settingsContainer.isHidden = true +end + local function deselectLastErrorLine() if lastErrorLine then mainWindow.codeView.highlights[lastErrorLine] = nil end end @@ -338,32 +361,31 @@ local function newFile() end local function open() - local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, - {"EmptyLine"}, - {"CenterText", 0x000000, localization.openFile}, - {"EmptyLine"}, - {"Input", 0x262626, 0x880000, ""}, - {"EmptyLine"}, - {"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}} - ) - if data[2] == "OK" and fs.exists(data[1]) then - loadFile(data[1]) + mainWindow.settingsContainer.isHidden = false + local elementWidth = math.floor(mainWindow.width * 0.3) + local x, y = math.floor(mainWindow.width / 2 - elementWidth / 2), math.floor(mainWindow.height / 2) - 3 + mainWindow.settingsContainer:addLabel(1, y, mainWindow.settingsContainer.width, 1, 0xFFFFFF, localization.openFile):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 + local inputTextBox = mainWindow.settingsContainer:addInputTextBox(x, y, elementWidth, 3, 0xCCCCCC, 0x777777, 0xCCCCCC, 0x2D2D2D, "", localization.pathToFile); y = y + 5 + inputTextBox.validator = function(text) + if fs.exists(text) then return true end + end + inputTextBox.onInputFinished = function() + loadFile(inputTextBox.text) + hideSettingsContainer() end end local function saveAs() - local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, - {"EmptyLine"}, - {"CenterText", 0x000000, localization.saveAs}, - {"EmptyLine"}, - {"Input", 0x262626, 0x880000, ""}, - {"EmptyLine"}, - {"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}} - ) - if data[2] == "OK" then - saveFile(data[1]) - mainWindow.leftTreeView.currentFile = data[1] + mainWindow.settingsContainer.isHidden = false + local elementWidth = math.floor(mainWindow.width * 0.3) + local x, y = math.floor(mainWindow.width / 2 - elementWidth / 2), math.floor(mainWindow.height / 2) - 3 + mainWindow.settingsContainer:addLabel(1, y, mainWindow.settingsContainer.width, 1, 0xFFFFFF, localization.saveAs):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 + local inputTextBox = mainWindow.settingsContainer:addInputTextBox(x, y, elementWidth, 3, 0xCCCCCC, 0x777777, 0xCCCCCC, 0x2D2D2D, "", localization.pathToFile); y = y + 5 + inputTextBox.onInputFinished = function() + saveFile(inputTextBox.text) + mainWindow.leftTreeView.currentFile = inputTextBox.text mainWindow.leftTreeView:updateFileList() + hideSettingsContainer() end end @@ -623,24 +645,33 @@ local function indentOrUnindent(isIndent) end end +local function updateRAMProgressBar() + if not mainWindow.topToolBar.isHidden then + local totalMemory = computer.totalMemory() + mainWindow.RAMUsageProgressBar.value = math.ceil((totalMemory - computer.freeMemory()) / totalMemory * 100) + end +end + local function updateTitle() - mainWindow.titleTextBox.lines[1] = string.limit(localization.file .. ": " .. (mainWindow.leftTreeView.currentFile or localization.none), mainWindow.titleTextBox.width - 4) - mainWindow.titleTextBox.lines[2] = string.limit(localization.cursor .. cursor.position.line .. localization.line .. cursor.position.symbol .. localization.symbol, mainWindow.titleTextBox.width - 4) - if mainWindow.codeView.selections[1] then - local countOfSelectedLines = mainWindow.codeView.selections[1].to.line - mainWindow.codeView.selections[1].from.line + 1 - local countOfSelectedSymbols - if mainWindow.codeView.selections[1].from.line == mainWindow.codeView.selections[1].to.line then - countOfSelectedSymbols = unicode.len(unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].from.line], mainWindow.codeView.selections[1].from.symbol, mainWindow.codeView.selections[1].to.symbol)) - else - countOfSelectedSymbols = unicode.len(unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].from.line], mainWindow.codeView.selections[1].from.symbol, -1)) - for line = mainWindow.codeView.selections[1].from.line + 1, mainWindow.codeView.selections[1].to.line - 1 do - countOfSelectedSymbols = countOfSelectedSymbols + unicode.len(mainWindow.codeView.lines[line]) + if not mainWindow.topToolBar.isHidden then + mainWindow.titleTextBox.lines[1] = string.limit(localization.file .. ": " .. (mainWindow.leftTreeView.currentFile or localization.none), mainWindow.titleTextBox.width - 4) + mainWindow.titleTextBox.lines[2] = string.limit(localization.cursor .. cursor.position.line .. localization.line .. cursor.position.symbol .. localization.symbol, mainWindow.titleTextBox.width - 4) + if mainWindow.codeView.selections[1] then + local countOfSelectedLines = mainWindow.codeView.selections[1].to.line - mainWindow.codeView.selections[1].from.line + 1 + local countOfSelectedSymbols + if mainWindow.codeView.selections[1].from.line == mainWindow.codeView.selections[1].to.line then + countOfSelectedSymbols = unicode.len(unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].from.line], mainWindow.codeView.selections[1].from.symbol, mainWindow.codeView.selections[1].to.symbol)) + else + countOfSelectedSymbols = unicode.len(unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].from.line], mainWindow.codeView.selections[1].from.symbol, -1)) + for line = mainWindow.codeView.selections[1].from.line + 1, mainWindow.codeView.selections[1].to.line - 1 do + countOfSelectedSymbols = countOfSelectedSymbols + unicode.len(mainWindow.codeView.lines[line]) + end + countOfSelectedSymbols = countOfSelectedSymbols + unicode.len(unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].to.line], 1, mainWindow.codeView.selections[1].to.symbol)) end - countOfSelectedSymbols = countOfSelectedSymbols + unicode.len(unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].to.line], 1, mainWindow.codeView.selections[1].to.symbol)) + mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. countOfSelectedLines .. localization.lines .. countOfSelectedSymbols .. localization.symbols, mainWindow.titleTextBox.width - 4) + else + mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. localization.none, mainWindow.titleTextBox.width - 4) end - mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. countOfSelectedLines .. localization.lines .. countOfSelectedSymbols .. localization.symbols, mainWindow.titleTextBox.width - 4) - else - mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. localization.none, mainWindow.titleTextBox.width - 4) end end @@ -786,44 +817,50 @@ local function createWindow() item4.onTouch = function() local menu = GUI.contextMenu(item4.x, item4.y + 1) menu:addItem(localization.colorScheme).onTouch = function() - local variants = {} - for key in pairs(config.syntaxColorScheme) do - table.insert(variants, key) - end + mainWindow.settingsContainer.isHidden = false - local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, - {"EmptyLine"}, - {"CenterText", 0x000000, localization.colorScheme}, - {"EmptyLine"}, - {"Selector", 0x262626, 0x880000, table.unpack(variants)}, - {"Color", localization.color, 0x000000}, - {"EmptyLine"}, - {"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}} - ) + local colorSelectorsCount, colorSelectorCountX = 0, 4; for key in pairs(config.syntaxColorScheme) do colorSelectorsCount = colorSelectorsCount + 1 end + local colorSelectorCountY = math.ceil(colorSelectorsCount / colorSelectorCountX) + local colorSelectorWidth, colorSelectorHeight, colorSelectorSpaceX, colorSelectorSpaceY = math.floor(mainWindow.settingsContainer.width / colorSelectorCountX * 0.8), 3, 2, 1 + + local startX, y = math.floor(mainWindow.settingsContainer.width / 2 - (colorSelectorCountX * (colorSelectorWidth + colorSelectorSpaceX) - colorSelectorSpaceX) / 2), math.floor(mainWindow.settingsContainer.height / 2 - (colorSelectorCountY * (colorSelectorHeight + colorSelectorSpaceY) - colorSelectorSpaceY + 3) / 2) + mainWindow.settingsContainer:addLabel(1, y, mainWindow.settingsContainer.width, 1, 0xFFFFFF, localization.colorScheme):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 + local x, counter = startX, 1 - if data[#data] == "OK" then - config.syntaxColorScheme[data[1]] = data[2] - syntax.colorScheme = config.syntaxColorScheme - saveConfig() + for key in pairs(config.syntaxColorScheme) do + local colorSelector = mainWindow.settingsContainer:addColorSelector(x, y, colorSelectorWidth, colorSelectorHeight, config.syntaxColorScheme[key], key) + colorSelector.onTouch = function() + config.syntaxColorScheme[key] = colorSelector.color + syntax.colorScheme = config.syntaxColorScheme + saveConfig() + end + + x, counter = x + colorSelectorWidth + colorSelectorSpaceX, counter + 1 + if counter > colorSelectorCountX then + x, y, counter = startX, y + colorSelectorHeight + colorSelectorSpaceY, 1 + end end end menu:addItem(localization.cursorProperties).onTouch = function() - local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, - {"EmptyLine"}, - {"CenterText", 0x000000, localization.cursorProperties}, - {"EmptyLine"}, - {"Input", 0x262626, 0x880000, config.cursorSymbol}, - {"Color", localization.cursorColor, config.cursorColor}, - {"Slider", 0x262626, 0x880000, 1, 100, config.cursorBlinkDelay * 100, localization.cursorBlinkDelay .. ": ", " ms"}, - {"EmptyLine"}, - {"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}} - ) + mainWindow.settingsContainer.isHidden = false - if data[#data] == "OK" then - config.cursorSymbol = data[1] - config.cursorColor = data[2] - config.cursorBlinkDelay = data[3] / 100 - saveConfig() + local elementWidth = math.floor(mainWindow.width * 0.3) + local x, y = math.floor(mainWindow.width / 2 - elementWidth / 2), math.floor(mainWindow.height / 2) - 7 + mainWindow.settingsContainer:addLabel(1, y, mainWindow.settingsContainer.width, 1, 0xFFFFFF, localization.cursorProperties):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 + local inputTextBox = mainWindow.settingsContainer:addInputTextBox(x, y, elementWidth, 3, 0xCCCCCC, 0x777777, 0xCCCCCC, 0x2D2D2D, config.cursorSymbol, localization.cursorSymbol); y = y + 5 + inputTextBox.validator = function(text) + if unicode.len(text) == 1 then return true end + end + inputTextBox.onInputFinished = function() + config.cursorSymbol = inputTextBox.text; saveConfig() + end + local colorSelector = mainWindow.settingsContainer:addColorSelector(x, y, elementWidth, 3, config.cursorColor, localization.cursorColor); y = y + 5 + colorSelector.onTouch = function() + config.cursorColor = colorSelector.color; saveConfig() + end + local horizontalSlider = mainWindow.settingsContainer:addHorizontalSlider(x, y, elementWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 1, 1000, config.cursorBlinkDelay * 1000, false, localization.cursorBlinkDelay .. ": ", " ms") + horizontalSlider.onValueChanged = function() + config.cursorBlinkDelay = horizontalSlider.value / 1000; saveConfig() end end menu:addSeparator() @@ -868,6 +905,8 @@ local function createWindow() buffer.square(titleTextBox.x + titleTextBox.width - 1, titleTextBox.y, 1, titleTextBox.height, sidesColor, titleTextBox.colors.text, " ") end + mainWindow.RAMUsageProgressBar = mainWindow.topToolBar:addProgressBar(1, 2, 1, 0x777777, 0xBBBBBB, 0xAAAAAA, 50, true, true, "RAM: ", "%") + mainWindow.runButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0x4B4B4B, 0xEEEEEE, 0xCCCCCC, 0x444444, "▷") mainWindow.runButton.onTouch = function() run() @@ -926,6 +965,11 @@ local function createWindow() mainWindow.errorMessage.errorTextBox = mainWindow.errorMessage:addTextBox(3, 2, 1, 1, nil, 0x2D2D2D, {}, 1) hideErrorMessage() + mainWindow.settingsContainer = mainWindow:addContainer(1, 1, 1, 1) + mainWindow.settingsContainer.backgroundPanel = mainWindow.settingsContainer:addPanel(1, 1, mainWindow.settingsContainer.width, mainWindow.settingsContainer.height, 0x0, 30) + mainWindow.settingsContainer.backgroundPanel.onTouch = hideSettingsContainer + mainWindow.settingsContainer.isHidden = true + mainWindow.onAnyEvent = function(eventData) cursor.blinkState = not cursor.blinkState local oldCursorState = cursor.blinkState @@ -1020,6 +1064,12 @@ local function createWindow() -- Delete elseif eventData[4] == 211 then deleteLine(cursor.position.line) + -- + + elseif eventData[4] == 13 then + if config.screenScale > 0.3 then changeScale(config.screenScale - 0.1) end + -- - + elseif eventData[4] == 12 then + if config.screenScale < 1 then changeScale(config.screenScale + 0.1) end end -- Arrows up, down, left, right elseif eventData[4] == 200 then @@ -1084,6 +1134,7 @@ local function createWindow() end updateTitle() + updateRAMProgressBar() mainWindow:draw() if cursor.blinkState then local x, y = mainWindow.codeView.codeAreaPosition + cursor.position.symbol - mainWindow.codeView.fromSymbol + 1, mainWindow.codeView.y + cursor.position.line - mainWindow.codeView.fromLine @@ -1106,8 +1157,9 @@ buffer.start() loadConfig() createWindow() -calculateSizes() +changeScale(config.screenScale) updateTitle() +updateRAMProgressBar() mainWindow:draw() if args[1] == "open" and fs.exists(args[2] or "") then diff --git a/lib/GUI.lua b/lib/GUI.lua index 7ba141ce..70faf885 100755 --- a/lib/GUI.lua +++ b/lib/GUI.lua @@ -85,7 +85,8 @@ GUI.objectTypes = enum( "comboBox", "scrollBar", "codeView", - "treeView" + "treeView", + "colorSelector" ) ----------------------------------------- Primitive objects ----------------------------------------- @@ -358,6 +359,11 @@ local function addTreeViewObjectToContainer(container, ...) return GUI.addChildToContainer(container, GUI.treeView(...), GUI.objectTypes.treeView) end +-- Add ColorSelector object to container +local function addColorSelectorObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.colorSelector(...), GUI.objectTypes.colorSelector) +end + -- Recursively draw container's content including all children container's content local function drawContainerContent(container) for objectIndex = 1, #container.children do @@ -417,6 +423,7 @@ function GUI.container(x, y, width, height) container.addScrollBar = addScrollBarObjectToContainer container.addCodeView = addCodeViewObjectToContainer container.addTreeView = addTreeViewObjectToContainer + container.addColorSelector = addColorSelectorObjectToContainer return container end @@ -1648,19 +1655,7 @@ function GUI.codeView(x, y, width, height, lines, fromSymbol, fromLine, maximumL codeView.draw = codeViewDraw return codeView -end - ------------------------------------------ Color Selector object ----------------------------------------- - -local function colorSelectorDraw(colorSelector) - -end - -function GUI.colorSelector(x, y, width, height, color) - local colorSelector = GUI.object(x, y, width, height) - colorSelector.color = color - colorSelector.draw = colorSelectorDraw -end +end ----------------------------------------- Color Selector object ----------------------------------------- @@ -1763,10 +1758,39 @@ function GUI.treeView(x, y, width, height, backgroundColor, textColor, selection return treeView end +----------------------------------------- Color Selector object ----------------------------------------- + +local function colorSelectorDraw(colorSelector) + local overlayColor = colorSelector.color < 0x7FFFFF and 0xFFFFFF or 0x000000 + buffer.square(colorSelector.x, colorSelector.y, colorSelector.width, colorSelector.height, colorSelector.color, overlayColor, " ") + if colorSelector.pressed then + buffer.square(colorSelector.x, colorSelector.y, colorSelector.width, colorSelector.height, overlayColor, overlayColor, " ", 80) + end + buffer.text(colorSelector.x, colorSelector.y + colorSelector.height - 1, overlayColor, string.rep("▄", colorSelector.width), 80) + buffer.text(colorSelector.x + 1, colorSelector.y + math.floor(colorSelector.height / 2), overlayColor, string.limit(colorSelector.text, colorSelector.width - 2)) + return colorSelector +end + +function GUI.colorSelector(x, y, width, height, color, text) + local colorSelector = GUI.object(x, y, width, height) + colorSelector.color = color + colorSelector.text = text + colorSelector.draw = colorSelectorDraw + return colorSelector +end + -------------------------------------------------------------------------------------------------------------------------------- -- buffer.start() -- buffer.clear(0xFF8888) +-- buffer.draw(true) + +-- local y = 2 +-- for i = 1, 10 do +-- GUI.colorSelector(2, y, 30, 3, math.random(0x0, 0xFFFFFF), "Типа цвет " .. i):draw() +-- y = y + 4 +-- end +-- buffer.draw() -- local lines = {} -- local file = io.open("/OS.lua", "r") diff --git a/lib/windows.lua b/lib/windows.lua index 24a2b613..b209cab7 100755 --- a/lib/windows.lua +++ b/lib/windows.lua @@ -175,6 +175,13 @@ local function treeViewHandler(window, object, objectIndex, eventData) end end +local function colorSelectorHandler(window, object, objectIndex, eventData) + object.pressed = true; object:draw(); buffer.draw() + object.color = require("palette").show("auto", "auto", object.color) or object.color + object.pressed = false; object:draw(); buffer.draw() + executeObjectMethod(object.onTouch) +end + function windows.handleEventData(window, eventData) if eventData[1] == "touch" then local object, objectIndex = window:getClickedObject(eventData[3], eventData[4]) @@ -198,6 +205,8 @@ function windows.handleEventData(window, eventData) scrollBarHandler(window, object, objectIndex, eventData) elseif object.type == GUI.objectTypes.treeView then treeViewHandler(window, object, objectIndex, eventData) + elseif object.type == GUI.objectTypes.colorSelector then + colorSelectorHandler(window, object, objectIndex, eventData) elseif object.onTouch then executeObjectMethod(object.onTouch, eventData) end @@ -334,6 +343,12 @@ end -- buffer.clear(0xFF8888) -- buffer.draw(true) +-- local myWindow = windows.empty(2, 2, 60, 30, 60, 30) +-- myWindow:addColorSelector(2, 2, 30, 3, 0xFF00FF, "Text") +-- myWindow:draw() +-- buffer.draw() +-- myWindow:handleEvents() + -- 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()