From b145d957e3809fd6c2d814c34c58234ade983bb0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 8 Sep 2024 17:07:22 +0200 Subject: More --- src/Theme.cpp | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'src/Theme.cpp') 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 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; -- cgit v1.2.3