diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-06-30 02:25:10 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-06-30 16:55:20 +0200 |
commit | 07f80da8f9c46c228c272e95ab88a3e098c899d9 (patch) | |
tree | bef7b74826c1845911f0afcbf8611a2e8ad75e15 /include | |
parent | 82e66059dc09087b625e25027922a9e3c3ccc6cd (diff) |
Add infinite image scroll mode
Diffstat (limited to 'include')
-rw-r--r-- | include/ImageViewer.hpp | 63 | ||||
-rw-r--r-- | include/Page.hpp | 1 | ||||
-rw-r--r-- | include/QuickMedia.hpp | 1 |
3 files changed, 65 insertions, 0 deletions
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp new file mode 100644 index 0000000..fb1e5e3 --- /dev/null +++ b/include/ImageViewer.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include "Path.hpp" +#include <string> +#include <vector> +#include <SFML/Graphics/RenderWindow.hpp> +#include <SFML/Graphics/Texture.hpp> +#include <SFML/Graphics/Sprite.hpp> +#include <SFML/Graphics/Font.hpp> +#include <SFML/Graphics/Text.hpp> +#include <SFML/System/Clock.hpp> + +namespace QuickMedia { + class Manga; + + struct ImageData { + sf::Texture texture; + sf::Sprite sprite; + bool failed_to_load_image; + bool visible_on_screen; + }; + + struct PageSize { + sf::Vector2<double> size; + bool loaded; + }; + + class ImageViewer { + public: + ImageViewer(Manga *manga, const std::string &images_url, const std::string &chapter_title, int current_page, const Path &chapter_cache_dir, sf::Font *font); + bool draw(sf::RenderWindow &window); + // Returns page as 1 indexed + int get_focused_page() const; + int get_num_pages() const { return num_pages; } + private: + bool render_page(sf::RenderWindow &window, int page, double offset_y); + sf::Vector2<double> get_page_size(int page); + private: + int current_page; + int num_pages; + int page_center; + + std::string chapter_title; + Path chapter_cache_dir; + + double scroll = 0.0; + double scroll_speed = 0.0; + double min_page_center_dist; + int page_closest_to_center; + int focused_page; + int prev_focused_page = -1; + + sf::Font *font; + sf::Clock frame_timer; + sf::Text page_text; + + std::vector<std::unique_ptr<ImageData>> image_data; + std::vector<PageSize> page_size; + + sf::Vector2<double> window_size; + bool window_size_set = false; + }; +}
\ No newline at end of file diff --git a/include/Page.hpp b/include/Page.hpp index b615c8c..dc4051c 100644 --- a/include/Page.hpp +++ b/include/Page.hpp @@ -8,6 +8,7 @@ namespace QuickMedia { VIDEO_CONTENT, EPISODE_LIST, IMAGES, + IMAGES_CONTINUOUS, CONTENT_LIST, CONTENT_DETAILS, IMAGE_BOARD_THREAD_LIST, diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index 2e14b09..387a5a5 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -33,6 +33,7 @@ namespace QuickMedia { void video_content_page(); void episode_list_page(); void image_page(); + void image_continuous_page(); void content_list_page(); void content_details_page(); void image_board_thread_list_page(); |