aboutsummaryrefslogtreecommitdiff
path: root/src/Tabs.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-04 02:31:10 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-04 02:31:10 +0200
commitfa815c3eee27cdae69b2e765b03de62a13f6379d (patch)
tree4244ae7b62e2c94d749f0b199dd620bdd251dad0 /src/Tabs.cpp
parentdd4573e05cdfa2d9b99ef7a49c99e27c201da3e9 (diff)
Make font sizes customizable with a config file, see example-config.json. Remove environment variables
Diffstat (limited to 'src/Tabs.cpp')
-rw-r--r--src/Tabs.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Tabs.cpp b/src/Tabs.cpp
index de9e2b3..3745973 100644
--- a/src/Tabs.cpp
+++ b/src/Tabs.cpp
@@ -1,7 +1,7 @@
#include "../include/Tabs.hpp"
#include "../include/Body.hpp"
#include "../include/ResourceLoader.hpp"
-#include "../include/Utils.hpp"
+#include "../include/Config.hpp"
#include "../include/Theme.hpp"
#include <SFML/Window/Event.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
@@ -9,8 +9,8 @@
#include <cmath>
namespace QuickMedia {
- static const float tab_text_size = std::floor(16.0f * get_ui_scale() * get_font_scale());
- static const float tab_height = tab_text_size + std::floor(10.0f * get_ui_scale());
+ static const float tab_text_size = std::floor(get_config().tab.font_size * get_config().scale * get_config().font_scale);
+ static const float tab_height = tab_text_size + std::floor(10.0f * get_config().scale);
static const float tab_min_width = 250.0f;
static const float tab_margin_x = 10.0f;
@@ -21,7 +21,7 @@ namespace QuickMedia {
// static
float Tabs::get_shade_height() {
- return tab_height + std::floor(10.0f * get_ui_scale());
+ return tab_height + std::floor(10.0f * get_config().scale);
}
Tabs::Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color) : background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_current_theme().selected_color, rounded_rectangle_shader), shade_color(shade_color) {
@@ -91,7 +91,7 @@ namespace QuickMedia {
const int num_visible_tabs = std::min((int)tabs.size(), std::max(1, (int)(width / tab_min_width)));
width_per_tab = std::floor(width / num_visible_tabs);
- const float tab_text_y = std::floor(pos.y + tab_height*0.5f - (tab_text_size + 5.0f*get_ui_scale())*0.5f);
+ const float tab_text_y = std::floor(pos.y + tab_height*0.5f - (tab_text_size + 5.0f*get_config().scale)*0.5f);
tab_background_width = std::floor(width_per_tab - tab_margin_x*2.0f);
background.set_size(sf::Vector2f(tab_background_width, tab_height));
@@ -145,7 +145,7 @@ namespace QuickMedia {
glDisable(GL_SCISSOR_TEST);
}
- float lw = std::floor(25.0f * get_ui_scale());
+ float lw = std::floor(25.0f * get_config().scale);
float lh = background.get_size().y;
float line_offset_y = std::floor(lw * 0.35f);
@@ -164,7 +164,7 @@ namespace QuickMedia {
window.draw(gradient_points, 4, sf::Quads);
- sf::RectangleShape line(sf::Vector2f(std::floor(10.0f * get_ui_scale()), std::floor(2.0f * get_ui_scale())));
+ sf::RectangleShape line(sf::Vector2f(std::floor(10.0f * get_config().scale), std::floor(2.0f * get_config().scale)));
line.setFillColor(get_current_theme().arrow_color);
line.setOrigin(line.getSize().x * 0.5f, line.getSize().y * 0.5f);
@@ -173,7 +173,7 @@ namespace QuickMedia {
window.draw(line);
line.rotate(-90.0f);
- line.setPosition(std::floor(start_pos.x + line.getLocalBounds().width), std::floor(pos.y + background.get_size().y * 0.5f - lh * 0.5f + line_offset_y + std::floor(7.0f * get_ui_scale())));
+ line.setPosition(std::floor(start_pos.x + line.getLocalBounds().width), std::floor(pos.y + background.get_size().y * 0.5f - lh * 0.5f + line_offset_y + std::floor(7.0f * get_config().scale)));
window.draw(line);
}
@@ -191,7 +191,7 @@ namespace QuickMedia {
window.draw(gradient_points, 4, sf::Quads);
- sf::RectangleShape line(sf::Vector2f(std::floor(10.0f * get_ui_scale()), std::floor(2.0f * get_ui_scale())));
+ sf::RectangleShape line(sf::Vector2f(std::floor(10.0f * get_config().scale), std::floor(2.0f * get_config().scale)));
line.setFillColor(get_current_theme().arrow_color);
line.setOrigin(line.getSize().x * 0.5f, line.getSize().y * 0.5f);
@@ -200,7 +200,7 @@ namespace QuickMedia {
window.draw(line);
line.rotate(-90.0f);
- line.setPosition(std::floor(start_pos.x + width - lw*0.75f + line.getLocalBounds().width), std::floor(pos.y + background.get_size().y * 0.5f - lh * 0.5f + line_offset_y + std::floor(7.0f * get_ui_scale())));
+ line.setPosition(std::floor(start_pos.x + width - lw*0.75f + line.getLocalBounds().width), std::floor(pos.y + background.get_size().y * 0.5f - lh * 0.5f + line_offset_y + std::floor(7.0f * get_config().scale)));
window.draw(line);
}
}