mirror of https://github.com/kepler155c/opus
cleanup + theme editor
This commit is contained in:
parent
9eeec8719c
commit
3e41996b9b
|
@ -58,10 +58,16 @@ local page = UI.Page {
|
||||||
},
|
},
|
||||||
[2] = UI.Tab {
|
[2] = UI.Tab {
|
||||||
tabTitle = 'Output',
|
tabTitle = 'Output',
|
||||||
|
backgroundColor = colors.black,
|
||||||
output = UI.Embedded {
|
output = UI.Embedded {
|
||||||
|
y = 2,
|
||||||
maxScroll = 1000,
|
maxScroll = 1000,
|
||||||
backgroundColor = colors.black,
|
backgroundColor = colors.black,
|
||||||
},
|
},
|
||||||
|
draw = function(self)
|
||||||
|
self:write(1, 1, string.rep('\131', self.width), colors.black, UI.colors.primary)
|
||||||
|
self:drawChildren()
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,31 @@ local page = UI.Page {
|
||||||
columns = gridColumns,
|
columns = gridColumns,
|
||||||
sortColumn = 'label',
|
sortColumn = 'label',
|
||||||
autospace = true,
|
autospace = true,
|
||||||
|
getRowTextColor = function(self, row, selected)
|
||||||
|
if not row.active then
|
||||||
|
return colors.lightGray
|
||||||
|
end
|
||||||
|
return UI.Grid.getRowTextColor(self, row, selected)
|
||||||
|
end,
|
||||||
|
getDisplayValues = function(_, row)
|
||||||
|
row = Util.shallowCopy(row)
|
||||||
|
if row.uptime then
|
||||||
|
if row.uptime < 60 then
|
||||||
|
row.uptime = string.format("%ds", math.floor(row.uptime))
|
||||||
|
elseif row.uptime < 3600 then
|
||||||
|
row.uptime = string.format("%sm", math.floor(row.uptime / 60))
|
||||||
|
else
|
||||||
|
row.uptime = string.format("%sh", math.floor(row.uptime / 3600))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if row.fuel then
|
||||||
|
row.fuel = row.fuel > 0 and Util.toBytes(row.fuel) or ''
|
||||||
|
end
|
||||||
|
if row.distance then
|
||||||
|
row.distance = Util.toBytes(Util.round(row.distance, 1))
|
||||||
|
end
|
||||||
|
return row
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
ports = UI.SlideOut {
|
ports = UI.SlideOut {
|
||||||
titleBar = UI.TitleBar {
|
titleBar = UI.TitleBar {
|
||||||
|
@ -72,6 +97,12 @@ local page = UI.Page {
|
||||||
sortColumn = 'port',
|
sortColumn = 'port',
|
||||||
autospace = true,
|
autospace = true,
|
||||||
},
|
},
|
||||||
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'grid_select' then
|
||||||
|
shell.openForegroundTab('Sniff ' .. event.selected.port)
|
||||||
|
end
|
||||||
|
return UI.SlideOut.eventHandler(self, event)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
help = UI.SlideOut {
|
help = UI.SlideOut {
|
||||||
x = 5, ex = -5, height = 8, y = -8,
|
x = 5, ex = -5, height = 8, y = -8,
|
||||||
|
@ -125,13 +156,6 @@ local function sendCommand(host, command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function page.ports:eventHandler(event)
|
|
||||||
if event.type == 'grid_select' then
|
|
||||||
shell.openForegroundTab('Sniff ' .. event.selected.port)
|
|
||||||
end
|
|
||||||
return UI.SlideOut.eventHandler(self, event)
|
|
||||||
end
|
|
||||||
|
|
||||||
function page.ports.grid:update()
|
function page.ports.grid:update()
|
||||||
local transport = network:getTransport()
|
local transport = network:getTransport()
|
||||||
|
|
||||||
|
@ -241,33 +265,6 @@ function page.menuBar:getActive(menuItem)
|
||||||
return menuItem.noCheck or not not t
|
return menuItem.noCheck or not not t
|
||||||
end
|
end
|
||||||
|
|
||||||
function page.grid:getRowTextColor(row, selected)
|
|
||||||
if not row.active then
|
|
||||||
return colors.lightGray
|
|
||||||
end
|
|
||||||
return UI.Grid.getRowTextColor(self, row, selected)
|
|
||||||
end
|
|
||||||
|
|
||||||
function page.grid:getDisplayValues(row)
|
|
||||||
row = Util.shallowCopy(row)
|
|
||||||
if row.uptime then
|
|
||||||
if row.uptime < 60 then
|
|
||||||
row.uptime = string.format("%ds", math.floor(row.uptime))
|
|
||||||
elseif row.uptime < 3600 then
|
|
||||||
row.uptime = string.format("%sm", math.floor(row.uptime / 60))
|
|
||||||
else
|
|
||||||
row.uptime = string.format("%sh", math.floor(row.uptime / 3600))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if row.fuel then
|
|
||||||
row.fuel = row.fuel > 0 and Util.toBytes(row.fuel) or ''
|
|
||||||
end
|
|
||||||
if row.distance then
|
|
||||||
row.distance = Util.toBytes(Util.round(row.distance, 1))
|
|
||||||
end
|
|
||||||
return row
|
|
||||||
end
|
|
||||||
|
|
||||||
Event.onInterval(1, function()
|
Event.onInterval(1, function()
|
||||||
page.grid:update()
|
page.grid:update()
|
||||||
page.grid:draw()
|
page.grid:draw()
|
||||||
|
|
|
@ -102,20 +102,18 @@ local page = UI.Page {
|
||||||
},
|
},
|
||||||
tray = UI.Window {
|
tray = UI.Window {
|
||||||
y = -1, width = 8,
|
y = -1, width = 8,
|
||||||
backgroundColor = colors.lightGray,
|
backgroundColor = UI.colors.tertiary,
|
||||||
newApp = UI.Button {
|
newApp = UI.FlatButton {
|
||||||
|
x = 2,
|
||||||
text = '+', event = 'new',
|
text = '+', event = 'new',
|
||||||
backgroundFocusColor = colors.lightGray,
|
|
||||||
},
|
},
|
||||||
mode = UI.Button {
|
mode = UI.FlatButton {
|
||||||
x = 3,
|
x = 4,
|
||||||
text = '=', event = 'display_mode',
|
text = '=', event = 'display_mode',
|
||||||
backgroundFocusColor = colors.lightGray,
|
|
||||||
},
|
},
|
||||||
help = UI.Button {
|
help = UI.FlatButton {
|
||||||
x = 5,
|
x = 6,
|
||||||
text = '?', event = 'help',
|
text = '?', event = 'help',
|
||||||
backgroundFocusColor = colors.lightGray,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
editor = UI.SlideOut {
|
editor = UI.SlideOut {
|
||||||
|
|
|
@ -2,8 +2,9 @@ local UI = require('opus.ui')
|
||||||
local Util = require('opus.util')
|
local Util = require('opus.util')
|
||||||
|
|
||||||
local shell = _ENV.shell
|
local shell = _ENV.shell
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
|
||||||
-- fileui [--path=path] [--exec=filename]
|
-- fileui [--path=path] [--exec=filename] [--title=title]
|
||||||
|
|
||||||
local page = UI.Page {
|
local page = UI.Page {
|
||||||
fileselect = UI.FileSelect { },
|
fileselect = UI.FileSelect { },
|
||||||
|
@ -22,6 +23,10 @@ local page = UI.Page {
|
||||||
|
|
||||||
local _, args = Util.parse(...)
|
local _, args = Util.parse(...)
|
||||||
|
|
||||||
|
if args.title and multishell then
|
||||||
|
multishell.setTitle(multishell.getCurrent(), args.title)
|
||||||
|
end
|
||||||
|
|
||||||
UI:setPage(page, args.path)
|
UI:setPage(page, args.path)
|
||||||
UI:start()
|
UI:start()
|
||||||
UI.term:setCursorBlink(false)
|
UI.term:setCursorBlink(false)
|
||||||
|
@ -31,5 +36,4 @@ if args.exec and page.selected then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print('selected: ' .. tostring(selected))
|
|
||||||
return page.selected
|
return page.selected
|
||||||
|
|
|
@ -28,7 +28,7 @@ local defaults = {
|
||||||
local _colors = config.color or Util.shallowCopy(defaults)
|
local _colors = config.color or Util.shallowCopy(defaults)
|
||||||
|
|
||||||
local allSettings = { }
|
local allSettings = { }
|
||||||
for k, v in pairs(defaults) do
|
for k in pairs(defaults) do
|
||||||
table.insert(allSettings, { name = k })
|
table.insert(allSettings, { name = k })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ return UI.Tab {
|
||||||
self.grid2:draw()
|
self.grid2:draw()
|
||||||
|
|
||||||
elseif event.type == 'grid_select' and event.element == self.grid2 then
|
elseif event.type == 'grid_select' and event.element == self.grid2 then
|
||||||
_colors[tab.grid1:getSelected().name] = event.selected.value
|
_colors[self.grid1:getSelected().name] = event.selected.value
|
||||||
self.display:draw()
|
self.display:draw()
|
||||||
self.grid2:draw()
|
self.grid2:draw()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
local Config = require('opus.config')
|
||||||
|
local UI = require('opus.ui')
|
||||||
|
local Util = require('opus.util')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
|
||||||
|
local allColors = { }
|
||||||
|
for k,v in pairs(colors) do
|
||||||
|
if type(v) == 'number' then
|
||||||
|
table.insert(allColors, { name = k, value = v })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local allSettings = { }
|
||||||
|
for k,v in pairs(UI.colors) do
|
||||||
|
allSettings[k] = { name = k, value = v }
|
||||||
|
end
|
||||||
|
|
||||||
|
return UI.Tab {
|
||||||
|
tabTitle = 'Theme',
|
||||||
|
description = 'Theme colors',
|
||||||
|
grid1 = UI.ScrollingGrid {
|
||||||
|
y = 2, ey = -10, x = 2, ex = -17,
|
||||||
|
disableHeader = true,
|
||||||
|
columns = { { key = 'name' } },
|
||||||
|
values = allSettings,
|
||||||
|
sortColumn = 'name',
|
||||||
|
},
|
||||||
|
grid2 = UI.ScrollingGrid {
|
||||||
|
y = 2, ey = -10, x = -14, ex = -2,
|
||||||
|
disableHeader = true,
|
||||||
|
columns = { { key = 'name' } },
|
||||||
|
values = allColors,
|
||||||
|
sortColumn = 'name',
|
||||||
|
getRowTextColor = function(self, row)
|
||||||
|
local selected = self.parent.grid1:getSelected()
|
||||||
|
if selected.value == row.value then
|
||||||
|
return colors.yellow
|
||||||
|
end
|
||||||
|
return UI.Grid.getRowTextColor(self, row)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
button = UI.Button {
|
||||||
|
x = -9, y = -2,
|
||||||
|
text = 'Update',
|
||||||
|
event = 'update',
|
||||||
|
},
|
||||||
|
display = UI.Window {
|
||||||
|
x = 2, ex = -2, y = -8, height = 5,
|
||||||
|
textColor = colors.black,
|
||||||
|
backgroundColor = colors.black,
|
||||||
|
draw = function(self)
|
||||||
|
self:clear()
|
||||||
|
|
||||||
|
self:write(1, 1, Util.widthify(' Local Global Device', self.width),
|
||||||
|
allSettings.secondary.value)
|
||||||
|
|
||||||
|
self:write(2, 2, 'enter command ',
|
||||||
|
colors.black, colors.gray)
|
||||||
|
|
||||||
|
self:write(1, 3, ' Formatted ',
|
||||||
|
allSettings.primary.value)
|
||||||
|
|
||||||
|
self:write(12, 3, Util.widthify(' Output ', self.width - 11),
|
||||||
|
allSettings.tertiary.value)
|
||||||
|
|
||||||
|
self:write(1, 4, Util.widthify(' Key', self.width),
|
||||||
|
allSettings.primary.value)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'grid_focus_row' and event.element == self.grid1 then
|
||||||
|
self.grid2:draw()
|
||||||
|
|
||||||
|
elseif event.type == 'grid_select' and event.element == self.grid2 then
|
||||||
|
self.grid1:getSelected().value = event.selected.value
|
||||||
|
self.display:draw()
|
||||||
|
self.grid2:draw()
|
||||||
|
|
||||||
|
elseif event.type == 'update' then
|
||||||
|
local config = Config.load('ui.theme', { colors = { } })
|
||||||
|
for k,v in pairs(allSettings) do
|
||||||
|
config.colors[k] = v.value
|
||||||
|
end
|
||||||
|
Config.update('ui.theme', config)
|
||||||
|
end
|
||||||
|
return UI.Tab.eventHandler(self, event)
|
||||||
|
end
|
||||||
|
}
|
|
@ -165,7 +165,7 @@ function input:translate(event, code, p1, p2)
|
||||||
self.mch = 'mouse_up'
|
self.mch = 'mouse_up'
|
||||||
self.mfired = input:toCode(self.mch, 255)
|
self.mfired = input:toCode(self.mch, 255)
|
||||||
end
|
end
|
||||||
_syslog(self.mfired)
|
|
||||||
return {
|
return {
|
||||||
code = self.mfired,
|
code = self.mfired,
|
||||||
button = code,
|
button = code,
|
||||||
|
|
|
@ -209,6 +209,15 @@ end
|
||||||
|
|
||||||
function Manager:generateTheme(filename)
|
function Manager:generateTheme(filename)
|
||||||
local t = { }
|
local t = { }
|
||||||
|
|
||||||
|
local function getName(d)
|
||||||
|
for c, n in pairs(colors) do
|
||||||
|
if n == d then
|
||||||
|
return 'colors.' .. c
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for k,v in pairs(self) do
|
for k,v in pairs(self) do
|
||||||
if type(v) == 'table' then
|
if type(v) == 'table' then
|
||||||
if v._preload then
|
if v._preload then
|
||||||
|
@ -221,17 +230,17 @@ function Manager:generateTheme(filename)
|
||||||
if not t[k] then
|
if not t[k] then
|
||||||
t[k] = { }
|
t[k] = { }
|
||||||
end
|
end
|
||||||
for c, n in pairs(colors) do
|
t[k][p] = getName(d)
|
||||||
if n == d then
|
|
||||||
t[k][p] = 'colors.' .. c
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
t.colors = {
|
||||||
|
primary = getName(self.colors.primary),
|
||||||
|
secondary = getName(self.colors.secondary),
|
||||||
|
tertiary = getName(self.colors.tertiary),
|
||||||
|
}
|
||||||
Util.writeFile(filename, textutils.serialize(t):gsub('(")', ''))
|
Util.writeFile(filename, textutils.serialize(t):gsub('(")', ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -409,8 +418,8 @@ end
|
||||||
|
|
||||||
Manager.colors = {
|
Manager.colors = {
|
||||||
primary = colors.cyan,
|
primary = colors.cyan,
|
||||||
secondary = colors.blue,
|
secondary = colors.lightGray,
|
||||||
tertiary = colors.blue,
|
tertiary = colors.gray,
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager.exitPullEvents = Event.exitPullEvents
|
Manager.exitPullEvents = Event.exitPullEvents
|
||||||
|
@ -652,7 +661,7 @@ function UI.Window:setCursorPos(x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.Window:setCursorBlink(blink)
|
function UI.Window:setCursorBlink(blink)
|
||||||
self.parent:setCursorBlink(blink)
|
self.cursorBlink = blink
|
||||||
end
|
end
|
||||||
|
|
||||||
UI.Window.docs.draw = [[draw(VOID)
|
UI.Window.docs.draw = [[draw(VOID)
|
||||||
|
@ -1072,7 +1081,6 @@ end
|
||||||
|
|
||||||
function UI.Device:setCursorBlink(blink)
|
function UI.Device:setCursorBlink(blink)
|
||||||
self.cursorBlink = blink
|
self.cursorBlink = blink
|
||||||
self.device.setCursorBlink(blink)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.Device:setTextScale(textScale)
|
function UI.Device:setTextScale(textScale)
|
||||||
|
@ -1130,9 +1138,7 @@ function UI.Device:sync()
|
||||||
local transitions = self.effectsEnabled and self.transitions
|
local transitions = self.effectsEnabled and self.transitions
|
||||||
self.transitions = nil
|
self.transitions = nil
|
||||||
|
|
||||||
if self:getCursorBlink() then
|
self.device.setCursorBlink(false)
|
||||||
self.device.setCursorBlink(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
if transitions then
|
if transitions then
|
||||||
self:runTransitions(transitions)
|
self:runTransitions(transitions)
|
||||||
|
@ -1182,6 +1188,7 @@ end
|
||||||
loadComponents()
|
loadComponents()
|
||||||
UI:loadTheme('usr/config/ui.theme')
|
UI:loadTheme('usr/config/ui.theme')
|
||||||
Util.merge(UI.Window.defaults, UI.theme.Window)
|
Util.merge(UI.Window.defaults, UI.theme.Window)
|
||||||
|
Util.merge(UI.colors, UI.theme.colors)
|
||||||
UI:setDefaultDevice(UI.Device({ device = term.current() }))
|
UI:setDefaultDevice(UI.Device({ device = term.current() }))
|
||||||
|
|
||||||
return UI
|
return UI
|
||||||
|
|
|
@ -21,6 +21,9 @@ function UI.Embedded:layout()
|
||||||
if not self.win then
|
if not self.win then
|
||||||
function self.render()
|
function self.render()
|
||||||
self:sync()
|
self:sync()
|
||||||
|
if self.focused then
|
||||||
|
self:setCursorPos(self.win.getCursorPos())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self.win = Terminal.window(UI.term.device, self.x, self.y, self.width, self.height, false)
|
self.win = Terminal.window(UI.term.device, self.x, self.y, self.width, self.height, false)
|
||||||
self.win.canvas = self
|
self.win.canvas = self
|
||||||
|
@ -38,6 +41,9 @@ end
|
||||||
|
|
||||||
function UI.Embedded:focus()
|
function UI.Embedded:focus()
|
||||||
-- allow scrolling
|
-- allow scrolling
|
||||||
|
if self.focused then
|
||||||
|
self:setCursorBlink(self.win.getCursorBlink())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.Embedded:enable()
|
function UI.Embedded:enable()
|
||||||
|
@ -67,6 +73,7 @@ function UI.Embedded.example()
|
||||||
local term = _G.term
|
local term = _G.term
|
||||||
|
|
||||||
return UI.Embedded {
|
return UI.Embedded {
|
||||||
|
y = 2, x = 2, ex = -2, ey = -2,
|
||||||
enable = function (self)
|
enable = function (self)
|
||||||
UI.Embedded.enable(self)
|
UI.Embedded.enable(self)
|
||||||
Event.addRoutine(function()
|
Event.addRoutine(function()
|
||||||
|
@ -75,10 +82,11 @@ function UI.Embedded.example()
|
||||||
term.redirect(oterm)
|
term.redirect(oterm)
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
eventHandler = function(_, event)
|
eventHandler = function(self, event)
|
||||||
if event.type == 'key' then
|
if event.type == 'key' then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
return UI.Embedded.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
local class = require('opus.class')
|
||||||
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
|
||||||
|
UI.FlatButton = class(UI.Button)
|
||||||
|
UI.FlatButton.defaults = {
|
||||||
|
UIElement = 'FlatButton',
|
||||||
|
textColor = colors.black,
|
||||||
|
textFocusColor = colors.white,
|
||||||
|
noPadding = true,
|
||||||
|
}
|
||||||
|
function UI.FlatButton:setParent()
|
||||||
|
self.backgroundColor = self.parent:getProperty('backgroundColor')
|
||||||
|
self.backgroundFocusColor = self.backgroundColor
|
||||||
|
|
||||||
|
UI.Button.setParent(self)
|
||||||
|
end
|
|
@ -60,7 +60,7 @@ UI.Grid.defaults = {
|
||||||
textSelectedColor = colors.white,
|
textSelectedColor = colors.white,
|
||||||
backgroundColor = colors.black,
|
backgroundColor = colors.black,
|
||||||
backgroundSelectedColor = colors.gray,
|
backgroundSelectedColor = colors.gray,
|
||||||
headerBackgroundColor = UI.colors.tertiary,
|
headerBackgroundColor = UI.colors.primary,
|
||||||
headerTextColor = colors.white,
|
headerTextColor = colors.white,
|
||||||
headerSortColor = colors.yellow,
|
headerSortColor = colors.yellow,
|
||||||
unfocusedTextSelectedColor = colors.white,
|
unfocusedTextSelectedColor = colors.white,
|
||||||
|
|
|
@ -8,7 +8,7 @@ UI.MenuBar.defaults = {
|
||||||
UIElement = 'MenuBar',
|
UIElement = 'MenuBar',
|
||||||
buttons = { },
|
buttons = { },
|
||||||
height = 1,
|
height = 1,
|
||||||
backgroundColor = colors.lightGray,
|
backgroundColor = UI.colors.secondary,
|
||||||
textColor = colors.black,
|
textColor = colors.black,
|
||||||
spacing = 2,
|
spacing = 2,
|
||||||
lastx = 1,
|
lastx = 1,
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
local class = require('opus.class')
|
local class = require('opus.class')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
UI.MenuItem = class(UI.FlatButton)
|
||||||
|
|
||||||
UI.MenuItem = class(UI.Button)
|
|
||||||
UI.MenuItem.defaults = {
|
UI.MenuItem.defaults = {
|
||||||
UIElement = 'MenuItem',
|
UIElement = 'MenuItem',
|
||||||
textFocusColor = colors.white,
|
noPadding = false,
|
||||||
backgroundFocusColor = colors.lightGray,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,17 +24,10 @@ function UI.Page:postInit()
|
||||||
self.__target = self
|
self.__target = self
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.Page:enable()
|
|
||||||
UI.Window.enable(self)
|
|
||||||
|
|
||||||
if not self.focused or not self.focused.enabled then
|
|
||||||
self:focusFirst()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function UI.Page:sync()
|
function UI.Page:sync()
|
||||||
if self.enabled then
|
if self.enabled then
|
||||||
self:checkFocus()
|
self:checkFocus()
|
||||||
|
self.parent:setCursorBlink(self.focused and self.focused.cursorBlink)
|
||||||
self.parent:sync()
|
self.parent:sync()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -137,15 +130,7 @@ end
|
||||||
|
|
||||||
function UI.Page:checkFocus()
|
function UI.Page:checkFocus()
|
||||||
if not self.focused or not self.focused.enabled then
|
if not self.focused or not self.focused.enabled then
|
||||||
local el = self.__target
|
self.__target:focusFirst()
|
||||||
while el do
|
|
||||||
local focusables = el:getFocusables()
|
|
||||||
if focusables[1] then
|
|
||||||
self:setFocus(focusables[1])
|
|
||||||
break
|
|
||||||
end
|
|
||||||
el = el.parent
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,13 @@ local class = require('opus.class')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
local Util = require('opus.util')
|
local Util = require('opus.util')
|
||||||
|
|
||||||
local colors = _G.colors
|
|
||||||
|
|
||||||
UI.TabBar = class(UI.MenuBar)
|
UI.TabBar = class(UI.MenuBar)
|
||||||
UI.TabBar.defaults = {
|
UI.TabBar.defaults = {
|
||||||
UIElement = 'TabBar',
|
UIElement = 'TabBar',
|
||||||
buttonClass = 'TabBarMenuItem',
|
buttonClass = 'TabBarMenuItem',
|
||||||
selectedBackgroundColor = UI.colors.secondary,
|
backgroundColor = UI.colors.tertiary,
|
||||||
unselectedBackgroundColor = colors.lightGray,
|
selectedBackgroundColor = UI.colors.primary,
|
||||||
|
unselectedBackgroundColor = UI.colors.tertiary,
|
||||||
}
|
}
|
||||||
function UI.TabBar:enable()
|
function UI.TabBar:enable()
|
||||||
UI.MenuBar.enable(self)
|
UI.MenuBar.enable(self)
|
||||||
|
|
|
@ -28,6 +28,7 @@ UI.TextEntry.defaults = {
|
||||||
backgroundFocusColor = colors.black, --lightGray,
|
backgroundFocusColor = colors.black, --lightGray,
|
||||||
height = 1,
|
height = 1,
|
||||||
limit = 6,
|
limit = 6,
|
||||||
|
cursorBlink = true,
|
||||||
accelerators = {
|
accelerators = {
|
||||||
[ 'control-c' ] = 'copy',
|
[ 'control-c' ] = 'copy',
|
||||||
}
|
}
|
||||||
|
@ -114,11 +115,6 @@ end
|
||||||
|
|
||||||
function UI.TextEntry:focus()
|
function UI.TextEntry:focus()
|
||||||
self:draw()
|
self:draw()
|
||||||
if self.focused then
|
|
||||||
self:setCursorBlink(true)
|
|
||||||
else
|
|
||||||
self:setCursorBlink(false)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.TextEntry:eventHandler(event)
|
function UI.TextEntry:eventHandler(event)
|
||||||
|
|
Loading…
Reference in New Issue