aboutsummaryrefslogtreecommitdiff
path: root/src/Body.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-02 03:38:32 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-02 03:38:32 +0200
commit275c6c9d801fffbf30fc702c1f683e519f66798f (patch)
tree75ae2c1999b9f42ca72cb9803fc682a4ddee6f5b /src/Body.cpp
parent4ae711eb3ca9157cf90de946517a1a2726d27024 (diff)
Change tab style, floor cleanup
Diffstat (limited to 'src/Body.cpp')
-rw-r--r--src/Body.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 3f24e7d..ea43781 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -582,8 +582,8 @@ namespace QuickMedia {
if(!show_drop_shadow)
return;
- const sf::Color color(0, 0, 0, 50);
- const float height = 5.0f;
+ const sf::Color color = get_theme().background_color;
+ const float height = 20.0f;
sf::Vertex gradient_points[4];
gradient_points[0] = sf::Vertex(body_pos + sf::Vector2f(0.0f, 0.0f), color);
@@ -792,7 +792,8 @@ namespace QuickMedia {
double scrollbar_offset_y = body_total_height == 0.0 ? 0.0 : (std::abs(page_scroll) / body_total_height);
RoundedRectangle scrollbar(
- sf::Vector2f(std::floor(5.0f * get_config().scale), std::floor(scrollbar_max_height * scrolling_bar_height_ratio)), std::floor(3.0f * get_config().scale),
+ vec2f_round(5.0f * get_config().scale, scrollbar_max_height * scrolling_bar_height_ratio),
+ std::floor(3.0f * get_config().scale),
get_theme().selected_color,
rounded_rectangle_shader);
@@ -1457,7 +1458,7 @@ namespace QuickMedia {
const float timestamp_text_y = std::floor(item_pos.y + padding_y - text_offset_y);
if(item->author_text && !merge_with_previous) {
- item->author_text->setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y - text_offset_y));
+ item->author_text->setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y));
item->author_text->draw(window);
sf::Vector2f replies_text_pos = item->author_text->getPosition() + sf::Vector2f(0.0f, 5.0f);
@@ -1481,7 +1482,7 @@ namespace QuickMedia {
float embedded_item_height = item->embedded_item ? get_item_height(item->embedded_item.get(), embedded_item_width, true, false) : ((body_spacing[body_theme].embedded_item_font_size + 5.0f) + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
sf::RectangleShape border_left(sf::Vector2f(embedded_item_border_width, std::floor(embedded_item_height)));
border_left.setFillColor(get_theme().embedded_item_border_color);
- border_left.setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 2.0f));
+ border_left.setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 2.0f));
window.draw(border_left);
if(item->embedded_item) {
@@ -1490,24 +1491,21 @@ namespace QuickMedia {
draw_item(window, item->embedded_item, embedded_item_pos, embedded_item_size, false, true);
} else {
embedded_item_load_text.setString(embedded_item_status_to_string(item->embedded_item_status));
- embedded_item_load_text.setPosition(std::floor(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x), std::floor(item_pos.y + embedded_item_height * 0.5f - (body_spacing[body_theme].embedded_item_font_size + 5.0f) * 0.5f + 6.0f));
+ embedded_item_load_text.setPosition(vec2f_round(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x, item_pos.y + embedded_item_height * 0.5f - (body_spacing[body_theme].embedded_item_font_size + 5.0f) * 0.5f + 6.0f));
window.draw(embedded_item_load_text);
}
item_pos.y += embedded_item_height + 4.0f;
}
- //title_text.setString(item->title);
- //title_text.setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y));
- //window.draw(title_text);
if(item->title_text) {
- item->title_text->setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y - text_offset_y));
+ item->title_text->setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y));
item->title_text->draw(window);
item_pos.y += item->title_text->getHeight() - 2.0f + std::floor(3.0f * get_config().scale);
}
if(item->description_text) {
float height_offset = 0.0f;
- item->description_text->setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y - text_offset_y) + height_offset);
+ item->description_text->setPosition(vec2f_round(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y + height_offset));
item->description_text->draw(window);
item_pos.y += item->description_text->getHeight() - 2.0f;
}
@@ -1521,8 +1519,8 @@ namespace QuickMedia {
auto &reaction = item->reactions[i];
reaction.text->updateGeometry();
reaction_max_height = std::max(reaction_max_height, reaction.text->getHeight());
- reaction.text->setPosition(std::floor(item_pos.x + text_offset_x + reaction_offset_x + body_spacing[body_theme].reaction_background_padding_x), std::floor(item_pos.y + padding_y - 4.0f + body_spacing[body_theme].reaction_background_padding_y));
- reaction_background.set_position(sf::Vector2f(std::floor(item_pos.x + text_offset_x + reaction_offset_x), std::floor(item_pos.y + padding_y)));
+ reaction.text->setPosition(vec2f_round(item_pos.x + text_offset_x + reaction_offset_x + body_spacing[body_theme].reaction_background_padding_x, item_pos.y + padding_y - 4.0f + body_spacing[body_theme].reaction_background_padding_y));
+ reaction_background.set_position(vec2f_round(item_pos.x + text_offset_x + reaction_offset_x, item_pos.y + padding_y));
reaction_background.set_size(sf::Vector2f(reaction.text->getWidth() + body_spacing[body_theme].reaction_background_padding_x * 2.0f, reaction.text->getHeight() + body_spacing[body_theme].reaction_background_padding_y * 2.0f));
reaction_background.draw(window);
reaction_offset_x += reaction.text->getWidth() + body_spacing[body_theme].reaction_background_padding_x * 2.0f + body_spacing[body_theme].reaction_spacing_x;
@@ -1537,7 +1535,7 @@ namespace QuickMedia {
}
if(item_index == selected_item && item->timestamp_text) {
- item->timestamp_text->setPosition(std::floor(item_pos.x + size.x - item->timestamp_text->getLocalBounds().width - body_spacing[body_theme].padding_x), timestamp_text_y + 8.0f);
+ item->timestamp_text->setPosition(vec2f_round(item_pos.x + size.x - item->timestamp_text->getLocalBounds().width - body_spacing[body_theme].padding_x, timestamp_text_y + 8.0f));
window.draw(*item->timestamp_text);
}
@@ -1553,7 +1551,7 @@ namespace QuickMedia {
if(current_json.isNumeric() && total_json.isNumeric()) {
progress_text.setString(std::string("Page: ") + std::to_string(current_json.asInt()) + "/" + std::to_string(total_json.asInt()));
auto bounds = progress_text.getLocalBounds();
- progress_text.setPosition(std::floor(item_pos.x + size.x - bounds.width - body_spacing[body_theme].padding_x), timestamp_text_y + text_offset_y);
+ progress_text.setPosition(vec2f_round(item_pos.x + size.x - bounds.width - body_spacing[body_theme].padding_x, timestamp_text_y + text_offset_y));
window.draw(progress_text);
}
}