aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Body.hpp3
-rw-r--r--src/Body.cpp20
-rw-r--r--src/QuickMedia.cpp2
-rw-r--r--src/Text.cpp2
4 files changed, 16 insertions, 11 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 841ba5a..da54ee5 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -53,7 +53,8 @@ namespace QuickMedia {
class BodyItem {
public:
BodyItem(std::string _title);
- BodyItem& operator=(BodyItem &other);
+ BodyItem(const BodyItem&) = delete;
+ BodyItem& operator=(const BodyItem &other);
static std::shared_ptr<BodyItem> create(std::string title) { return std::make_shared<BodyItem>(std::move(title)); }
diff --git a/src/Body.cpp b/src/Body.cpp
index fcdc850..b11cb51 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -39,6 +39,7 @@ static const int card_padding_y = 20 * QuickMedia::get_ui_scale();
static const int card_image_text_padding = 10 * QuickMedia::get_ui_scale();
static const sf::Vector2i card_max_image_size(card_width - card_padding_x * 2, (card_height - card_padding_y * 2) / 2);
static const int num_columns_switch_to_list = 1;
+static const int embedded_item_border_width = 4;
static BodySpacing body_spacing[2];
static bool themes_initialized = false;
@@ -108,7 +109,7 @@ namespace QuickMedia {
set_title(std::move(_title));
}
- BodyItem& BodyItem::operator=(BodyItem &other) {
+ BodyItem& BodyItem::operator=(const BodyItem &other) {
url = other.url;
thumbnail_url = other.thumbnail_url;
visible = other.visible;
@@ -1160,6 +1161,9 @@ namespace QuickMedia {
}
if(item->visible && pos_offset.y + item_height > -body_spacing[body_theme].body_padding_vertical && pos_offset.y < size.y) {
+ if(body_item_render_callback)
+ body_item_render_callback(item);
+
sf::Vector2i thumbnail_size = get_item_thumbnail_size(item);
std::shared_ptr<ThumbnailData> item_thumbnail;
if(draw_thumbnails && !item->thumbnail_url.empty())
@@ -1381,7 +1385,7 @@ namespace QuickMedia {
text_offset_x += body_spacing[body_theme].image_padding_x + item->loaded_image_size.x;
}
} else if(item->thumbnail_size.x > 0) {
- text_offset_x += body_spacing[body_theme].image_padding_x + thumbnail_size.x;
+ text_offset_x += body_spacing[body_theme].image_padding_x + item->loaded_image_size.x;
}
const float text_offset_y = std::floor(6.0f * get_ui_scale());
@@ -1408,21 +1412,20 @@ namespace QuickMedia {
}
if(include_embedded_item && item->embedded_item_status != FetchStatus::NONE) {
- const float border_width = 4.0f;
- const float embedded_item_width = std::floor(size.x - text_offset_x - border_width - body_spacing[body_theme].padding_x);
+ const float embedded_item_width = std::floor(size.x - text_offset_x - embedded_item_border_width - body_spacing[body_theme].padding_x);
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(border_width, std::floor(embedded_item_height)));
+ sf::RectangleShape border_left(sf::Vector2f(embedded_item_border_width, std::floor(embedded_item_height)));
border_left.setFillColor(get_current_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));
window.draw(border_left);
if(item->embedded_item) {
- sf::Vector2f embedded_item_pos(std::floor(item_pos.x + text_offset_x + border_width + body_spacing[body_theme].padding_x), std::floor(item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 6.0f));
+ sf::Vector2f embedded_item_pos(std::floor(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x), std::floor(item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 6.0f));
sf::Vector2f embedded_item_size(embedded_item_width, embedded_item_height);
draw_item(window, item->embedded_item.get(), 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 + 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(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));
window.draw(embedded_item_load_text);
}
item_pos.y += embedded_item_height + 4.0f;
@@ -1543,8 +1546,9 @@ namespace QuickMedia {
has_loaded_text = true;
}
if(include_embedded_item && item->embedded_item_status != FetchStatus::NONE) {
+ const float embedded_item_width = std::floor(width - text_offset_x - embedded_item_border_width - body_spacing[body_theme].padding_x);
if(item->embedded_item)
- item_height += (get_item_height(item->embedded_item.get(), width, load_texture, false) + 6.0f + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
+ item_height += (get_item_height(item->embedded_item.get(), embedded_item_width, load_texture, false) + 6.0f + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
else
item_height += ((body_spacing[body_theme].embedded_item_font_size + 5.0f) + 6.0f + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index e21e591..ba97794 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -4776,7 +4776,7 @@ namespace QuickMedia {
delete (PinnedEventData*)prev_body_item->userdata;
}
- if(empty_before)
+ if(empty_before || ui_tabs.get_selected() != PINNED_TAB_INDEX)
tabs[PINNED_TAB_INDEX].body->select_last_item();
else
tabs[PINNED_TAB_INDEX].body->set_selected_item(selected_before);
diff --git a/src/Text.cpp b/src/Text.cpp
index 3cde45f..3ebd303 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -425,7 +425,7 @@ namespace QuickMedia
int vertexStart = vertices[vertices_index].getVertexCount();
EmojiRectangle emoji_rec = emoji_get_extents(codePoint);
- const float font_height_offset = -latin_font_height * 1.2f;
+ const float font_height_offset = std::floor(-latin_font_height * 1.2f);
sf::Vector2f vertexTopLeft(glyphPos.x, glyphPos.y + font_height_offset - std::floor(emoji_rec.height * get_ui_scale()) * 0.5f);
sf::Vector2f vertexTopRight(glyphPos.x + std::floor(emoji_rec.width * get_ui_scale()), glyphPos.y + font_height_offset - std::floor(emoji_rec.height * get_ui_scale()) * 0.5f);
sf::Vector2f vertexBottomLeft(glyphPos.x, glyphPos.y + font_height_offset + emoji_rec.height * get_ui_scale() * 0.5f);