aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-03-19 12:22:25 +0100
committerdec05eba <dec05eba@protonmail.com>2021-03-19 12:22:25 +0100
commitc207201a4a5a47e4ad286ba7371e4176c8ed5056 (patch)
tree253b84dae998a7506042ef924caf8beb498c6ba9 /include
parent5f022066684f8ed6c4b827fabf8554d8730add2f (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/Body.hpp25
-rw-r--r--include/QuickMedia.hpp1
-rw-r--r--include/Utils.hpp5
3 files changed, 23 insertions, 8 deletions
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<Text>(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<std::string, std::shared_ptr<ThumbnailData>> 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
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 4142a27..21b451d 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -96,6 +96,7 @@ namespace QuickMedia {
private:
void base_event_handler(sf::Event &event, PageType previous_page, Body *body, SearchBar *search_bar, bool handle_key_press = true, bool handle_searchbar = true);
void event_idle_handler(const sf::Event &event);
+ void idle_active_handler();
void update_idle_state();
void page_loop_render(sf::RenderWindow &window, std::vector<Tab> &tabs, int selected_tab, TabAssociatedData &tab_associated_data, const Json::Value *json_chapters);
using PageLoopSubmitHandler = std::function<void(const std::vector<Tab> &new_tabs)>;
diff --git a/include/Utils.hpp b/include/Utils.hpp
new file mode 100644
index 0000000..7ca409c
--- /dev/null
+++ b/include/Utils.hpp
@@ -0,0 +1,5 @@
+#pragma once
+
+namespace QuickMedia {
+ float get_ui_scale();
+} \ No newline at end of file