aboutsummaryrefslogtreecommitdiff
path: root/src/syslua/lx
diff options
context:
space:
mode:
Diffstat (limited to 'src/syslua/lx')
-rw-r--r--src/syslua/lx/tk.lua59
1 files changed, 19 insertions, 40 deletions
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))