aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Body.hpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index da54ee5..43fdf22 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -179,7 +179,7 @@ namespace QuickMedia {
};
using BodyItems = std::vector<std::shared_ptr<BodyItem>>;
- using BodyItemRenderCallback = std::function<void(BodyItem *body_item)>;
+ using BodyItemRenderCallback = std::function<void(std::shared_ptr<BodyItem> &body_item)>;
// Return true to merge
using BodyItemMergeHandler = std::function<bool(BodyItem *prev_item, BodyItem *this_item)>;
@@ -236,7 +236,7 @@ namespace QuickMedia {
// This happens because of |draw| sets thumbnails as unreferenced at the beginning and cleans them up at the end if they are not drawn in the same function call.
// TODO: Right now drawing an item that also exists in the body will cause the text to update geometry every frame if the text is wrapping text and the items are drawn at different sizes,
// because of Text::setMaxWidth
- void draw_item(sf::RenderWindow &window, BodyItem *item, sf::Vector2f pos, sf::Vector2f size, bool include_embedded_item = true, bool is_embedded = false);
+ void draw_item(sf::RenderWindow &window, std::shared_ptr<BodyItem> &item, sf::Vector2f pos, sf::Vector2f size, bool include_embedded_item = true, bool is_embedded = false);
float get_item_height(BodyItem *item, float width, bool load_texture = true, bool include_embedded_item = true, bool merge_with_previous = false, int item_index = -1);
@@ -264,6 +264,7 @@ namespace QuickMedia {
bool can_move_left() const { return selected_column > 0; }
bool can_move_right() const { return selected_column + 1 < num_columns; }
+ // TODO: Prevent items from being removed when render is in progress. That would invalidate references and cause a crash
BodyItems items;
bool draw_thumbnails;
// Set to {0, 0} to disable resizing
@@ -287,7 +288,7 @@ namespace QuickMedia {
// Returns the the body total drawn height
float draw_list_view(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, const int prev_num_visible_items, const Json::Value &content_progress);
void draw_card_view(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, sf::Vector2u window_size, float scissor_y);
- void draw_item(sf::RenderWindow &window, BodyItem *item, const sf::Vector2f &pos, const sf::Vector2f &size, const float item_height, const int item_index, const Json::Value &content_progress, bool include_embedded_item = true, bool merge_with_previous = false);
+ void draw_item(sf::RenderWindow &window, std::shared_ptr<BodyItem> &item, const sf::Vector2f &pos, const sf::Vector2f &size, const float item_height, const int item_index, const Json::Value &content_progress, bool include_embedded_item = true, bool merge_with_previous = false);
void update_dirty_state(BodyItem *body_item, float width);
void clear_body_item_cache(BodyItem *body_item);
sf::Vector2i get_item_thumbnail_size(BodyItem *item) const;