aboutsummaryrefslogtreecommitdiff
path: root/include/QuickMedia.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-17 09:47:45 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-17 09:59:29 +0100
commit453eac7f1f5ef70390ec51087fc1f190811a7507 (patch)
tree21a32ef6de9a3d7c29562484104b56c12518a6f0 /include/QuickMedia.hpp
parentfc49d40c0d2f6edbbe9dde1f1b53d6a17e9d9f7d (diff)
Replace sfml with mgl
Diffstat (limited to 'include/QuickMedia.hpp')
-rw-r--r--include/QuickMedia.hpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index c19e1f6..d4166ec 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -9,16 +9,16 @@
#include "../plugins/FileManager.hpp"
#include <vector>
#include <memory>
-#include <SFML/Graphics/Font.hpp>
-#include <SFML/Graphics/RenderWindow.hpp>
-#include <SFML/Graphics/Shader.hpp>
+#include <mglpp/graphics/Font.hpp>
+#include <mglpp/graphics/Texture.hpp>
+#include <mglpp/window/Window.hpp>
+#include <mglpp/graphics/Shader.hpp>
#include <unordered_set>
#include <json/value.h>
#include <future>
#include <thread>
#include <stack>
#include <X11/Xlib.h>
-#include <X11/Xatom.h>
namespace QuickMedia {
class Matrix;
@@ -69,7 +69,7 @@ namespace QuickMedia {
bool fetching_next_page_failed = false;
bool search_suggestion_submitted = false;
int fetched_page = 0;
- sf::Text search_result_text;
+ mgl::Text search_result_text;
AsyncTask<FetchResult> fetch_future;
AsyncTask<BodyItems> next_page_future;
};
@@ -100,22 +100,24 @@ namespace QuickMedia {
void youtube_get_watch_history(BodyItems &history_items);
Json::Value load_video_history_json();
+
+ void set_clipboard(const std::string &str);
private:
void init(Window parent_window, std::string &program_path);
void load_plugin_by_name(std::vector<Tab> &tabs, int &start_tab_index, FileManagerMimeType fm_mime_type, FileSelectionHandler file_selection_handler, std::string instance);
- void common_event_handler(sf::Event &event);
+ void common_event_handler(mgl::Event &event);
void handle_x11_events();
- 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 base_event_handler(mgl::Event &event, PageType previous_page, Body *body, SearchBar *search_bar, bool handle_key_press = true, bool handle_searchbar = true);
+ void event_idle_handler(const mgl::Event &event);
void idle_active_handler();
void update_idle_state();
bool show_info_page(BodyItem *body_item, bool include_reverse_image_search);
bool toggle_bookmark(BodyItem *body_item, const char *bookmark_name);
- void page_loop_render(sf::RenderWindow &window, std::vector<Tab> &tabs, int selected_tab, TabAssociatedData &tab_associated_data, const Json::Value *json_chapters, Tabs &ui_tabs);
+ void page_loop_render(mgl::Window &window, std::vector<Tab> &tabs, int selected_tab, TabAssociatedData &tab_associated_data, const Json::Value *json_chapters, Tabs &ui_tabs);
using PageLoopSubmitHandler = std::function<void(const std::vector<Tab> &new_tabs)>;
// Returns false if the page loop was escaped by user navigation (pressing escape) or if there was an error at startup
bool page_loop(std::vector<Tab> &tabs, int start_tab_index = 0, PageLoopSubmitHandler after_submit_handler = nullptr, bool go_to_previous_on_escape = true);
- void video_page_download_video(const std::string &url, sf::WindowHandle video_player_window = None);
+ void video_page_download_video(const std::string &url, mgl::WindowHandle video_player_window = None);
bool video_download_if_non_streamable(std::string &video_url, std::string &audio_url, bool &is_audio_only, bool &has_embedded_audio, PageType previous_page);
int video_get_max_height();
void video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, Body *parent_body, int play_index, int *parent_body_page = nullptr, const std::string &parent_page_search = "");
@@ -137,7 +139,7 @@ namespace QuickMedia {
DOWNLOAD_IN_PROGRESS
};
- LoadImageResult load_image_by_index(int image_index, sf::Texture &image_texture, sf::String &error_message);
+ LoadImageResult load_image_by_index(int image_index, mgl::Texture &image_texture, std::string &error_message);
void download_chapter_images_if_needed(MangaImagesPage *images_page);
void select_episode(BodyItem *item, bool start_from_beginning);
@@ -151,16 +153,16 @@ namespace QuickMedia {
};
Display *disp;
- sf::RenderWindow window;
+ mgl::Window window;
Matrix *matrix = nullptr;
bool is_login_sync = false;
int monitor_hz;
- sf::Vector2f window_size;
+ mgl::vec2i window_size;
const char *plugin_name = nullptr;
- sf::Texture plugin_logo;
- sf::Texture loading_icon;
- sf::Sprite load_sprite;
- sf::Clock load_sprite_timer;
+ mgl::Texture plugin_logo;
+ mgl::Texture loading_icon;
+ mgl::Sprite load_sprite;
+ mgl::Clock load_sprite_timer;
PageType current_page;
std::stack<PageType> page_stack;
int image_index;
@@ -182,9 +184,9 @@ namespace QuickMedia {
int num_manga_pages = 0;
int exit_code = 0;
std::string resources_root;
- sf::Shader circle_mask_shader;
- sf::Shader rounded_rectangle_shader;
- sf::Shader rounded_rectangle_mask_shader;
+ mgl::Shader circle_mask_shader;
+ mgl::Shader rounded_rectangle_shader;
+ mgl::Shader rounded_rectangle_mask_shader;
bool no_video = false;
bool force_no_video = false;
UpscaleImageAction upscale_image_action = UpscaleImageAction::NO;
@@ -195,20 +197,16 @@ namespace QuickMedia {
RoomData *current_chat_room = nullptr;
bool go_to_previous_page = false;
bool running_task_with_loading_screen = false;
- sf::Text tab_text;
- sf::Vertex gradient_points[4];
- sf::Vector2f body_pos;
- sf::Vector2f body_size;
+ mgl::Vertex gradient_points[4];
+ mgl::vec2f body_pos;
+ mgl::vec2f body_size;
bool show_room_side_panel = true;
std::thread::id main_thread_id;
- sf::Clock idle_timer;
+ mgl::Clock idle_timer;
bool idle = true;
bool low_cpu_mode = false;
bool window_closed = false;
std::string pipe_selected_text;
- Window x11_window = None;
- Atom wm_delete_window_atom;
- Atom net_wm_ping_atom;
XEvent xev;
std::filesystem::path file_manager_start_dir;
std::string youtube_url;
@@ -216,4 +214,4 @@ namespace QuickMedia {
bool use_youtube_dl = false;
int video_max_height = 0;
};
-} \ No newline at end of file
+}