Launcher looks more like in other modern OS
This commit is contained in:
parent
3fbc521975
commit
41bf7e2f31
6
API.md
6
API.md
@ -22,9 +22,11 @@ Usable from node functions, from apps or outsite
|
||||
## App Definition
|
||||
`laptop.register_app(internal_shortname, { definitiontable })` - add a new app or view
|
||||
- `app_name` - App name shown in launcher. If not defined the app is just a view, not visible in launcher but can be activated. This way multi-screen apps are possible
|
||||
- `app_icon` - Icon to be shown in launcher. If nothing given the default icon is used
|
||||
- `app_info` - Short app info visible in launcher tooltip
|
||||
- `background_img` - if set the image is added as background to formspec by framework
|
||||
- `formspec_func(app, os)` - Function, should return the app formspec (mandatory) During definition the "app" and the "os" are available
|
||||
- `receive_fields_func(app, os, fields, sender)` Function for input processing. The "app" and the "os" are available inside the call
|
||||
- `formspec_func(app, os)` - Function, should return the app formspec (mandatory) During definition the "app" and the "os" are available
|
||||
- `receive_fields_func(app, os, fields, sender)` Function for input processing. The "app" and the "os" are available inside the call
|
||||
|
||||
## App Object
|
||||
`local app = laptop.get_app(internal_shortname, os)` - Give the app object internal_shortname, connected to given os. Not necessary in formspec_func or receive_fields_func because given trough interface
|
||||
|
@ -3,6 +3,8 @@ laptop.register_app("launcher", {
|
||||
-- app_name = "Main launcher", -- not in launcher list
|
||||
background_img = "os_main2.png",
|
||||
formspec_func = function(app, os)
|
||||
local c_row_count = 4
|
||||
|
||||
local i = 0
|
||||
local out = ""
|
||||
local appslist_sorted = {}
|
||||
@ -13,7 +15,11 @@ laptop.register_app("launcher", {
|
||||
end
|
||||
table.sort(appslist_sorted, function(a,b) return a.name < b.name end)
|
||||
for i, e in ipairs(appslist_sorted) do
|
||||
out = out .. 'button['..2*i..',1;2,1;'..e.name..';'..e.def.app_name..']'
|
||||
local x = math.floor((i-1) / c_row_count)*2 + 1
|
||||
local y = ((i-1) % c_row_count)*2 + 1
|
||||
out = out .. 'image_button['..x..','..y..';1,1;'..(e.def.app_icon or 'logo.png')..';'..e.name..';]'..
|
||||
'label['..(x-0.5)..','..(y+1)..';'..e.def.app_name..']'..
|
||||
'tooltip['..e.name..';'..(e.def.app_info or e.name)..']' --;<bgcolor>;<fontcolor>]'
|
||||
end
|
||||
return out
|
||||
end,
|
||||
|
@ -1,5 +1,7 @@
|
||||
laptop.register_app("stickynote", {
|
||||
app_name = "Sticky note pad",
|
||||
app_icon = "notes_pad.png",
|
||||
app_info = "Write notes in simple text editor",
|
||||
formspec_func = function(app, os)
|
||||
local data = app:get_storage_ref()
|
||||
data.text = data.text or ""
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
laptop.register_app("demo1", {
|
||||
app_name = "Demo App",
|
||||
app_icon = "setting_wrench.png",
|
||||
app_info = "The first and simple demo app",
|
||||
formspec_func = function(app, os)
|
||||
return 'button[5,5;3,1;Back;Back to launcher]'
|
||||
end,
|
||||
|
Loading…
x
Reference in New Issue
Block a user