summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-09-12 05:20:07 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-09-12 05:20:07 +0000
commit9a47e43ab72daa96bfb3e95e95c30e5703f39397 (patch)
tree04ed29f71978feb722b0b2246e9d88067812b9a4 /lua
parent1f5ce2438982860529e43f8ddf093164b920724a (diff)
downloadtangara-fw-9a47e43ab72daa96bfb3e95e95c30e5703f39397.tar.gz
daniel/theme-tweaks (#102)
- Multiple improvements + fixes - Add charge outline icon for improving readability with monochromatic themes - Add a chevron icon and update existing dropdown menus - Rename `set_style` to `set_subject` for disambiguation with lvgl's Style type Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/102 Reviewed-by: cooljqln <cooljqln@noreply.codeberg.org> Co-authored-by: ailurux <ailuruxx@gmail.com> Co-committed-by: ailurux <ailuruxx@gmail.com>
Diffstat (limited to 'lua')
-rw-r--r--lua/images.lua1
-rw-r--r--lua/img/bat/chg.pngbin8326 -> 8564 bytes
-rw-r--r--lua/img/bat/chg_outline.pngbin0 -> 6632 bytes
-rw-r--r--lua/img/bt.pngbin10120 -> 8304 bytes
-rw-r--r--lua/img/bt_conn.pngbin11932 -> 10417 bytes
-rw-r--r--lua/img/chevron.pngbin0 -> 584 bytes
-rw-r--r--lua/settings.lua8
-rw-r--r--lua/theme_dark.lua19
-rw-r--r--lua/theme_hicon.lua27
-rw-r--r--lua/theme_light.lua19
-rw-r--r--lua/widgets.lua6
11 files changed, 78 insertions, 2 deletions
diff --git a/lua/images.lua b/lua/images.lua
index 5bb33d4d..1d08ec17 100644
--- a/lua/images.lua
+++ b/lua/images.lua
@@ -15,6 +15,7 @@ local img = {
queue = lvgl.ImgData("//lua/img/queue.png"),
files = lvgl.ImgData("//lua/img/files.png"),
settings = lvgl.ImgData("//lua/img/settings.png"),
+ chevron = lvgl.ImgData("//lua/img/chevron.png"),
}
return img
diff --git a/lua/img/bat/chg.png b/lua/img/bat/chg.png
index 629586e3..7b0c1755 100644
--- a/lua/img/bat/chg.png
+++ b/lua/img/bat/chg.png
Binary files differ
diff --git a/lua/img/bat/chg_outline.png b/lua/img/bat/chg_outline.png
new file mode 100644
index 00000000..304aca7d
--- /dev/null
+++ b/lua/img/bat/chg_outline.png
Binary files differ
diff --git a/lua/img/bt.png b/lua/img/bt.png
index ae45dfbf..f441f2cb 100644
--- a/lua/img/bt.png
+++ b/lua/img/bt.png
Binary files differ
diff --git a/lua/img/bt_conn.png b/lua/img/bt_conn.png
index 890e4160..022d5c96 100644
--- a/lua/img/bt_conn.png
+++ b/lua/img/bt_conn.png
Binary files differ
diff --git a/lua/img/chevron.png b/lua/img/chevron.png
new file mode 100644
index 00000000..fdc7c97c
--- /dev/null
+++ b/lua/img/chevron.png
Binary files differ
diff --git a/lua/settings.lua b/lua/settings.lua
index 654ae62c..b23f9756 100644
--- a/lua/settings.lua
+++ b/lua/settings.lua
@@ -12,6 +12,7 @@ local database = require("database")
local usb = require("usb")
local font = require("font")
local main_menu = require("main_menu")
+local img = require("images")
local SettingsScreen = widgets.MenuScreen:new {
show_back = true,
@@ -213,6 +214,7 @@ local HeadphonesSettings = SettingsScreen:new {
local volume_chooser = self.content:Dropdown {
options = "Line Level (-10 dB)\nCD Level (+6 dB)\nMaximum (+10dB)",
selected = 1,
+ symbol = img.chevron,
}
local limits = { -10, 6, 10 }
volume_chooser:onevent(lvgl.EVENT.VALUE_CHANGED, function()
@@ -319,7 +321,9 @@ local ThemeSettings = SettingsScreen:new {
local theme_dir_iter = filesystem.iterator("/.themes/")
for dir in theme_dir_iter do
local theme_name = tostring(dir):match("(.+).lua$")
- themeOptions[theme_name] = "/sd/.themes/" .. theme_name .. ".lua"
+ if (theme_name) then
+ themeOptions[theme_name] = "/sd/.themes/" .. theme_name .. ".lua"
+ end
end
local saved_theme = theme.theme_filename();
@@ -346,6 +350,7 @@ local ThemeSettings = SettingsScreen:new {
local theme_chooser = self.content:Dropdown {
options = options,
+ symbol = img.chevron,
}
theme_chooser:set({selected = selected_idx})
@@ -388,6 +393,7 @@ local InputSettings = SettingsScreen:new {
local controls_chooser = self.content:Dropdown {
options = options,
+ symbol = img.chevron,
}
self.bindings = self.bindings + {
diff --git a/lua/theme_dark.lua b/lua/theme_dark.lua
index 41fddf81..ac1044c6 100644
--- a/lua/theme_dark.lua
+++ b/lua/theme_dark.lua
@@ -38,6 +38,7 @@ local theme_dark = {
},
button = {
{lvgl.PART.MAIN, lvgl.Style {
+ bg_opa = lvgl.OPA(100),
pad_left = 2,
pad_right = 2,
pad_top = 1,
@@ -217,6 +218,12 @@ local theme_dark = {
radius = 4
}},
},
+ bluetooth_icon = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = text_color,
+ }},
+ },
battery = {
{lvgl.PART.MAIN, lvgl.Style {
image_recolor_opa = 0,
@@ -240,6 +247,18 @@ local theme_dark = {
image_recolor = "#fdd833",
}},
},
+ battery_charge_outline = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = background_color,
+ }},
+ },
+ regulatory_icons = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = text_color,
+ }},
+ },
}
return theme_dark
diff --git a/lua/theme_hicon.lua b/lua/theme_hicon.lua
index 30947c18..59446bd7 100644
--- a/lua/theme_hicon.lua
+++ b/lua/theme_hicon.lua
@@ -40,6 +40,7 @@ local theme_hicon = {
},
button = {
{lvgl.PART.MAIN, lvgl.Style {
+ bg_opa = lvgl.OPA(100),
pad_left = 2,
pad_right = 2,
pad_top = 1,
@@ -188,6 +189,14 @@ local theme_hicon = {
bg_color = text_color,
text_color = background_color,
}},
+ {lvgl.PART.INDICATOR, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = text_color,
+ }},
+ {lvgl.PART.INDICATOR | lvgl.STATE.FOCUSED, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = background_color,
+ }},
},
dropdownlist = {
{lvgl.PART.MAIN, lvgl.Style{
@@ -244,6 +253,12 @@ local theme_hicon = {
radius = 4
}},
},
+ bluetooth_icon = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = text_color,
+ }},
+ },
battery = {
{lvgl.PART.MAIN, lvgl.Style {
image_recolor_opa = 255,
@@ -268,6 +283,18 @@ local theme_hicon = {
image_recolor = text_color,
}},
},
+ battery_charge_outline = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = background_color,
+ }},
+ },
+ regulatory_icons = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = text_color,
+ }},
+ },
}
return theme_hicon
diff --git a/lua/theme_light.lua b/lua/theme_light.lua
index 275d06ca..412fec25 100644
--- a/lua/theme_light.lua
+++ b/lua/theme_light.lua
@@ -20,7 +20,7 @@ local theme_light = {
{lvgl.PART.MAIN, lvgl.Style {
bg_opa = lvgl.OPA(100),
bg_color = background_color, -- Root background color
- text_color = text_color
+ text_color = text_color,
}},
},
header = {
@@ -37,6 +37,7 @@ local theme_light = {
},
button = {
{lvgl.PART.MAIN, lvgl.Style {
+ bg_opa = lvgl.OPA(100),
pad_left = 1,
pad_right = 1,
margin_all = 1,
@@ -185,6 +186,10 @@ local theme_light = {
{lvgl.PART.MAIN | lvgl.STATE.FOCUSED, lvgl.Style {
border_color = highlight_color,
}},
+ {lvgl.PART.INDICATOR, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = text_color,
+ }},
},
dropdownlist = {
{lvgl.PART.MAIN, lvgl.Style{
@@ -256,6 +261,12 @@ local theme_light = {
radius = 4
}},
},
+ bluetooth_icon = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = text_color,
+ }},
+ },
battery = {
{lvgl.PART.MAIN, lvgl.Style {
image_recolor_opa = 180,
@@ -280,6 +291,12 @@ local theme_light = {
image_recolor = "#fdd833",
}},
},
+ battery_charge_outline = {
+ {lvgl.PART.MAIN, lvgl.Style {
+ image_recolor_opa = 255,
+ image_recolor = background_color,
+ }},
+ },
regulatory_icons = {
{lvgl.PART.MAIN, lvgl.Style {
image_recolor_opa = 255,
diff --git a/lua/widgets.lua b/lua/widgets.lua
index 65d4e760..8112b656 100644
--- a/lua/widgets.lua
+++ b/lua/widgets.lua
@@ -13,6 +13,7 @@ local images = require("images")
local img = {
db = lvgl.ImgData("//lua/img/db.png"),
chg = lvgl.ImgData("//lua/img/bat/chg.png"),
+ chg_outline = lvgl.ImgData("//lua/img/bat/chg_outline.png"),
bat_100 = lvgl.ImgData("//lua/img/bat/100.png"),
bat_80 = lvgl.ImgData("//lua/img/bat/80.png"),
bat_60 = lvgl.ImgData("//lua/img/bat/60.png"),
@@ -149,6 +150,8 @@ function widgets.StatusBar(parent, opts)
local bt_icon = root:Image {}
local battery_icon = root:Image {}
local charge_icon = battery_icon:Image { src = img.chg }
+ local charge_icon_outline = battery_icon:Image { src = img.chg_outline }
+ charge_icon_outline:center();
charge_icon:center()
local is_charging = nil
@@ -180,9 +183,12 @@ function widgets.StatusBar(parent, opts)
if is_charging then
theme.set_subject(battery_icon, "battery_charging")
theme.set_subject(charge_icon, "battery_charge_icon")
+ theme.set_subject(charge_icon_outline, "battery_charge_outline")
charge_icon:clear_flag(lvgl.FLAG.HIDDEN)
+ charge_icon_outline:clear_flag(lvgl.FLAG.HIDDEN)
else
charge_icon:add_flag(lvgl.FLAG.HIDDEN)
+ charge_icon_outline:add_flag(lvgl.FLAG.HIDDEN)
end
battery_icon:set_src(src)
end