Какая-то хуйня

This commit is contained in:
Igor Timofeev 2019-01-25 08:24:34 +03:00
parent 8a76fd8a3b
commit 9b8b11ca2c
16 changed files with 130 additions and 69 deletions

View File

@ -30,9 +30,37 @@ local savePath
local saveItem
local tool
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 125, 37, 0x1E1E1E))
--------------------------------------------------------------------
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 125, 37, 0x1E1E1E))
window.newInput = function(...)
return GUI.input(1, 1, 1, 1, 0x1E1E1E, 0xC3C3C3, 0x5A5A5A, 0x1E1E1E, 0xD2D2D2, ...)
end
window.newSlider = function(...)
local slider = GUI.slider(1, 1, 1, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, ...)
slider.roundValues = true
return slider
end
window.newSwitch = function(...)
return GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, ...)
end
window.newButton1 = function(...)
return GUI.roundedButton(1, 1, 36, 1, 0xE1E1E1, 0x4B4B4B, 0x4B4B4B, 0xE1E1E1, ...)
end
window.newButton2 = function(...)
local button = GUI.roundedButton(1, 1, 36, 1, 0x4B4B4B, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, ...)
button.colors.disabled.background, button.colors.disabled.text = 0x4B4B4B, 0x787878
return button
end
--------------------------------------------------------------------
local function saveConfig()
filesystem.writeTable(configPath, config)
@ -137,8 +165,6 @@ window.toolsList:setMargin(0, 3)
window.image = window:addChild(GUI.object(1, 1, 1, 1))
window.image.data = {}
local function onToolTouch(index)
tool = window.toolsList:getItem(index).tool
@ -292,13 +318,29 @@ window.image.eventHandler = function(workspace, object, e1, e2, e3, e4, ...)
end
end
window.image.setPosition = function(x, y)
window.image.localX = x
window.image.localY = y
window.currentToolOverlay.localX = x
window.currentToolOverlay.localY = y
end
window.image.reposition = function()
window.image.width, window.image.height = window.image.data[1], window.image.data[2]
if window.image.width <= window.backgroundPanel.width then
window.image.localX = math.floor(window.backgroundPanel.localX + window.backgroundPanel.width / 2 - window.image.width / 2)
window.image.localY = math.floor(window.backgroundPanel.localY + window.backgroundPanel.height / 2 - window.image.height / 2)
window.image.width = window.image.data[1]
window.image.height = window.image.data[2]
window.currentToolOverlay.width = window.image.width
window.currentToolOverlay.height = window.image.height
if window.image.width < window.backgroundPanel.width then
window.image.setPosition(
math.floor(window.backgroundPanel.localX + window.backgroundPanel.width / 2 - window.image.width / 2),
math.floor(window.backgroundPanel.localY + window.backgroundPanel.height / 2 - window.image.height / 2)
)
else
window.image.localX, window.image.localY = window.backgroundPanel.localX, window.backgroundPanel.localY
window.image.setPosition(
window.backgroundPanel.localX,
window.backgroundPanel.localY
)
end
end
@ -512,9 +554,6 @@ window.onResize = function(width, height)
window.backgroundPanel.width = width - window.sidebarLayout.width - window.toolsList.width
window.backgroundPanel.height = height
window.currentToolOverlay.width = width
window.currentToolOverlay.height = height
window.sidebarPanel.localX = window.width - window.sidebarPanel.width + 1
window.sidebarPanel.height = height

View File

@ -14,24 +14,24 @@ tool.about = "Selection tool allows you to select preferred area on image and to
local selector, touchX, touchY, dragX, dragY = GUI.object(1, 1, 1, 1)
local fillButton = GUI.roundedButton(1, 1, 36, 1, 0xE1E1E1, 0x2D2D2D, 0x2D2D2D, 0xE1E1E1, "Fill")
local outlineButton = GUI.roundedButton(1, 1, 36, 1, 0xE1E1E1, 0x2D2D2D, 0x2D2D2D, 0xE1E1E1, "Outline")
local rasterizeLineButton = GUI.roundedButton(1, 1, 36, 1, 0xE1E1E1, 0x2D2D2D, 0x2D2D2D, 0xE1E1E1, "Rasterize line")
local rasterizeEllipseButton = GUI.roundedButton(1, 1, 36, 1, 0xE1E1E1, 0x2D2D2D, 0x2D2D2D, 0xE1E1E1, "Rasterize ellipse")
local clearButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Clear")
local cropButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Crop")
local fillButton = window.newButton1("Fill")
local outlineButton = window.newButton1("Outline")
local rasterizeLineButton = window.newButton1("Rasterize line")
local rasterizeEllipseButton = window.newButton1("Rasterize ellipse")
local clearButton = window.newButton2("Clear")
local cropButton = window.newButton2("Crop")
local function repositionSelector()
if dragX - touchX >= 0 then
selector.localX, selector.width = touchX - window.x + 1, dragX - touchX + 1
selector.localX, selector.width = touchX - window.currentToolOverlay.x + 1, dragX - touchX + 1
else
selector.localX, selector.width = dragX - window.x + 1, touchX - dragX + 1
selector.localX, selector.width = dragX - window.currentToolOverlay.x + 1, touchX - dragX + 1
end
if dragY - touchY >= 0 then
selector.localY, selector.height = touchY - window.y + 1, dragY - touchY + 1
selector.localY, selector.height = touchY - window.currentToolOverlay.y + 1, dragY - touchY + 1
else
selector.localY, selector.height = dragY - window.y + 1, touchY - dragY + 1
selector.localY, selector.height = dragY - window.currentToolOverlay.y + 1, touchY - dragY + 1
end
workspace:draw()
@ -154,8 +154,8 @@ selector.draw = function()
screen.drawText(selector.x + selector.width - 1, selector.y, 0x0, "")
screen.drawText(selector.x, selector.y + selector.height - 1, 0x0, "")
screen.drawText(touchX, touchY, 0x66FF80, "")
screen.drawText(dragX, dragY, 0x66FF80, "")
screen.drawText(selector.x, selector.y, 0x66FF80, "")
screen.drawText(selector.x + selector.width - 1, selector.y + selector.height - 1, 0x66FF80, "")
end
------------------------------------------------------

View File

@ -15,8 +15,10 @@ tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" then
xOld, yOld = e3, e4
elseif e1 == "drag" and xOld and yOld then
window.image.localX = window.image.localX + (e3 - xOld)
window.image.localY = window.image.localY + (e4 - yOld)
window.image.setPosition(
window.image.localX + (e3 - xOld),
window.image.localY + (e4 - yOld)
)
xOld, yOld = e3, e4
workspace:draw()

View File

@ -18,14 +18,11 @@ local buttonsLayout = GUI.layout(1, 1, buttonsContainer.width, buttonsContainer.
buttonsLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
buttonsLayout:addChild(buttonsContainer)
local widthInput = GUI.input(1, 1, 1, 1, 0x1E1E1E, 0xC3C3C3, 0x5A5A5A, 0x1E1E1E, 0xD2D2D2, "", "Width")
local heightInput = GUI.input(1, 1, 1, 1, 0x1E1E1E, 0xC3C3C3, 0x5A5A5A, 0x1E1E1E, 0xD2D2D2, "", "Height")
local widthInput = window.newInput("", "Width")
local heightInput = window.newInput("", "Height")
local expandButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Expand")
local cropButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Crop")
expandButton.colors.disabled.background, expandButton.colors.disabled.text = 0x4B4B4B, 0x787878
cropButton.colors = expandButton.colors
local expandButton = window.newButton2("Expand")
local cropButton = window.newButton2("Crop")
local function try(x, y, symbol)
if buttons[y] and buttons[y][x] then

View File

@ -11,8 +11,8 @@ tool.shortcut = "Pck"
tool.keyCode = 56
tool.about = "Picker tool allows to select interested data from image as primary or secondary color. You can configure of what colors to pick."
local pickBackgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Pick background:", true)
local pickForegroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Pick foreground:", true)
local pickBackgroundSwitch = window.newSwitch("Pick background:", true)
local pickForegroundSwitch = window.newSwitch("Pick foreground:", true)
tool.onSelection = function()
window.currentToolLayout:addChild(pickBackgroundSwitch)

View File

@ -12,22 +12,19 @@ tool.shortcut = "Brs"
tool.keyCode = 48
tool.about = "Classic brush tool to perform drawing with specified radius and transparency. You can configure of what data will be drawn. Also you can specify preferred symbol to draw with, otherwise whitespace will be used."
local backgroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw background:", true)
local foregroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw foreground:", true)
local alphaSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw alpha:", true)
local symbolSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw symbol:", true)
local backgroundSwitch = window.newSwitch("Draw background:", true)
local foregroundSwitch = window.newSwitch("Draw foreground:", true)
local alphaSwitch = window.newSwitch("Draw alpha:", true)
local symbolSwitch = window.newSwitch("Draw symbol:", true)
local symbolInput = GUI.input(1, 1, 1, 1, 0x1E1E1E, 0xC3C3C3, 0x5A5A5A, 0x1E1E1E, 0xD2D2D2, "", "Symbol to draw with")
local symbolInput = window.newInput("", "Symbol to draw with")
symbolInput.onInputFinished = function()
symbolInput.text = unicode.sub(symbolInput.text, 1, 1)
end
local alphaSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, 0, 255, 0, false, "Alpha value: ", "")
alphaSlider.roundValues = true
local radiusSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, 1, 8, 1, false, "Radius: ", " px")
local alphaSlider = window.newSlider(0, 255, 0, false, "Alpha value: ", "")
local radiusSlider = window.newSlider(1, 8, 1, false, "Radius: ", " px")
radiusSlider.height = 2
radiusSlider.roundValues = true
tool.onSelection = function()
window.currentToolLayout:addChild(backgroundSwitch)

View File

@ -11,13 +11,12 @@ tool.shortcut = "Ers"
tool.keyCode = 18
tool.about = "Eraser tool will cleanup pixels just like brush tool. You can configure of what data is need to be erased"
local backgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase background:", true)
local foregroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase foreground:", true)
local alphaSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase alpha:", true)
local symbolSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase symbol:", true)
local radiusSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, 1, 8, 1, false, "Radius: ", " px")
local backgroundSwitch = window.newSwitch("Erase background:", true)
local foregroundSwitch = window.newSwitch("Erase foreground:", true)
local alphaSwitch = window.newSwitch("Erase alpha:", true)
local symbolSwitch = window.newSwitch("Erase symbol:", true)
local radiusSlider = window.newSlider(1, 8, 1, false, "Radius: ", " px")
radiusSlider.height = 2
radiusSlider.roundValues = true
tool.onSelection = function()
window.currentToolLayout:addChild(backgroundSwitch)

View File

@ -33,7 +33,7 @@ for y = 1, 8, 2 do
step = not step
end
local backgroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw background:", false)
local backgroundSwitch = window.newSwitch("Draw background:", false)
tool.onSelection = function()
window.currentToolLayout:addChild(layout)

View File

@ -35,10 +35,13 @@
appearanceColorScheme = "Color scheme",
appearanceFiles = "File properties",
appearanceDesktopBackground = "Desktop background",
appearanceDock = "Dock color",
appearanceMenu = "Menu",
appearanceDock = "Dock background",
appearanceMenu = "Menu background",
appearanceTransparencyEnabled = "Interface transparency",
appearanceTransparencyInfo = "Disabling the last two options will significantly reduce the number of direct calls to the CPU / GPU and increase performance",
appearanceDropDownDefaultBackground = "Drop down menu background",
appearanceDropDownDefaultText = "Drop down menu text",
appearanceDropDownSeparator = "Drop down menu separator",
users = "Users",

View File

@ -39,6 +39,9 @@
appearanceMenu = "Couleur du menu",
appearanceTransparencyEnabled = "Transparence de l'interface",
appearanceTransparencyInfo = "La désactivation des deux dernières options réduira considérablement le nombre d'appels directs au processeur / processeur graphique et augmentera les performances.",
appearanceDropDownDefaultBackground = "Menu déroulant arrière-plan",
appearanceDropDownDefaultText = "Menu déroulant texte",
appearanceDropDownSeparator = "Menu déroulant séparateur",
users = "Liste des membres",

View File

@ -39,6 +39,9 @@
appearanceMenu = "Menü",
appearanceTransparencyEnabled = "Interface Transparenz",
appearanceTransparencyInfo = "Das deaktivieren der letzten beiden Optionen reduziert die Anzahl der direkten Aufrufe an die CPU / GPU erheblich und erhöht die Leistung",
appearanceDropDownDefaultBackground = "Dropdown-Menü hintergrund",
appearanceDropDownDefaultText = "Dropdown-Menü text",
appearanceDropDownSeparator = "Dropdown-Menü Trennzeichen",
users = "Internetnutzer",

View File

@ -39,6 +39,9 @@
appearanceMenu = "Menu",
appearanceTransparencyEnabled = "Trasparenza interfaccia",
appearanceTransparencyInfo = "Disabilitare le ultime due opzioni ridurrà significativamente il numero di chiamate dirette alla CPU / GPU e aumenterà le prestazioni",
appearanceDropDownDefaultBackground = "Sfondo menu a discesa",
appearanceDropDownDefaultText = "Testo menu a discesa",
appearanceDropDownSeparator = "Separatore menu a discesa",
users = "Internauti",

View File

@ -39,6 +39,9 @@
appearanceMenu = "Цвет меню",
appearanceTransparencyEnabled = "Прозрачность интерфейса",
appearanceTransparencyInfo = "Отключение последних двух опций существенно снизит количество прямых обращений к CPU/GPU и увеличит производительность",
appearanceDropDownDefaultBackground = "Фон контекстного меню",
appearanceDropDownDefaultText = "Текст контекстного меню",
appearanceDropDownSeparator = "Разделитель контекстного меню",
users = "Пользователи",

View File

@ -39,6 +39,9 @@
appearanceMenu = "Колір меню",
appearanceTransparencyEnabled = "Прозорість інтерфейсу",
appearanceTransparencyInfo = "Відключення останніх двох опцій істотно знизить кількість прямих звернень до CPU / GPU і збільшить продуктивність",
appearanceDropDownDefaultBackground = "Випадаюче меню фон",
appearanceDropDownDefaultText = "Випадаюче меню текст",
appearanceDropDownSeparator = "Роздільник спадного меню",
users = "Користувачі",

View File

@ -24,23 +24,23 @@ module.onTouch = function()
window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.appearanceColorScheme))
local backgroundColorSelector = window.contentLayout:addChild(GUI.colorSelector(1, 1, 36, 3, userSettings.interfaceColorDesktopBackground, localization.appearanceDesktopBackground))
local menuColorSelector = window.contentLayout:addChild(GUI.colorSelector(1, 1, 36, 3, userSettings.interfaceColorMenu, localization.appearanceMenu))
local dockColorSelector = window.contentLayout:addChild(GUI.colorSelector(1, 1, 36, 3, userSettings.interfaceColorDock, localization.appearanceDock))
local function addColorSelector(key, ...)
local c = window.contentLayout:addChild(GUI.colorSelector(1, 1, 36, 1, userSettings[key], ...))
c.onColorSelected = function()
userSettings[key] = c.color
backgroundColorSelector.onColorSelected = function()
userSettings.interfaceColorDesktopBackground = backgroundColorSelector.color
userSettings.interfaceColorMenu = menuColorSelector.color
userSettings.interfaceColorDock = dockColorSelector.color
userSettings.interfaceTransparencyEnabled = transparencySwitch.state
system.updateColorScheme()
workspace:draw()
system.saveUserSettings()
system.updateColorScheme()
workspace:draw()
system.saveUserSettings()
end
end
menuColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
dockColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
transparencySwitch.onStateChanged = backgroundColorSelector.onColorSelected
addColorSelector("interfaceColorDesktopBackground", localization.appearanceDesktopBackground)
addColorSelector("interfaceColorMenu", localization.appearanceMenu)
addColorSelector("interfaceColorDock", localization.appearanceDock)
addColorSelector("interfaceColorDropDownMenuDefaultBackground", localization.appearanceDropDownDefaultBackground)
addColorSelector("interfaceColorDropDownMenuDefaultText", localization.appearanceDropDownDefaultText)
addColorSelector("interfaceColorDropDownMenuSeparator", localization.appearanceDropDownSeparator)
window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.appearanceSize))
@ -79,11 +79,13 @@ module.onTouch = function()
userSettings.filesShowExtension = showExtensionSwitch.state
userSettings.filesShowHidden = showHiddenFilesSwitch.state
userSettings.filesShowApplicationIcon = showApplicationIconsSwitch.state
userSettings.interfaceTransparencyEnabled = transparencySwitch.state
system.updateColorScheme()
system.saveUserSettings()
computer.pushSignal("system", "updateFileList")
end
showHiddenFilesSwitch.onStateChanged, showApplicationIconsSwitch.onStateChanged = showExtensionSwitch.onStateChanged, showExtensionSwitch.onStateChanged
showHiddenFilesSwitch.onStateChanged, showApplicationIconsSwitch.onStateChanged, transparencySwitch.onStateChanged = showExtensionSwitch.onStateChanged, showExtensionSwitch.onStateChanged, showExtensionSwitch.onStateChanged
end

View File

@ -94,6 +94,9 @@ function system.getDefaultUserSettings()
interfaceColorDesktopBackground = 0x1E1E1E,
interfaceColorDock = 0xE1E1E1,
interfaceColorMenu = 0xF0F0F0,
interfaceColorDropDownMenuSeparator = 0xA5A5A5,
interfaceColorDropDownMenuDefaultBackground = 0xFFFFFF,
interfaceColorDropDownMenuDefaultText = 0x2D2D2D,
filesShowExtension = false,
filesShowHidden = false,
@ -2357,6 +2360,10 @@ function system.updateColorScheme()
-- Drop down menus
GUI.CONTEXT_MENU_BACKGROUND_TRANSPARENCY = userSettings.interfaceTransparencyEnabled and 0.18
GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY = userSettings.interfaceTransparencyEnabled and 0.4
GUI.CONTEXT_MENU_SEPARATOR_COLOR = userSettings.interfaceColorDropDownMenuSeparator
GUI.CONTEXT_MENU_DEFAULT_BACKGROUND_COLOR = userSettings.interfaceColorDropDownMenuDefaultBackground
GUI.CONTEXT_MENU_DEFAULT_TEXT_COLOR = userSettings.interfaceColorDropDownMenuDefaultText
-- Windows
GUI.WINDOW_SHADOW_TRANSPARENCY = userSettings.interfaceTransparencyEnabled and 0.6
-- Background containers