1
0
mirror of https://github.com/kepler155c/opus synced 2025-01-03 20:30:28 +00:00

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 if clickEvent.element.focus then
target:setFocus(clickEvent.element) target:setFocus(clickEvent.element)
end end
_G._p = clickEvent
self:inputEvent(clickEvent.element, clickEvent) self:inputEvent(clickEvent.element, clickEvent)
target:sync() target:sync()

View File

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

View File

@ -32,6 +32,13 @@ function UI.Embedded:setParent()
self.win.clear() self.win.clear()
end 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() function UI.Embedded:draw()
self.canvas:dirty() self.canvas:dirty()
end end

View File

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

View File

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