aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Body.cpp18
-rw-r--r--src/StringUtils.cpp1
2 files changed, 16 insertions, 3 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 3f8691a..2700288 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -1564,6 +1564,7 @@ namespace QuickMedia {
bool thumbnail_drawn = false;
{
float image_height = 0.0f;
+ float image_offset_x = 999999.0f;
if(item_thumbnail && item_thumbnail->loading_state == LoadingState::APPLIED_TO_TEXTURE && item_thumbnail->texture.is_valid()) {
image.set_texture(&item_thumbnail->texture);
auto image_size = image.get_texture()->get_size();
@@ -1586,6 +1587,7 @@ namespace QuickMedia {
}
thumbnail_drawn = true;
+ image_offset_x = image.get_position().x - (pos.x + pos_offset.x);
} else if(!item->thumbnail_url.empty()) {
mgl::vec2f content_size = thumbnail_size.to_vec2f();
image_fallback.set_size(content_size);
@@ -1602,7 +1604,9 @@ namespace QuickMedia {
loading_icon.set_rotation(elapsed_time_sec * 400.0);
window.draw(loading_icon);
}
+
image_height = content_size.y;
+ image_offset_x = image_fallback.get_position().x - (pos.x + pos_offset.x);
}
if(item->extra) {
@@ -1628,22 +1632,30 @@ namespace QuickMedia {
mgl::View new_view = { mgl::vec2i(0, std::max(text_pos.y, scissor_y)), mgl::vec2i(window_size.x, underflow_height) };
window.set_view(new_view);
+ float min_text_offset = image_offset_x - card_padding_x;
+ if(item->author_text)
+ min_text_offset = std::min(min_text_offset, item->author_text->getMaxWidth() * 0.5f - item->author_text->getWidth() * 0.5f);
+ if(item->title_text)
+ min_text_offset = std::min(min_text_offset, item->title_text->getMaxWidth() * 0.5f - item->title_text->getWidth() * 0.5f);
+ if(item->description_text)
+ min_text_offset = std::min(min_text_offset, item->description_text->getMaxWidth() * 0.5f - item->description_text->getWidth() * 0.5f);
+
text_pos.y = std::min(0.0f, underflow_text);
float text_offset_y = 0.0f;
if(item->author_text) {
- item->author_text->set_position(text_pos);
+ item->author_text->set_position(text_pos + mgl::vec2f(min_text_offset, 0.0f).floor());
item->author_text->draw(window);
text_offset_y += item->author_text->getHeight() + std::floor(3.0f * get_config().scale);
}
if(item->title_text) {
- item->title_text->set_position(text_pos + mgl::vec2f(0.0f, text_offset_y));
+ item->title_text->set_position(text_pos + mgl::vec2f(min_text_offset, text_offset_y).floor());
item->title_text->draw(window);
text_offset_y += item->title_text->getHeight() + std::floor(3.0f * get_config().scale);
}
if(item->description_text) {
- item->description_text->set_position(text_pos + mgl::vec2f(0.0f, text_offset_y));
+ item->description_text->set_position(text_pos + mgl::vec2f(min_text_offset, text_offset_y).floor());
item->description_text->draw(window);
text_offset_y += item->description_text->getHeight() + std::floor(3.0f * get_config().scale);
}
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 57c30d4..5505a32 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -151,6 +151,7 @@ namespace QuickMedia {
// TODO: Support utf-8 case insensitive find
bool string_find_fuzzy_case_insensitive(const std::string &str, const std::string &substr) {
if(substr.empty()) return true;
+ if(str.empty()) return false;
size_t str_index = 0;
bool full_match = true;