aboutsummaryrefslogtreecommitdiff
path: root/src/Theme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Theme.cpp')
-rw-r--r--src/Theme.cpp49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/Theme.cpp b/src/Theme.cpp
index d498ef3..523a324 100644
--- a/src/Theme.cpp
+++ b/src/Theme.cpp
@@ -1,19 +1,36 @@
#include "../include/Theme.hpp"
#include "../include/GsrInfo.hpp"
+
#include <assert.h>
namespace gsr {
static Theme *theme = nullptr;
- bool init_theme(const GsrInfo &gsr_info, mgl::vec2i window_size, const std::string &resources_path) {
+ bool Theme::set_window_size(mgl::vec2i window_size) {
+ if(std::abs(window_size.x - window_width) < 0.1f && std::abs(window_size.y - window_height) < 0.1f)
+ return true;
+
+ window_width = window_size.x;
+ window_height = window_size.y;
+
+ if(!theme->title_font.load_from_file(theme->title_font_file, std::max(16.0f, window_size.y * 0.019f)))
+ return false;
+
+ if(!theme->top_bar_font.load_from_file(theme->title_font_file, std::max(23.0f, window_size.y * 0.03f)))
+ return false;
+
+ if(!theme->body_font.load_from_file(theme->body_font_file, std::max(13.0f, window_size.y * 0.015f)))
+ return false;
+
+ return true;
+ }
+
+ bool init_theme(const GsrInfo &gsr_info, const std::string &resources_path) {
if(theme)
return true;
theme = new Theme();
- theme->window_width = window_size.x;
- theme->window_height = window_size.y;
-
switch(gsr_info.gpu_info.vendor) {
case GpuVendor::UNKNOWN: {
break;
@@ -32,31 +49,37 @@ namespace gsr {
}
}
- if(!theme->body_font_file.load("/usr/share/fonts/noto/NotoSans-Regular.ttf", mgl::MemoryMappedFile::LoadOptions{true, false}))
+ if(!theme->body_font_file.load((resources_path + "fonts/NotoSans-Regular.ttf").c_str(), 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}))
+ if(!theme->title_font_file.load((resources_path + "fonts/NotoSans-Bold.ttf").c_str(), mgl::MemoryMappedFile::LoadOptions{true, false}))
goto error;
- if(!theme->title_font.load_from_file(theme->title_font_file, std::max(16.0f, window_size.y * 0.019f)))
+ if(!theme->combobox_arrow_texture.load_from_file((resources_path + "images/combobox_arrow.png").c_str()))
goto error;
- if(!theme->top_bar_font.load_from_file(theme->title_font_file, std::max(23.0f, window_size.y * 0.03f)))
+ if(!theme->settings_texture.load_from_file((resources_path + "images/settings.png").c_str()))
goto error;
- if(!theme->body_font.load_from_file(theme->body_font_file, std::max(13.0f, window_size.y * 0.015f)))
+ if(!theme->folder_texture.load_from_file((resources_path + "images/folder.png").c_str()))
+ goto error;
+
+ if(!theme->up_arrow_texture.load_from_file((resources_path + "images/up_arrow.png").c_str()))
+ goto error;
+
+ if(!theme->replay_button_texture.load_from_file((resources_path + "images/replay.png").c_str()))
goto error;
- if(!theme->combobox_arrow_texture.load_from_file((resources_path + "images/combobox_arrow.png").c_str(), {false, false, false}))
+ if(!theme->record_button_texture.load_from_file((resources_path + "images/record.png").c_str()))
goto error;
- if(!theme->settings_texture.load_from_file((resources_path + "images/settings.png").c_str(), {false, false, false}))
+ if(!theme->stream_button_texture.load_from_file((resources_path + "images/stream.png").c_str()))
goto error;
- if(!theme->folder_texture.load_from_file((resources_path + "images/folder.png").c_str(), {false, false, false}))
+ if(!theme->close_texture.load_from_file((resources_path + "images/cross.png").c_str()))
goto error;
- if(!theme->up_arrow_texture.load_from_file((resources_path + "images/up_arrow.png").c_str(), {false, false, false}))
+ if(!theme->logo_texture.load_from_file((resources_path + "images/gpu_screen_recorder_logo.png").c_str()))
goto error;
return true;