fix ui resizing (due to canvas changes)

This commit is contained in:
kepler155c@gmail.com 2019-02-26 18:03:09 -05:00
parent ad60fce9b0
commit cc1a2bfbf4
6 changed files with 49 additions and 27 deletions

View File

@ -263,6 +263,7 @@ function Manager:click(target, code, button, x, y)
if clickEvent.element.focus then
target:setFocus(clickEvent.element)
end
_G._p = clickEvent
self:inputEvent(clickEvent.element, clickEvent)
target:sync()

View File

@ -5,11 +5,13 @@ UI.ActiveLayer = class(UI.Window)
UI.ActiveLayer.defaults = {
UIElement = 'ActiveLayer',
}
function UI.ActiveLayer:setParent()
self:layout(self)
self.canvas = self:addLayer()
UI.Window.setParent(self)
function UI.ActiveLayer:layout()
UI.Window.layout(self)
if not self.canvas then
self.canvas = self:addLayer()
else
self.canvas:resize(self.width, self.height)
end
end
function UI.ActiveLayer:enable(...)

View File

@ -32,6 +32,13 @@ function UI.Embedded:setParent()
self.win.clear()
end
function UI.Embedded:layout()
UI.Window.layout(self)
if self.win then
self.win.reposition(self.x, self.y, self.width, self.height)
end
end
function UI.Embedded:draw()
self.canvas:dirty()
end

View File

@ -1,5 +1,6 @@
local UI = require('ui')
local colors = _G.colors
local device = _G.device
local peripheral = _G.peripheral
local settings = _G.settings
@ -8,7 +9,7 @@ local tab = UI.Tab {
tabTitle = 'Kiosk',
description = 'Kiosk options',
form = UI.Form {
x = 2,
x = 2, ex = -2,
manualControls = true,
monitor = UI.Chooser {
formLabel = 'Monitor', formKey = 'monitor',
@ -22,6 +23,11 @@ local tab = UI.Tab {
},
help = 'Adjust text scaling',
},
labelText = UI.TextArea {
x = 2, ex = -2, y = 5,
textColor = colors.yellow,
value = 'Settings apply to kiosk mode selected during startup'
},
},
}

View File

@ -1,3 +1,4 @@
local Ansi = require('ansi')
local Config = require('config')
local UI = require('ui')
@ -6,17 +7,20 @@ local device = _G.device
local tab = UI.Tab {
tabTitle = 'Network',
description = 'Networking options',
form = UI.Form {
x = 2,
manualControls = true,
modem = UI.Chooser {
formLabel = 'Modem', formKey = 'modem',
nochoice = 'auto',
},
update = UI.Button {
x = 9, y = 4,
text = 'Update', event = 'form_complete',
},
info = UI.TextArea {
x = 3, y = 4,
value = string.format(
[[%sSet the primary modem used for wireless communications.%s
Reboot to take effect.]], Ansi.yellow, Ansi.reset)
},
label = UI.Text {
x = 3, y = 2,
value = 'Modem',
},
modem = UI.Chooser {
x = 10, ex = -3, y = 2,
nochoice = 'auto',
},
}
@ -34,19 +38,19 @@ function tab:enable()
end
end
self.form.modem.choices = choices
self.form.modem.width = width + 4
self.modem.choices = choices
--self.modem.width = width + 4
local config = Config.load('os')
self.form.modem.value = config.wirelessModem or 'auto'
self.modem.value = config.wirelessModem or 'auto'
UI.Tab.enable(self)
end
function tab:eventHandler(event)
if event.type == 'form_complete' then
if event.type == 'choice_change' then
local config = Config.load('os')
config.wirelessModem = self.form.modem.value
config.wirelessModem = self.modem.value
Config.update('os', config)
self:emit({ type = 'success_message', message = 'reboot to take effect' })
return true

View File

@ -2,18 +2,20 @@ local Security = require('security')
local SHA1 = require('sha1')
local UI = require('ui')
local colors = _G.colors
local passwordTab = UI.Tab {
tabTitle = 'Password',
description = 'Wireless network password',
oldPass = UI.TextEntry {
x = 2, y = 2, ex = -2,
x = 3, ex = -3, y = 2,
limit = 32,
mask = true,
shadowText = 'old password',
inactive = not Security.getPassword(),
},
newPass = UI.TextEntry {
y = 3, x = 2, ex = -2,
x = 3, ex = -3, y = 3,
limit = 32,
mask = true,
shadowText = 'new password',
@ -22,13 +24,13 @@ local passwordTab = UI.Tab {
},
},
button = UI.Button {
x = 2, y = 5,
x = 3, y = 5,
text = 'Update',
event = 'update_password',
},
info = UI.TextArea {
x = 2, ex = -2,
y = 7,
x = 3, ex = -3, y = 7,
textColor = colors.yellow,
inactive = true,
value = 'Add a password to enable other computers to connect to this one.',
}