list mode for overview

This commit is contained in:
kepler155c@gmail.com 2020-03-31 23:43:45 -06:00
parent 3313fb986c
commit fc1a308193
5 changed files with 79 additions and 32 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/ignore /ignore
.project

View File

@ -18,6 +18,12 @@ local shell = _ENV.shell
local term = _G.term local term = _G.term
local turtle = _G.turtle local turtle = _G.turtle
--[[
turtle: 39x13
computer: 51x19
pocket: 26x20
]]
if not _ENV.multishell then if not _ENV.multishell then
error('multishell is required') error('multishell is required')
end end
@ -110,6 +116,17 @@ local page = UI.Page {
backgroundColor = colors.lightGray, backgroundColor = colors.lightGray,
newApp = UI.Button { newApp = UI.Button {
text = '+', event = 'new', text = '+', event = 'new',
backgroundFocusColor = colors.lightGray,
},
mode = UI.Button {
x = 3,
text = '=', event = 'display_mode',
backgroundFocusColor = colors.lightGray,
},
help = UI.Button {
x = 5,
text = '?', event = 'help',
backgroundFocusColor = colors.lightGray,
}, },
--[[ --[[
volume = UI.Button { volume = UI.Button {
@ -138,16 +155,16 @@ local page = UI.Page {
required = true, required = true,
}, },
editIcon = UI.Button { editIcon = UI.Button {
x = 11, y = 9, x = 11, y = 6,
text = 'Edit', event = 'editIcon', help = 'Edit icon file', text = 'Edit', event = 'editIcon', help = 'Edit icon file',
}, },
loadIcon = UI.Button { loadIcon = UI.Button {
x = 18, y = 9, x = 11, y = 8,
text = 'Load', event = 'loadIcon', help = 'Load icon file', text = 'Load', event = 'loadIcon', help = 'Load icon file',
}, },
info = UI.TextArea { helpIcon = UI.Button {
x = 11, y = 6, height = 2, x = 11, y = 8,
value = 'magenta is transparent\n3 high - max width is 8' text = 'Load', event = 'loadIcon', help = 'Load icon file',
}, },
image = UI.NftImage { image = UI.NftImage {
backgroundColor = colors.black, backgroundColor = colors.black,
@ -312,25 +329,43 @@ function page.container:setCategory(categoryName, animate)
local title = ellipsis(program.title, 8) local title = ellipsis(program.title, 8)
local width = math.max(icon.width + 2, #title + 2) local width = math.max(icon.width + 2, #title + 2)
table.insert(self.children, UI.Icon({ if config.listMode then
width = width, table.insert(self.children, UI.Icon {
image = UI.NftImage({ width = self.width - 2,
x = math.floor((width - icon.width) / 2) + 1, height = 1,
image = icon, UI.Button {
}), x = 1, ex = -1,
button = UI.Button({ text = program.title,
x = math.floor((width - #title - 2) / 2) + 1, centered = false,
y = 4, backgroundColor = self:getProperty('backgroundColor'),
text = title, backgroundFocusColor = colors.gray,
backgroundColor = self:getProperty('backgroundColor'), textColor = colors.white,
backgroundFocusColor = colors.gray, textFocusColor = colors.white,
textColor = colors.white, event = 'button',
textFocusColor = colors.white, app = program,
width = #title + 2, }
event = 'button', })
app = program, else
}), table.insert(self.children, UI.Icon({
})) width = width,
image = UI.NftImage({
x = math.floor((width - icon.width) / 2) + 1,
image = icon,
}),
button = UI.Button({
x = math.floor((width - #title - 2) / 2) + 1,
y = 4,
text = title,
backgroundColor = self:getProperty('backgroundColor'),
backgroundFocusColor = colors.gray,
textColor = colors.white,
textFocusColor = colors.white,
width = #title + 2,
event = 'button',
app = program,
}),
}))
end
end end
local gutter = 2 local gutter = 2
@ -383,7 +418,7 @@ function page.container:setCategory(categoryName, animate)
col = col + child.width col = col + child.width
if col + self.children[k + 1].width + gutter - 2 > self.width then if col + self.children[k + 1].width + gutter - 2 > self.width then
col = gutter col = gutter
row = row + 5 row = row + (config.listMode and 1 or 5)
end end
end end
end end
@ -452,6 +487,9 @@ function page:eventHandler(event)
elseif event.type == 'network' then elseif event.type == 'network' then
shell.switchTab(shell.openTab('network')) shell.switchTab(shell.openTab('network'))
elseif event.type == 'help' then
shell.switchTab(shell.openTab('Help Overview'))
elseif event.type == 'focus_change' then elseif event.type == 'focus_change' then
if event.focused.parent.UIElement == 'Icon' then if event.focused.parent.UIElement == 'Icon' then
event.focused.parent:scrollIntoView() event.focused.parent:scrollIntoView()
@ -486,6 +524,13 @@ function page:eventHandler(event)
end end
self.editor:show({ category = category }) self.editor:show({ category = category })
elseif event.type == 'display_mode' then
config.listMode = not config.listMode
Config.update('Overview', config)
loadApplications()
self:refresh()
self:draw()
elseif event.type == 'edit' then elseif event.type == 'edit' then
local focused = page:getFocused() local focused = page:getFocused()
if focused.app then if focused.app then
@ -493,7 +538,7 @@ function page:eventHandler(event)
end end
else else
UI.Page.eventHandler(self, event) return UI.Page.eventHandler(self, event)
end end
return true return true
end end
@ -595,10 +640,6 @@ function page.editor:eventHandler(event)
return true return true
end end
UI:setPages({
main = page,
})
local function reload() local function reload()
loadApplications() loadApplications()
page:refresh() page:refresh()

View File

@ -45,5 +45,6 @@ if settings then
end end
end end
return settingsTab -- this needs lots of work - currently only works with booleans
--return settingsTab
end end

View File

@ -6,10 +6,11 @@ Shortcut keys
* l: Lua application * l: Lua application
* f: Files * f: Files
* e: Edit an application (or right-click) * e: Edit an application (or right-click)
* n: Network
* control-n: Add a new application * control-n: Add a new application
* delete: Delete an application * delete: Delete an application
Adding a new application Adding a new application
======================== ========================
The run entry can be either a disk file or a URL. The run entry can be either a disk file or a URL.
Icons must be in NFT format with a height of 3 and a width of 3 to 8 characters. Icons must be in NFT format with a height of 3 and a width of 3 to 8 characters. Magenta is used for transparency.

View File

@ -77,6 +77,9 @@ function UI.Viewport:getViewArea()
end end
function UI.Viewport:eventHandler(event) function UI.Viewport:eventHandler(event)
if #self.lines <= self.height then
return
end
if event.type == 'scroll_down' then if event.type == 'scroll_down' then
self:setScrollPosition(self.offy + 1, self.offx) self:setScrollPosition(self.offy + 1, self.offx)
elseif event.type == 'scroll_up' then elseif event.type == 'scroll_up' then