mirror of
https://github.com/kepler155c/opus
synced 2025-01-16 18:32:52 +00:00
optional label for checkboxes
This commit is contained in:
parent
8c794d9107
commit
dc915337a0
@ -3069,12 +3069,18 @@ UI.Checkbox.defaults = {
|
||||
backgroundColor = colors.black,
|
||||
backgroundFocusColor = colors.lightGray,
|
||||
height = 1,
|
||||
width = 3,
|
||||
accelerators = {
|
||||
space = 'checkbox_toggle',
|
||||
mouse_click = 'checkbox_toggle',
|
||||
}
|
||||
}
|
||||
function UI.Checkbox:setParent()
|
||||
if not self.width and not self.ex then
|
||||
self.width = (self.label and #self.label or 0) + 3
|
||||
end
|
||||
UI.Window.setParent(self)
|
||||
end
|
||||
|
||||
function UI.Checkbox:draw()
|
||||
local bg = self.backgroundColor
|
||||
if self.focused then
|
||||
@ -3084,10 +3090,15 @@ function UI.Checkbox:draw()
|
||||
self.value = nil -- TODO: fix form
|
||||
end
|
||||
local text = string.format('[%s]', not self.value and ' ' or self.checkedIndicator)
|
||||
self:write(1, 1, text, bg)
|
||||
self:write(1, 1, self.leftMarker, self.backgroundColor, self.textColor)
|
||||
self:write(2, 1, not self.value and ' ' or self.checkedIndicator, bg)
|
||||
self:write(3, 1, self.rightMarker, self.backgroundColor, self.textColor)
|
||||
local x = 1
|
||||
if self.label then
|
||||
self:write(1, 1, self.label)
|
||||
x = #self.label + 2
|
||||
end
|
||||
self:write(x, 1, text, bg)
|
||||
self:write(x, 1, self.leftMarker, self.backgroundColor, self.textColor)
|
||||
self:write(x + 1, 1, not self.value and ' ' or self.checkedIndicator, bg)
|
||||
self:write(x + 2, 1, self.rightMarker, self.backgroundColor, self.textColor)
|
||||
end
|
||||
|
||||
function UI.Checkbox:focus()
|
||||
|
@ -1,19 +0,0 @@
|
||||
if _G.device.wireless_modem then
|
||||
|
||||
_G.requireInjector(_ENV)
|
||||
local Config = require('config')
|
||||
|
||||
local kernel = _G.kernel
|
||||
|
||||
local config = { }
|
||||
Config.load('gps', config)
|
||||
|
||||
if config.host and type(config.host) == 'table' then
|
||||
kernel.run({
|
||||
title = 'GPS Daemon',
|
||||
hidden = true,
|
||||
path = '/rom/programs/gps',
|
||||
args = { 'host', config.host.x, config.host.y, config.host.z },
|
||||
})
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user