From 623cfeb9de7ff4bcc710b5a4e41cc354bb2e3f0c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 2 Dec 2019 00:06:10 +0100 Subject: Add padding for image --- src/Body.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 01f0292..be5267a 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -137,6 +137,8 @@ namespace QuickMedia { const float font_height = title_text.getCharacterSize() + 4.0f; const float image_max_height = 100.0f; const float spacing_y = 15.0f; + const float padding_x = 10.0f; + const float image_padding_x = 5.0f; const float padding_y = 5.0f; const float start_y = pos.y; @@ -256,7 +258,7 @@ namespace QuickMedia { item_background.setSize(sf::Vector2f(size.x, item_height)); window.draw(item_background); - float text_offset_x = 0.0f; + float text_offset_x = padding_x; if(draw_thumbnails) { // TODO: Verify if this is safe. The thumbnail is being modified in another thread // and it might not be fully finished before the native handle is set? @@ -268,19 +270,19 @@ namespace QuickMedia { auto image_scale_ratio = scale.x / scale.y; const float width_ratio = height_ratio * image_scale_ratio; image.setScale(width_ratio, height_ratio); - image.setPosition(item_pos + sf::Vector2f(0.0f, padding_y)); + image.setPosition(item_pos + sf::Vector2f(image_padding_x, padding_y)); window.draw(image); - text_offset_x = width_ratio * image_size.x; + text_offset_x += image_padding_x + width_ratio * image_size.x; } else if(!item->thumbnail_url.empty()) { - image_fallback.setPosition(item_pos + sf::Vector2f(0.0f, padding_y)); + image_fallback.setPosition(item_pos + sf::Vector2f(image_padding_x, padding_y)); window.draw(image_fallback); - text_offset_x = image_fallback.getSize().x; + text_offset_x += image_padding_x + image_fallback.getSize().x; } } if(!item->author.empty()) { author_text.setString(item->author); - author_text.setPosition(std::floor(item_pos.x + text_offset_x + 10.0f), std::floor(item_pos.y + padding_y)); + author_text.setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y)); window.draw(author_text); sf::Vector2f replies_text_pos = author_text.getPosition(); @@ -296,7 +298,7 @@ namespace QuickMedia { item_pos.y += author_text.getCharacterSize() + 2.0f; } title_text.setString(item->title); - title_text.setPosition(std::floor(item_pos.x + text_offset_x + 10.0f), std::floor(item_pos.y + padding_y)); + title_text.setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y)); window.draw(title_text); // TODO: Do the same for non-manga content @@ -307,7 +309,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 - 10.0f), std::floor(item_pos.y)); + progress_text.setPosition(std::floor(item_pos.x + size.x - bounds.width - padding_x), std::floor(item_pos.y)); window.draw(progress_text); } } -- cgit v1.2.3