aboutsummaryrefslogtreecommitdiff
path: root/include/Body.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-04 19:22:04 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-04 19:22:04 +0200
commit59e4ce5c35e7e5a73d61e7111e8d4f07d63b7056 (patch)
treea8465d03cc8e6de2999c2fd22bbc83592e7ddd06 /include/Body.hpp
parent31efd6ba39036291955babd900c86a897c5cbd86 (diff)
Add grid view
Diffstat (limited to 'include/Body.hpp')
-rw-r--r--include/Body.hpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 4846b59..4007bc4 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -198,10 +198,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 scroll_page_if_large_item = false);
+ bool select_previous_item(bool scroll_page_if_large_item = false, bool ignore_columns = false);
// 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 scroll_page_if_large_item = false);
+ bool select_next_item(bool scroll_page_if_large_item = false, bool ignore_columns = false);
void set_selected_item(int item, bool reset_prev_selected_item = true);
void reset_prev_selected_item();
@@ -259,6 +259,9 @@ namespace QuickMedia {
void apply_search_filter_for_item(BodyItem *body_item);
+ bool can_move_left() const { return selected_column > 0; }
+ bool can_move_right() const { return selected_column + 1 < num_columns; }
+
BodyItems items;
bool draw_thumbnails;
// Set to {0, 0} to disable resizing
@@ -271,13 +274,17 @@ namespace QuickMedia {
bool title_mark_urls = false;
bool swiping_enabled = false;
bool show_drop_shadow = true;
+ bool card_view = false;
std::function<void()> on_top_reached = nullptr;
std::function<void()> on_bottom_reached = nullptr;
private:
void draw_drop_shadow(sf::RenderWindow &window);
void filter_search_fuzzy_item(const std::string &text, BodyItem *body_item);
- void handle_item_render(BodyItem *item, const sf::Vector2f pos, const sf::Vector2f size, const float item_height, int item_index);
+ 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);
+ 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 update_dirty_state(BodyItem *body_item, float width);
void clear_body_item_cache(BodyItem *body_item);
@@ -312,6 +319,7 @@ namespace QuickMedia {
double page_scroll = 0.0;
float selected_scrolled = 0.0f;
// TODO: Use a loading gif or something similar instead, to properly indicate the image is loading. Which could also have text that says "failed to load image" when image loading failed.
+ // TODO: Use rounded rectangle instead
sf::RectangleShape image_fallback;
//sf::RectangleShape item_separator;
sf::Sprite image;
@@ -336,6 +344,9 @@ namespace QuickMedia {
bool mouse_left_clicked = false;
bool has_scrolled_with_input = false;
bool click_counts = false;
+ int num_columns = 1;
+ int selected_column = 0;
+ bool card_view_enabled = true;
StuckDirection stuck_direction = StuckDirection::NONE;
sf::Vector2f mouse_click_pos;
sf::Vector2f mouse_release_pos;
@@ -354,10 +365,10 @@ namespace QuickMedia {
RoundedRectangle item_background;
RoundedRectangle reaction_background;
bool render_selected_item_bg = true;
- float item_background_prev_pos_y = 0.0f;
- float item_background_target_pos_y = 0.0f;
- float item_background_prev_height = 0.0f;
- float item_background_target_height = 0.0f;
+ sf::Vector2f item_background_prev_pos;
+ sf::Vector2f item_background_target_pos;
+ sf::Vector2f item_background_prev_size;
+ sf::Vector2f item_background_target_size;
TargetSetState target_y_set = TargetSetState::NOT_SET;
// TODO: Instead of using this, add functions for modifying |items| and apply the filter on those new items
DirtyState items_dirty = DirtyState::FALSE;