From 84d4d43d2f79da48c3494e11c8b29790fb6eae12 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 24 Mar 2021 08:42:40 +0100 Subject: Matrix: merge body items if same author --- include/Body.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Body.hpp b/include/Body.hpp index 53622e8..738c41b 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -160,6 +160,8 @@ namespace QuickMedia { using BodyItems = std::vector>; using BodyItemRenderCallback = std::function; + // Return true to merge + using BodyItemMergeHandler = std::function; enum class AttachSide { TOP, @@ -216,7 +218,7 @@ namespace QuickMedia { // 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); - float get_item_height(BodyItem *item, float width, bool load_texture = true, bool include_embedded_item = true); + float get_item_height(BodyItem *item, float width, bool load_texture = true, bool include_embedded_item = true, bool merge_with_previous = false); float get_spacing_y() const; static bool string_find_case_insensitive(const std::string &str, const std::string &substr); @@ -249,14 +251,17 @@ namespace QuickMedia { sf::Vector2i thumbnail_max_size; sf::Color line_separator_color; BodyItemRenderCallback body_item_render_callback; + BodyItemMergeHandler body_item_merge_handler; std::function body_item_select_callback; sf::Shader *thumbnail_mask_shader; AttachSide attach_side = AttachSide::TOP; private: - 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); + 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 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; + BodyItem* get_previous_visible_item(int start_index); + BodyItem* get_next_visible_item(int start_index); private: Program *program; std::unordered_map> item_thumbnail_textures; -- cgit v1.2.3