aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-12-02 00:06:10 +0100
committerdec05eba <dec05eba@protonmail.com>2019-12-02 00:06:10 +0100
commit623cfeb9de7ff4bcc710b5a4e41cc354bb2e3f0c (patch)
tree1e02ba8b3ac3dfd40959dd2fdcc76c346fc55cba
parentf330b16a2c36585be8ce8102cfb11e4914ed9a69 (diff)
Add padding for image
-rw-r--r--README.md5
-rw-r--r--src/Body.cpp18
2 files changed, 14 insertions, 9 deletions
diff --git a/README.md b/README.md
index e17d1da..3ce0e43 100644
--- a/README.md
+++ b/README.md
@@ -60,4 +60,7 @@ Show progress of manga in the history tab (current chapter out of total chapters
Animate page navigation.\
Properly format text in items. For example for 4chan. The size of the item should also change.\
Show list of replies to a comment (for image boards).\
-Wrap text that is too long. \ No newline at end of file
+Wrap text that is too long.\
+Add greentext support for quotes.\
+Add support for special formatting for posts by admins on imageboards.\
+For image boards, track (You)'s and show notification when somebody replies to your post. \ No newline at end of file
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);
}
}