From dd3da1832c0103a2da35df8ac2483461311bdf25 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 10 Nov 2020 21:13:02 +0100 Subject: Scroll body automatically to reveal more items when making the window larger, even after resizing to smaller size before --- include/Body.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Body.hpp b/include/Body.hpp index 1fa32bb..1952b74 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -136,6 +136,11 @@ namespace QuickMedia { using BodyItems = std::vector>; using BodyItemRenderCallback = std::function; + enum class AttachSide { + TOP, + BOTTOM + }; + class Body { public: Body(Program *program, sf::Texture &loading_icon_texture); @@ -146,10 +151,10 @@ namespace QuickMedia { bool select_next_page(); // Select previous item, ignoring invisible items. Returns true if the item was changed or if the item scrolled. This can be used to check if the top was hit when wrap_around is set to false - bool select_previous_item(); + bool select_previous_item(bool scroll_page_if_large_item = true); // Select next item, ignoring invisible items. Returns true if the item was changed or if the item scrolled. This can be used to check if the bottom was hit when wrap_around is set to false - bool select_next_item(); + bool select_next_item(bool scroll_page_if_large_item = true); void set_selected_item(int item, bool reset_prev_selected_item = true); // Returns -1 if item can't be found @@ -213,6 +218,7 @@ namespace QuickMedia { sf::Color line_separator_color; BodyItemRenderCallback body_item_render_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 update_dirty_state(BodyItem *body_item, float width); @@ -238,5 +244,8 @@ namespace QuickMedia { double elapsed_time_sec = 0.0; bool selected_line_top_visible = true; bool selected_line_bottom_visible = true; + bool items_cut_off = false; + float offset_to_top = 0.0f; + float offset_to_bottom = 0.0f; }; } \ No newline at end of file -- cgit v1.2.3