aboutsummaryrefslogtreecommitdiff
path: root/src/Theme.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-08-06 03:11:43 +0200
committerdec05eba <dec05eba@protonmail.com>2024-08-06 03:11:43 +0200
commitb778fd7cc654f28a2bfe0ff74537f120241b289c (patch)
treede1830608492356d818cce314094e2359a3a478a /src/Theme.cpp
parentae1897cf2ce6a447b253ffa8489b5c016a23fb41 (diff)
Change fonts, nicer combobox, add/remove audio track button
Diffstat (limited to 'src/Theme.cpp')
-rw-r--r--src/Theme.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/Theme.cpp b/src/Theme.cpp
index 0c99320..7db16aa 100644
--- a/src/Theme.cpp
+++ b/src/Theme.cpp
@@ -5,10 +5,14 @@
namespace gsr {
static Theme *theme = nullptr;
- void init_theme(const gsr::GsrInfo &gsr_info) {
- assert(!theme);
+ bool init_theme(const gsr::GsrInfo &gsr_info, mgl::vec2i window_size, const std::string &resources_path) {
+ if(theme)
+ return true;
+
theme = new Theme();
+ theme->window_height = window_size.y;
+
switch(gsr_info.gpu_info.vendor) {
case gsr::GpuVendor::UNKNOWN: {
break;
@@ -26,15 +30,40 @@ namespace gsr {
break;
}
}
+
+ if(!theme->body_font_file.load("/usr/share/fonts/noto/NotoSans-Regular.ttf", mgl::MemoryMappedFile::LoadOptions{true, false}))
+ goto error;
+
+ if(!theme->title_font_file.load("/usr/share/fonts/noto/NotoSans-Bold.ttf", mgl::MemoryMappedFile::LoadOptions{true, false}))
+ goto error;
+
+ if(!theme->title_font.load_from_file(theme->title_font_file, window_size.y * 0.019f))
+ goto error;
+
+ if(!theme->top_bar_font.load_from_file(theme->title_font_file, window_size.y * 0.03f))
+ goto error;
+
+ if(!theme->body_font.load_from_file(theme->body_font_file, window_size.y * 0.015f))
+ goto error;
+
+ if(!theme->combobox_arrow.load_from_file((resources_path + "images/combobox_arrow.png").c_str(), {false, false, false}))
+ goto error;
+
+ return true;
+
+ error:
+ deinit_theme();
+ return false;
}
void deinit_theme() {
- assert(theme);
- delete theme;
- theme = nullptr;
+ if(theme) {
+ delete theme;
+ theme = nullptr;
+ }
}
- const Theme& get_theme() {
+ Theme& get_theme() {
assert(theme);
return *theme;
}