aboutsummaryrefslogtreecommitdiff
path: root/src/Tabs.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-21 13:29:01 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-21 13:29:01 +0200
commit3ac1120fd40b84507c51f867559bd05adff4eecf (patch)
tree32a3d7e037dd0fa07f764e563cfaa304470ad7f1 /src/Tabs.cpp
parent0f151afa58c1f725a652eaa4444ce3e2b2509770 (diff)
Use shader for rounded rectangle, improve circle shader
Diffstat (limited to 'src/Tabs.cpp')
-rw-r--r--src/Tabs.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Tabs.cpp b/src/Tabs.cpp
index eb435fc..4437472 100644
--- a/src/Tabs.cpp
+++ b/src/Tabs.cpp
@@ -24,8 +24,7 @@ namespace QuickMedia {
return tab_height + std::floor(10.0f * get_ui_scale());
}
- Tabs::Tabs(sf::Color shade_color) : background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10), shade_color(shade_color) {
- background.setFillColor(tab_selected_color);
+ Tabs::Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color) : background(sf::Vector2f(1.0f, 1.0f), 10.0f, tab_selected_color, rounded_rectangle_shader), shade_color(shade_color) {
shade.setFillColor(shade_color);
}
@@ -70,7 +69,7 @@ namespace QuickMedia {
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);
tab_background_width = std::floor(width_per_tab - tab_margin_x*2.0f);
- background.setSize(sf::Vector2f(tab_background_width, tab_height));
+ background.set_size(sf::Vector2f(tab_background_width, tab_height));
shade.setSize(sf::Vector2f(width, get_shade_height()));
shade.setPosition(std::floor(pos.x), std::floor(pos.y));
@@ -106,8 +105,8 @@ namespace QuickMedia {
}
if((int)index == selected_tab) {
- background.setPosition(background_pos_x, std::floor(pos.y));
- window.draw(background);
+ background.set_position(sf::Vector2f(background_pos_x, std::floor(pos.y)));
+ background.draw(window);
}
sf::Text &tab_text = tab_texts[index];
@@ -121,7 +120,7 @@ namespace QuickMedia {
}
float lw = std::floor(25.0f * get_ui_scale());
- float lh = background.getSize().y;
+ float lh = background.get_size().y;
float line_offset_y = std::floor(lw * 0.35f);
@@ -144,11 +143,11 @@ namespace QuickMedia {
line.setOrigin(line.getSize().x * 0.5f, line.getSize().y * 0.5f);
line.rotate(-45.0f);
- line.setPosition(std::floor(start_pos.x + line.getLocalBounds().width), std::floor(pos.y + background.getSize().y * 0.5f - lh * 0.5f + line_offset_y));
+ 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));
window.draw(line);
line.rotate(-90.0f);
- line.setPosition(std::floor(start_pos.x + line.getLocalBounds().width), std::floor(pos.y + background.getSize().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_ui_scale())));
window.draw(line);
}
@@ -171,11 +170,11 @@ namespace QuickMedia {
line.setOrigin(line.getSize().x * 0.5f, line.getSize().y * 0.5f);
line.rotate(45.0f);
- line.setPosition(std::floor(start_pos.x + width - lw*0.75f + line.getLocalBounds().width), std::floor(pos.y + background.getSize().y * 0.5f - lh * 0.5f + line_offset_y));
+ 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));
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.getSize().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_ui_scale())));
window.draw(line);
}
}