aboutsummaryrefslogtreecommitdiff
path: root/src/Body.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Body.cpp')
-rw-r--r--src/Body.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index da7152d..6081028 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -133,7 +133,6 @@ namespace QuickMedia {
// TODO: Load thumbnails with more than one thread.
// TODO: Show chapters (rows) that have been read differently to make it easier to see what hasn't been read yet.
void Body::draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, const Json::Value &content_progress) {
- const float font_height = title_text.getCharacterSize() + title_text.getLineSpacing() + 4.0f;
const float image_max_height = 100.0f;
const float spacing_y = 15.0f;
const float padding_x = 10.0f;
@@ -155,7 +154,6 @@ namespace QuickMedia {
sf::RectangleShape selected_border;
selected_border.setFillColor(sf::Color(0, 85, 119));
- const float selected_border_width = 5.0f;
int num_items = items.size();
if(num_items == 0)
@@ -169,6 +167,15 @@ namespace QuickMedia {
for(auto &body_item : items) {
// Intentionally create the item with the key item->thumbnail_url if it doesn't exist
item_thumbnail_textures[body_item->thumbnail_url].referenced = true;
+
+ if(body_item->dirty) {
+ body_item->dirty = false;
+ if(body_item->title_text)
+ body_item->title_text->setString(body_item->title);
+ else
+ body_item->title_text = std::make_unique<Text>(body_item->title, title_text.getFont(), 14, size.x - 50 - image_padding_x * 2.0f);
+ //body_item->title_text->updateGeometry();
+ }
}
// Find the starting row that can be drawn to make selected row visible as well
@@ -178,7 +185,7 @@ namespace QuickMedia {
for(; first_visible_item >= 0; --first_visible_item) {
auto &item = items[first_visible_item];
if(item->visible) {
- float item_height = font_height * item->num_lines;
+ float item_height = item->title_text->getHeight();
if(!item->author.empty()) {
item_height += author_text.getCharacterSize() + 2.0f;
}
@@ -212,7 +219,7 @@ namespace QuickMedia {
if(!item->visible)
continue;
- float item_height = font_height * item->num_lines;
+ float item_height = item->title_text->getHeight();
if(!item->author.empty()) {
item_height += author_text.getCharacterSize() + 2.0f;
}
@@ -297,9 +304,13 @@ 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), std::floor(item_pos.y + padding_y));
- window.draw(title_text);
+ //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);
+ item->title_text->setString(item->title);
+ item->title_text->setPosition(std::floor(item_pos.x + text_offset_x), std::floor(item_pos.y + padding_y - 4.0f));
+ item->title_text->setMaxWidth(size.x - text_offset_x - image_padding_x * 2.0f);
+ item->title_text->draw(window);
// TODO: Do the same for non-manga content
const Json::Value &item_progress = content_progress[item->title];