From c207201a4a5a47e4ad286ba7371e4176c8ed5056 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 19 Mar 2021 12:22:25 +0100 Subject: Start on touch support, add support for ui scaling, revert back to old get_message_by_id method for matrix to support loading user display names in replies --- include/Body.hpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'include/Body.hpp') diff --git a/include/Body.hpp b/include/Body.hpp index 1664696..ac5853d 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -14,6 +14,7 @@ namespace sf { class RenderWindow; class Shader; class Texture; + class Event; } namespace QuickMedia { @@ -94,13 +95,7 @@ namespace QuickMedia { dirty_author = true; } - void add_reaction(std::string text, void *userdata) { - sf::String str = sf::String::fromUtf8(text.begin(), text.end()); - Reaction reaction; - reaction.text = std::make_unique(std::move(str), false, 14, 0.0f); - reaction.userdata = userdata; - reactions.push_back(std::move(reaction)); - } + void add_reaction(std::string text, void *userdata); // Returns true if reaction is found bool remove_reaction_by_userdata(void *userdata) { @@ -209,6 +204,9 @@ namespace QuickMedia { BodyItem* get_last_fully_visible_item(); void clamp_selection(); + + // Returns true if the event was handled + bool on_event(const sf::RenderWindow &window, const sf::Event &event); void draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size); void draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, const Json::Value &content_progress); // |size| is the clip size, another outside this will be cut off. @@ -263,7 +261,7 @@ namespace QuickMedia { std::unordered_map> item_thumbnail_textures; int selected_item; int prev_selected_item; - float page_scroll; + double page_scroll; // 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. sf::RectangleShape image_fallback; sf::RectangleShape item_separator; @@ -272,13 +270,24 @@ namespace QuickMedia { sf::Sprite loading_icon; int num_visible_items; bool last_item_fully_visible; + int first_fully_visible_item; int last_fully_visible_item; sf::Clock draw_timer; + sf::Clock frame_timer; 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; + bool mouse_state_set = false; + bool mouse_left_pressed = false; + sf::Vector2f mouse_pos; + sf::Vector2f prev_mouse_pos; + sf::Vector2i mouse_pos_raw; + sf::Vector2f mouse_scroll_accel; + float selected_item_height = 0.0f; + float selected_scrolled = 0.0f; + //float scroll_y = 0.0f; }; } \ No newline at end of file -- cgit v1.2.3