aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-18 17:03:11 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-18 17:03:11 +0200
commit63774155016ad581dcf418c94cd2ec84fcf86445 (patch)
treece4a9939d2555dce80792a06d1361b9f5d8b8ec0 /include
parent86d23983d8c9cd75af9c40f038f6b9a1f0b5fbb5 (diff)
Render selected item background as a rectangle on top instead of banding
Limit selected item background position to body content position and size
Diffstat (limited to 'include')
-rw-r--r--include/Body.hpp18
-rw-r--r--include/RoundedRectangle.hpp5
2 files changed, 17 insertions, 6 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 65645e9..91913b5 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -17,6 +17,7 @@ namespace Json {
}
namespace QuickMedia {
+ class ThumbnailData;
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)>;
@@ -154,9 +155,10 @@ namespace QuickMedia {
void filter_search_fuzzy_item(const std::string &text, BodyItem *body_item);
void handle_item_render(const sf::Vector2f pos, const float item_width, const float item_height, int item_index);
// 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);
+ float draw_list_view(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, 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, 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 draw_card_item(sf::RenderWindow &window, std::shared_ptr<BodyItem> &item, const sf::Vector2f &pos, const sf::Vector2f &pos_offset, const sf::Vector2f &body_size, const sf::Vector2f &window_size, float item_height, float scissor_y, int item_index, ThumbnailData *item_thumbnail);
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;
@@ -183,11 +185,25 @@ namespace QuickMedia {
BOTTOM
};
+ struct RenderItem {
+ std::shared_ptr<BodyItem> body_item;
+ sf::Vector2f pos;
+ sf::Vector2f pos_offset;
+ sf::Vector2f size;
+ float item_height;
+ int item_index;
+ bool merge_with_previous;
+ std::shared_ptr<ThumbnailData> item_thumbnail;
+ };
+
// TODO: Prevent items from being removed when render is in progress. That would invalidate references and cause a crash
BodyItems items;
BodyTheme body_theme;
+ // Items that are rendered in the current frame
+ std::vector<RenderItem> render_items;
+
int selected_item;
int prev_selected_item;
double page_scroll = 0.0;
diff --git a/include/RoundedRectangle.hpp b/include/RoundedRectangle.hpp
index 2106634..96e57fd 100644
--- a/include/RoundedRectangle.hpp
+++ b/include/RoundedRectangle.hpp
@@ -17,8 +17,6 @@ namespace QuickMedia {
void set_color(sf::Color color);
sf::Vector2f get_position() const;
sf::Vector2f get_size() const;
- void set_band(sf::Vector2f pos, sf::Vector2f size);
- void set_band_color(sf::Color color);
void draw(sf::RenderTarget &target);
private:
float radius;
@@ -26,8 +24,5 @@ namespace QuickMedia {
sf::Vector2f size;
sf::Vertex vertices[4];
sf::Shader *rounded_rectangle_shader;
- sf::Vector2f band_pos;
- sf::Vector2f band_size;
- sf::Color band_color;
};
} \ No newline at end of file