aboutsummaryrefslogtreecommitdiff
path: root/src/Tabs.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-17 19:18:19 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-17 19:18:34 +0100
commit02e029ed40f801e0710b09062069e7083cd30b93 (patch)
treeb3bd567ad0c03074064d62d32a876920aa58fab4 /src/Tabs.cpp
parentd4cd63129ae5dff8fd69525424e0f8cb9ae1a905 (diff)
Add local anime tracking. Check readme for more info about local_anime config
Diffstat (limited to 'src/Tabs.cpp')
-rw-r--r--src/Tabs.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/Tabs.cpp b/src/Tabs.cpp
index 6b33df1..213e11e 100644
--- a/src/Tabs.cpp
+++ b/src/Tabs.cpp
@@ -8,13 +8,16 @@
#include <mglpp/window/Event.hpp>
#include <mglpp/window/Window.hpp>
#include <mglpp/graphics/Texture.hpp>
-#include <cmath>
namespace QuickMedia {
- 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 float floor(float v) {
+ return (int)v;
+ }
+
+ static const float tab_text_size = floor(get_config().tab.font_size * get_config().scale * get_config().font_scale);
+ static const float tab_height = tab_text_size + floor(10.0f * get_config().scale);
static const float tab_min_width = 250.0f;
- static const float tab_margin_x = std::floor(10.0f * get_config().spacing_scale);
+ static const float tab_margin_x = floor(10.0f * get_config().spacing_scale);
// static
float Tabs::get_height() {
@@ -23,7 +26,7 @@ namespace QuickMedia {
// static
float Tabs::get_shade_height() {
- return tab_height + std::floor(10.0f * get_config().scale * get_config().spacing_scale);
+ return tab_height + floor(10.0f * get_config().scale * get_config().spacing_scale);
}
Tabs::Tabs(mgl::Shader *rounded_rectangle_shader, mgl::Color shade_color) : background(mgl::vec2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().selected_color, rounded_rectangle_shader), shade_color(shade_color) {
@@ -98,14 +101,14 @@ namespace QuickMedia {
container_width = width;
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);
- tab_background_width = std::floor(width_per_tab - tab_margin_x*2.0f);
+ width_per_tab = floor(width / num_visible_tabs);
+ const float tab_text_y = floor(pos.y + tab_height*0.5f - tab_text_size);
+ tab_background_width = floor(width_per_tab - tab_margin_x*2.0f);
background.set_size(mgl::vec2f(tab_background_width, tab_height));
if(shade_color != mgl::Color(0, 0, 0, 0)) {
shade.set_size(mgl::vec2f(width, get_shade_height()));
- shade.set_position(mgl::vec2f(std::floor(pos.x), std::floor(pos.y)));
+ shade.set_position(mgl::vec2f(floor(pos.x), floor(pos.y)));
window.draw(shade);
}
@@ -131,7 +134,7 @@ namespace QuickMedia {
pos.x += scroll_fixed;
for(size_t i = 0; i < tabs.size(); ++i) {
const int index = i;
- const float background_pos_x = std::floor(pos.x + tab_index_to_x_offset(i));
+ const float background_pos_x = floor(pos.x + tab_index_to_x_offset(i));
if(background_pos_x - start_pos.x >= width - tab_margin_x) {
tabs_cutoff_right = true;
break;
@@ -141,12 +144,12 @@ namespace QuickMedia {
}
if((int)index == selected_tab) {
- background.set_position(mgl::vec2f(background_pos_x, std::floor(pos.y)));
+ background.set_position(mgl::vec2f(background_pos_x, floor(pos.y)));
background.draw(window);
}
mgl::Text &tab_text = tabs[index].text;
- float text_pos_x = std::floor(pos.x + i*width_per_tab + width_per_tab*0.5f - tab_text.get_bounds().size.x*0.5f);
+ float text_pos_x = floor(pos.x + i*width_per_tab + width_per_tab*0.5f - tab_text.get_bounds().size.x*0.5f);
text_pos_x = std::max(text_pos_x, background_pos_x);
window.set_view(create_scissor_view({ text_pos_x, tab_text_y }, { tab_background_width, tab_height }));
@@ -154,7 +157,7 @@ namespace QuickMedia {
window.set_view(prev_view);
}
- const float lw = std::floor(25.0f * get_config().scale);
+ const float lw = floor(25.0f * get_config().scale);
const float lh = background.get_size().y;
if(tabs_cutoff_left) {
@@ -224,6 +227,6 @@ namespace QuickMedia {
}
float Tabs::tab_index_to_x_offset(int index) {
- return std::floor(index*width_per_tab + tab_margin_x);
+ return floor(index*width_per_tab + tab_margin_x);
}
} \ No newline at end of file