diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config/default/sysdir | 1 | ||||
-rw-r--r-- | src/config/default/theme.lua | 62 | ||||
-rw-r--r-- | src/config/retro/sysdir | 1 | ||||
-rw-r--r-- | src/config/retro/theme.lua | 55 | ||||
-rw-r--r-- | src/lib/lua/luaconf.h | 2 | ||||
-rw-r--r-- | src/sysapp/login/main.lua | 12 | ||||
-rw-r--r-- | src/syslua/lx/tk.lua | 59 |
7 files changed, 145 insertions, 47 deletions
diff --git a/src/config/default/sysdir b/src/config/default/sysdir new file mode 100644 index 0000000..cbe4219 --- /dev/null +++ b/src/config/default/sysdir @@ -0,0 +1 @@ +root:/sys diff --git a/src/config/default/theme.lua b/src/config/default/theme.lua new file mode 100644 index 0000000..2e42337 --- /dev/null +++ b/src/config/default/theme.lua @@ -0,0 +1,62 @@ +local theme = { + fonts = { + default = 'veramono.ttf', + title = 'veramono.ttf' + }, + fontsize = { + default = 16, + title = 16 + }, + colors = { + window_border = function(tk) return tk.rgb(255, 128, 0) end, + window_title_bg = function(tk) return tk.rgb(255, 255, 255) end, + window_title = function(tk) return tk.rgb(0, 0, 0) end, + default_bg = function(tk) return tk.rgb(240, 240, 240) end, + default = function(tk) return tk.rgb(0, 0, 0) end, + scrollbar = function(tk) return tk.rgb(0, 0, 0) end, + resizebox = function(tk) return tk.rgb(255, 255, 255) end, + resizebox_border = function(tk) return tk.rgb(0, 0, 0) end, + button = { + good = { + text = function(tk) return tk.rgb(0, 0, 0) end, + bg = function(tk) return tk.rgb(128, 255, 128) end + }, + bad = { + text = function(tk) return tk.rgb(0, 0, 0) end, + bg = function(tk) return tk.rgb(255, 128, 128) end + }, + action = { + text = function(tk) return tk.rgb(0, 0, 0) end, + bg = function(tk) return tk.rgb(128, 128, 255) end + } + } + + }, + draw_bg = function(x0, y0, buf) + local step = 32 + local halfstep = 16 + for x = x0 - (x0 % step), x0 + buf:width(), step do + for y = y0 - (y0 % step), y0 + buf:height(), step do + buf:fillrect(x - x0, y - y0, halfstep, halfstep, buf:rgb(110, 110, 140)) + buf:fillrect(x - x0 + halfstep, y - y0 + halfstep, halfstep, halfstep, buf:rgb(110, 110, 140)) + buf:fillrect(x - x0 + halfstep, y - y0, halfstep, halfstep, buf:rgb(110, 140, 110)) + buf:fillrect(x - x0, y - y0 + halfstep, halfstep, halfstep, buf:rgb(110, 140, 110)) + end + end + end, + draw_image_bg = function(x0, y0, buf) + local step = 20 + local halfstep = 10 + for x = x0 - (x0 % step), x0 + buf:width(), step do + for y = y0 - (y0 % step), y0 + buf:height(), step do + buf:fillrect(x - x0, y - y0, halfstep, halfstep, buf:rgb(150, 150, 150)) + buf:fillrect(x - x0 + halfstep, y - y0 + halfstep, halfstep, halfstep, buf:rgb(150, 150, 150)) + buf:fillrect(x - x0 + halfstep, y - y0, halfstep, halfstep, buf:rgb(170, 170, 170)) + buf:fillrect(x - x0, y - y0 + halfstep, halfstep, halfstep, buf:rgb(170, 170, 170)) + end + end + end + +} + +return theme diff --git a/src/config/retro/sysdir b/src/config/retro/sysdir new file mode 100644 index 0000000..cbe4219 --- /dev/null +++ b/src/config/retro/sysdir @@ -0,0 +1 @@ +root:/sys diff --git a/src/config/retro/theme.lua b/src/config/retro/theme.lua new file mode 100644 index 0000000..673ab3d --- /dev/null +++ b/src/config/retro/theme.lua @@ -0,0 +1,55 @@ +local theme = { + fonts = { + default = 'galax___.ttf', + title = 'faceptbs.ttf' + }, + fontsize = { + default = 16, + title = 16 + }, + colors = { + window_border = function(tk) return tk.rgb(0, 128, 128) end, + window_title_bg = function(tk) return tk.rgb(0, 0, 0) end, + window_title = function(tk) return tk.rgb(255, 0, 255) end, + default_bg = function(tk) return tk.rgb(0, 0, 0) end, + default = function(tk) return tk.rgb(255, 255, 255) end, + scrollbar = function(tk) return tk.rgb(0, 255, 255) end, + resizebox = function(tk) return tk.rgb(0, 0, 0) end, + resizebox_border = function(tk) return tk.rgb(0, 255, 255) end, + button = { + good = { + text = function(tk) return tk.rgb(0, 255, 0) end, + bg = function(tk) return tk.rgb(0, 0, 0) end + }, + bad = { + text = function(tk) return tk.rgb(255, 0, 0) end, + bg = function(tk) return tk.rgb(0, 0, 0) end + }, + action = { + text = function(tk) return tk.rgb(128, 128, 255) end, + bg = function(tk) return tk.rgb(0, 0, 0) end + } + } + }, + draw_bg = function(x0, y0, buf) + local step = 32 + local halfstep = 16 + buf:fillrect(0, 0, buf:width(), buf:height(), buf:rgb(0, 0, 0)) + for x = x0 - (x0 % step), x0 + buf:width(), step do + for y = y0 - (y0 % step), y0 + buf:height(), step do + buf:fillrect(x - x0, y - y0 + halfstep, step, 1, buf:rgb(0, 0, 255)) + buf:fillrect(x - x0 + halfstep, y - y0, 1, step, buf:rgb(0, 0, 255)) + end + end + end, + draw_image_bg = function(x0, y0, buf) + local step = 4 + local halfstep = 2 + for y = y0 - (y0 % step), y0 + buf:height(), step do + buf:fillrect(0, y - y0, buf:width(), halfstep, buf:rgb(64, 64, 64)) + buf:fillrect(0, y - y0 + halfstep, buf:width(), halfstep, buf:rgb(80, 80, 80)) + end + end +} + +return theme diff --git a/src/lib/lua/luaconf.h b/src/lib/lua/luaconf.h index c0cfb0f..24e4a5d 100644 --- a/src/lib/lua/luaconf.h +++ b/src/lib/lua/luaconf.h @@ -178,7 +178,7 @@ #define LUA_PATH_DEFAULT \ LUA_ROOT"?.lua;" LUA_ROOT"?/init.lua;" \ LUA_APPROOT"?.lua;" LUA_APPROOT"?/init.lua;" \ - "./?.lua;" "./?/init.lua" + "./?.lua;" "./?/init.lua;" "?.lua" #define LUA_CPATH_DEFAULT \ LUA_ROOT"?.so;" "./?.so" diff --git a/src/sysapp/login/main.lua b/src/sysapp/login/main.lua index 1e9bba1..67ce3fe 100644 --- a/src/sysapp/login/main.lua +++ b/src/sysapp/login/main.lua @@ -51,8 +51,8 @@ function alert(text, on_dismiss) tk.grid({}, { { tk.text({padding = 16}, text) }, { tk.box({center_content = true, height = 40}, - tk.text({background = tk.rgb(0, 0, 0), - color = tk.rgb(0, 255, 0), + tk.text({background = tk.theme.colors.button.good.bg(tk), + color = tk.theme.colors.button.good.text(tk), padding = 4, on_click = function() win.close() end}, "Ok")) @@ -85,8 +85,8 @@ local function open_listing(path) tk.text(name), tk.text(tostring(size)), tk.box({center_content = true, width = 32}, - tk.text({background = tk.rgb(0, 0, 0), - color = tk.rgb(128, 128, 255), + tk.text({background = tk.theme.colors.button.action.bg(tk), + color = tk.theme.colors.button.action.text(tk), on_click = function() open_listing(path) end}, "open")) } @@ -125,8 +125,8 @@ local function fsline(fs) return { tk.text(fs .. ":/"), tk.box({center_content = true, width = 32}, - tk.text({background = tk.rgb(0, 0, 0), - color = tk.rgb(128, 128, 255), + tk.text({background = tk.theme.colors.button.action.bg(tk), + color = tk.theme.colors.button.action.text(tk), on_click = function() open_listing(fs .. ":/") end}, "open")) } diff --git a/src/syslua/lx/tk.lua b/src/syslua/lx/tk.lua index 92043db..e8686ba 100644 --- a/src/syslua/lx/tk.lua +++ b/src/syslua/lx/tk.lua @@ -246,13 +246,19 @@ function tk.init(gui, root_widget) if root_widget.parent ~= nil then return end root_widget.parent = gui + + tk.theme = require 'config:/theme' tk.fonts = { ["vera.ttf"] = draw.load_ttf_font("sys:/fonts/vera.ttf"), ["veraserif.ttf"] = draw.load_ttf_font("sys:/fonts/veraserif.ttf"), ["veramono.ttf"] = draw.load_ttf_font("sys:/fonts/veramono.ttf"), + ["faceptbs.ttf"] = draw.load_ttf_font("sys:/fonts/faceptbs.ttf"), + ["zekton.ttf"] = draw.load_ttf_font("sys:/fonts/zekton.ttf"), + ["galax___.ttf"] = draw.load_ttf_font("sys:/fonts/galax___.ttf"), } - tk.fonts.default = tk.fonts["vera.ttf"] + tk.fonts.default = tk.fonts[tk.theme.fonts.default] + tk.fonts.title = tk.fonts[tk.theme.fonts.title] function tk.rgb(r, g, b) return gui.surface:rgb(r, g, b) @@ -310,22 +316,7 @@ function tk.image(a, b) image.img = img function image:draw(x0, y0, buf) - local step = 4 - local halfstep = 2 - for y = y0 - (y0 % step), y0 + buf:height(), step do - buf:fillrect(0, y - y0, buf:width(), halfstep, buf:rgb(64, 64, 64)) - buf:fillrect(0, y - y0 + halfstep, buf:width(), halfstep, buf:rgb(80, 80, 80)) - end - -- local step = 20 - -- local halfstep = 10 - -- for x = x0 - (x0 % step), x0 + buf:width(), step do - -- for y = y0 - (y0 % step), y0 + buf:height(), step do - -- buf:fillrect(x - x0, y - y0, halfstep, halfstep, buf:rgb(150, 150, 150)) - -- buf:fillrect(x - x0 + halfstep, y - y0 + halfstep, halfstep, halfstep, buf:rgb(150, 150, 150)) - -- buf:fillrect(x - x0 + halfstep, y - y0, halfstep, halfstep, buf:rgb(170, 170, 170)) - -- buf:fillrect(x - x0, y - y0 + halfstep, halfstep, halfstep, buf:rgb(170, 170, 170)) - -- end - -- end + tk.theme.draw_image_bg(x0, y0, buf) if x0 < self.img:width() and y0 < self.img:height() then buf:blit(0, 0, self.img:sub(x0, y0, self.img:width(), self.img:height())) end @@ -341,8 +332,8 @@ function tk.text(a, b) -- Some defaults opts.text_size = opts.text_size or 16 opts.padding = opts.padding or 2 - opts.background = opts.background or tk.rgb(0, 0, 0) - opts.color = opts.color or tk.rgb(255, 255, 255) + opts.background = opts.background or tk.theme.colors.default_bg(tk) + opts.color = opts.color or tk.theme.colors.default(tk) opts.line_spacing = opts.line_spacing or 1 if opts.word_wrap == nil then opts.word_wrap = true end opts.font = opts.font or tk.fonts.default @@ -389,7 +380,7 @@ function tk.box(a, b) opts.min_height = opts.min_height or 8 opts.center_content = opts.center_content or false opts.constrain_size = opts.constrain_size or false - opts.background_color = opts.background_color or tk.rgb(0, 0, 0) + opts.background_color = opts.background_color or tk.theme.colors.default_bg(tk) opts.control_size = opts.control_size or 12 local box = tk.widget(content.width, content.height, opts) @@ -486,16 +477,16 @@ function tk.box(a, b) end if self.vresize or self.hresize then - buf:rect(self.width - csz - x0, self.height - csz - y0, csz, csz, buf:rgb(0, 255, 255)) - buf:fillrect(self.width - csz + 1 - x0, self.height - csz + 1 - y0, csz - 2, csz - 2, buf:rgb(0, 0, 0)) + buf:rect(self.width - csz - x0, self.height - csz - y0, csz, csz, tk.theme.colors.resizebox_border(tk)) + buf:fillrect(self.width - csz + 1 - x0, self.height - csz + 1 - y0, csz - 2, csz - 2, tk.theme.colors.resizebox(tk)) end if self.hscroll and self.width < self.content.width then local barsize, barpos = self:barcalc(self.content.x, self.content.width, self.width) - buf:fillrect(barpos + 4 - x0, self.height - csz + 2 - y0, barsize - 8, csz - 4, buf:rgb(0, 255, 255)) + buf:fillrect(barpos + 4 - x0, self.height - csz + 2 - y0, barsize - 8, csz - 4, tk.theme.colors.scrollbar(tk)) end if self.vscroll and self.height < self.content.height then local barsize, barpos = self:barcalc(self.content.y, self.content.height, self.height) - buf:fillrect(self.width - csz + 2 - x0, barpos + 4 - y0, csz - 4, barsize - 8, buf:rgb(0, 255, 255)) + buf:fillrect(self.width - csz + 2 - x0, barpos + 4 - y0, csz - 4, barsize - 8, tk.theme.colors.scrollbar(tk)) end end @@ -768,10 +759,10 @@ function tk.window_manager() function win:draw(x0, y0, buf) self:draw_sub(x0, y0, buf, self.content) - buf:rect(-x0, -y0, self.width, self.height, buf:rgb(0, 128, 128)) - buf:fillrect(-x0+1, -y0+1, win.width-2, 20, buf:rgb(0, 0, 0)) + buf:rect(-x0, -y0, self.width, self.height, tk.theme.colors.window_border(tk)) + buf:fillrect(-x0+1, -y0+1, win.width-2, 20, tk.theme.colors.window_title_bg(tk)) if win.title then - buf:write(-x0+2, -y0+2, win.title, tk.fonts.default, 16, buf:rgb(255, 0, 255)) + buf:write(-x0+2, -y0+2, win.title, tk.fonts.title, 16, tk.theme.colors.window_title(tk)) end end @@ -862,19 +853,7 @@ function tk.window_manager() -- Draw background function draw_background(x0, y0, buf) - local step = 32 - local halfstep = 16 - buf:fillrect(0, 0, buf:width(), buf:height(), buf:rgb(0, 0, 0)) - for x = x0 - (x0 % step), x0 + buf:width(), step do - for y = y0 - (y0 % step), y0 + buf:height(), step do - buf:fillrect(x - x0, y - y0 + halfstep, step, 1, buf:rgb(0, 0, 255)) - buf:fillrect(x - x0 + halfstep, y - y0, 1, step, buf:rgb(0, 0, 255)) - --buf:fillrect(x - x0, y - y0, halfstep, halfstep, buf:rgb(110, 110, 140)) - --buf:fillrect(x - x0 + halfstep, y - y0 + halfstep, halfstep, halfstep, buf:rgb(110, 110, 140)) - --buf:fillrect(x - x0 + halfstep, y - y0, halfstep, halfstep, buf:rgb(110, 140, 110)) - --buf:fillrect(x - x0, y - y0 + halfstep, halfstep, halfstep, buf:rgb(110, 140, 110)) - end - end + tk.theme.draw_bg(x0, y0, buf) end for _, reg in pairs(remaining) do draw_background(reg.x, reg.y, buf:sub(reg.x - x0, reg.y - y0, reg.w, reg.h)) |