aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/AsyncImageLoader.hpp23
-rw-r--r--include/Body.hpp91
-rw-r--r--include/BodyItem.hpp32
-rw-r--r--include/Entry.hpp24
-rw-r--r--include/ImageViewer.hpp43
-rw-r--r--include/NetUtils.hpp1
-rw-r--r--include/QuickMedia.hpp56
-rw-r--r--include/ResourceLoader.hpp8
-rw-r--r--include/RoundedRectangle.hpp31
-rw-r--r--include/Scale.hpp38
-rw-r--r--include/SearchBar.hpp43
-rw-r--r--include/SfmlFixes.hpp11
-rw-r--r--include/Tabs.hpp27
-rw-r--r--include/Text.hpp84
-rw-r--r--include/Theme.hpp46
-rw-r--r--include/Utils.hpp4
-rw-r--r--include/VideoPlayer.hpp16
-rw-r--r--include/gui/Button.hpp24
18 files changed, 296 insertions, 306 deletions
diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp
index 7556fbc..856e9cc 100644
--- a/include/AsyncImageLoader.hpp
+++ b/include/AsyncImageLoader.hpp
@@ -4,9 +4,10 @@
#include "../include/MessageQueue.hpp"
#include "../include/FileAnalyzer.hpp"
#include "../include/AsyncTask.hpp"
-#include <SFML/System/Vector2.hpp>
-#include <SFML/Graphics/Texture.hpp>
-#include <SFML/System/Clock.hpp>
+#include <mglpp/system/vec.hpp>
+#include <mglpp/graphics/Texture.hpp>
+#include <mglpp/graphics/Image.hpp>
+#include <mglpp/system/Clock.hpp>
#include <string>
#include <memory>
#include <unordered_map>
@@ -22,8 +23,8 @@ namespace QuickMedia {
struct ThumbnailData {
LoadingState loading_state = LoadingState::NOT_LOADED;
- sf::Texture texture;
- std::unique_ptr<sf::Image> image; // Set in another thread. This should be .reset after loading it into |texture|, to save memory
+ mgl::Texture texture;
+ std::unique_ptr<mgl::Image> image; // Set in another thread. This should be .reset after loading it into |texture|, to save memory
size_t counter = 0;
Path thumbnail_path;
};
@@ -33,12 +34,12 @@ namespace QuickMedia {
Path thumbnail_path;
bool local;
std::shared_ptr<ThumbnailData> thumbnail_data;
- sf::Vector2i resize_target_size;
+ mgl::vec2i resize_target_size;
};
// If |symlink_if_no_resize| is false then a copy is made from |thumbnail_path| to |thumbnail_path_resized| instead of a symlink if |thumbnail_path| is not larger than |resize_target_size|.
// One example of why you might not want a symlink is if |thumbnail_path| is a temporary file.
- bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, sf::Vector2i resize_target_size, ContentType content_type, bool symlink_if_no_resize);
+ bool create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, mgl::vec2i resize_target_size, ContentType content_type, bool symlink_if_no_resize);
constexpr int NUM_IMAGE_LOAD_PARALLEL = 4;
@@ -50,7 +51,7 @@ namespace QuickMedia {
// This function should be called every frame for the objects that need to display this thumbnail, otherwise it can be unloaded.
// set |resize_target_size| to {0, 0} to disable resizing.
// Note: this method is not thread-safe
- std::shared_ptr<ThumbnailData> get_thumbnail(const std::string &url, bool local, sf::Vector2i resize_target_size);
+ std::shared_ptr<ThumbnailData> get_thumbnail(const std::string &url, bool local, mgl::vec2i resize_target_size);
// Note: this should only be called once every frame.
// Note: this method is not thread-safe
@@ -61,7 +62,7 @@ namespace QuickMedia {
int64_t download_start = 0;
Path thumbnail_path;
std::shared_ptr<ThumbnailData> thumbnail_data;
- sf::Vector2i resize_target_size;
+ mgl::vec2i resize_target_size;
std::string url;
};
@@ -72,12 +73,12 @@ namespace QuickMedia {
// set |resize_target_size| to {0, 0} to disable resizing.
// Note: this method is not thread-safe
- bool load_thumbnail(const std::string &url, bool local, sf::Vector2i resize_target_size, std::shared_ptr<ThumbnailData> thumbnail_data, Path &thumbnail_path);
+ bool load_thumbnail(const std::string &url, bool local, mgl::vec2i resize_target_size, std::shared_ptr<ThumbnailData> thumbnail_data, Path &thumbnail_path);
// Returns -1 if all threads are busy
int get_free_load_index() const;
- void load_create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, ThumbnailData *thumbnail_data, sf::Vector2i resize_target_size);
+ void load_create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, ThumbnailData *thumbnail_data, mgl::vec2i resize_target_size);
void process_thumbnail(ThumbnailLoadData &thumbnail_load_data);
private:
void reset_download(Download &download);
diff --git a/include/Body.hpp b/include/Body.hpp
index d4eb49f..45749ce 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -2,11 +2,12 @@
#include "BodyItem.hpp"
#include "RoundedRectangle.hpp"
-#include <SFML/Graphics/RectangleShape.hpp>
-#include <SFML/Graphics/Sprite.hpp>
+#include <mglpp/graphics/Rectangle.hpp>
+#include <mglpp/graphics/Sprite.hpp>
+#include <functional>
-namespace sf {
- class RenderWindow;
+namespace mgl {
+ class Window;
class Shader;
class Texture;
class Event;
@@ -17,6 +18,8 @@ namespace Json {
}
namespace QuickMedia {
+ void init_body_themes();
+
class ThumbnailData;
using BodyItemRenderCallback = std::function<void(std::shared_ptr<BodyItem> &body_item)>;
// Return true to merge
@@ -41,7 +44,7 @@ namespace QuickMedia {
class Body {
public:
- Body(BodyTheme body_theme, sf::Texture &loading_icon_texture, sf::Shader *rounded_rectangle_shader, sf::Shader *rounded_rectangle_mask_shader);
+ Body(BodyTheme body_theme, mgl::Texture &loading_icon_texture, mgl::Shader *rounded_rectangle_shader, mgl::Shader *rounded_rectangle_mask_shader);
~Body();
// Select previous page, ignoring invisible items. Returns true if the item was changed. This can be used to check if the top was hit when wrap_around is set to false
@@ -102,17 +105,17 @@ namespace QuickMedia {
void clamp_selection();
// Returns true if the event was handled
- bool on_event(const sf::RenderWindow &window, const sf::Event &event, bool keyboard_navigation = true);
+ bool on_event(const mgl::Window &window, const mgl::Event &event, bool keyboard_navigation = true);
// Returns the the body total height
- double draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size);
+ double draw(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size);
// Returns the the body total height
- double draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, const Json::Value &content_progress);
+ double draw(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, const Json::Value &content_progress);
// |size| is the clip size, another outside this will be cut off.
// Note: this should be called after |draw|, or thumbnails will be messed up. TODO: find a way to solve this issue in a clean way.
// This happens because of |draw| sets thumbnails as unreferenced at the beginning and cleans them up at the end if they are not drawn in the same function call.
// TODO: Right now drawing an item that also exists in the body will cause the text to update geometry every frame if the text is wrapping text and the items are drawn at different sizes,
// because of Text::setMaxWidth
- void draw_item(sf::RenderWindow &window, std::shared_ptr<BodyItem> &item, sf::Vector2f pos, sf::Vector2f size, bool include_embedded_item = true, bool is_embedded = false);
+ void draw_item(mgl::Window &window, std::shared_ptr<BodyItem> &item, mgl::vec2f pos, mgl::vec2f size, bool include_embedded_item = true, bool is_embedded = false);
float get_item_height(BodyItem *item, float width, bool load_texture = true, bool include_embedded_item = true, bool merge_with_previous = false, int item_index = -1);
@@ -137,11 +140,11 @@ namespace QuickMedia {
bool draw_thumbnails;
// Set to {0, 0} to disable resizing
- sf::Vector2i thumbnail_max_size;
+ mgl::vec2i thumbnail_max_size;
BodyItemRenderCallback body_item_render_callback;
BodyItemMergeHandler body_item_merge_handler;
std::function<void(BodyItem*)> body_item_select_callback;
- sf::Shader *thumbnail_mask_shader;
+ mgl::Shader *thumbnail_mask_shader;
AttachSide attach_side = AttachSide::TOP;
bool title_mark_urls = false;
bool swiping_enabled = false;
@@ -151,18 +154,18 @@ namespace QuickMedia {
std::function<void()> on_top_reached = nullptr;
std::function<void()> on_bottom_reached = nullptr;
private:
- void draw_drop_shadow(sf::RenderWindow &window);
+ void draw_drop_shadow(mgl::Window &window);
void filter_search_fuzzy_item(const std::string &text, BodyItem *body_item);
- void handle_item_render(const sf::Vector2f pos, const float item_width, const float item_height, int item_index);
+ void handle_item_render(const mgl::vec2f pos, const float item_width, const float item_height, int item_index);
// Returns the the body total height
- double draw_list_view(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, const Json::Value &content_progress);
+ double draw_list_view(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, const Json::Value &content_progress);
// Returns the the body total height
- double 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, std::shared_ptr<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 draw_card_item(sf::RenderWindow &window, std::shared_ptr<BodyItem> &item, const sf::Vector2f &pos, const sf::Vector2f &pos_offset, const sf::Vector2f &body_size, const sf::Vector2f &window_size, float item_height, float scissor_y, int item_index, ThumbnailData *item_thumbnail);
+ double draw_card_view(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, mgl::vec2i window_size, float scissor_y, bool &switched_to_list_view);
+ void draw_item(mgl::Window &window, std::shared_ptr<BodyItem> &item, const mgl::vec2f &pos, const mgl::vec2f &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 draw_card_item(mgl::Window &window, std::shared_ptr<BodyItem> &item, const mgl::vec2f &pos, const mgl::vec2f &pos_offset, const mgl::vec2f &body_size, const mgl::vec2f &window_size, float item_height, float scissor_y, int item_index, ThumbnailData *item_thumbnail);
void update_dirty_state(BodyItem *body_item, float width);
void clear_body_item_cache(BodyItem *body_item);
- sf::Vector2i get_item_thumbnail_size(BodyItem *item) const;
+ mgl::vec2i get_item_thumbnail_size(BodyItem *item) const;
// Returns -1 if not found
int get_previous_visible_item(int start_index);
@@ -189,9 +192,9 @@ namespace QuickMedia {
struct RenderItem {
std::shared_ptr<BodyItem> body_item;
- sf::Vector2f pos;
- sf::Vector2f pos_offset;
- sf::Vector2f size;
+ mgl::vec2f pos;
+ mgl::vec2f pos_offset;
+ mgl::vec2f size;
float item_height;
int item_index;
bool merge_with_previous;
@@ -212,14 +215,14 @@ namespace QuickMedia {
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;
- sf::Sprite loading_icon;
+ mgl::Rectangle image_fallback;
+ //mgl::Rectangle item_separator;
+ mgl::Sprite image;
+ mgl::Sprite loading_icon;
- sf::Text progress_text;
- sf::Text replies_text;
- sf::Text embedded_item_load_text;
+ mgl::Text progress_text;
+ mgl::Text replies_text;
+ mgl::Text embedded_item_load_text;
bool body_size_changed = false;
@@ -228,8 +231,8 @@ namespace QuickMedia {
bool bottom_cut_off;
int first_visible_item = -1;
int last_visible_item = -1;
- sf::Clock draw_timer;
- sf::Clock frame_timer;
+ mgl::Clock draw_timer;
+ mgl::Clock frame_timer;
double elapsed_time_sec = 0.0;
bool selected_line_top_visible = true;
bool selected_line_bottom_visible = true;
@@ -242,15 +245,15 @@ namespace QuickMedia {
int selected_column = 0;
bool card_view_enabled = true;
StuckDirection stuck_direction = StuckDirection::NONE;
- sf::Vector2f mouse_click_pos;
- sf::Vector2f mouse_release_pos;
+ mgl::vec2f mouse_click_pos;
+ mgl::vec2f mouse_release_pos;
double mouse_press_pixels_moved_abs;
- sf::Vector2f mouse_pos;
- sf::Vector2i prev_mouse_pos_raw;
- sf::Vector2i mouse_pos_raw;
- sf::Vector2f mouse_scroll_accel;
- sf::Vector2f body_pos;
- sf::Vector2f body_size;
+ mgl::vec2f mouse_pos;
+ mgl::vec2i prev_mouse_pos_raw;
+ mgl::vec2i mouse_pos_raw;
+ mgl::vec2f mouse_scroll_accel;
+ mgl::vec2f body_pos;
+ mgl::vec2f body_size;
double body_swipe_x = 0.0;
bool body_swipe_move_right = false;
bool grabbed_left_side = false;
@@ -259,15 +262,15 @@ namespace QuickMedia {
RoundedRectangle item_background;
RoundedRectangle reaction_background;
bool render_selected_item_bg = true;
- sf::Vector2f item_background_prev_pos;
- sf::Vector2f item_background_target_pos;
- sf::Vector2f item_background_prev_size;
- sf::Vector2f item_background_target_size;
+ mgl::vec2f item_background_prev_pos;
+ mgl::vec2f item_background_target_pos;
+ mgl::vec2f item_background_prev_size;
+ mgl::vec2f item_background_target_size;
float item_background_target_height = 0.0f;
TargetSetState target_set = TargetSetState::NOT_SET;
std::string current_filter;
bool using_filter = false;
- sf::Shader *rounded_rectangle_shader;
- sf::Shader *rounded_rectangle_mask_shader;
+ mgl::Shader *rounded_rectangle_shader;
+ mgl::Shader *rounded_rectangle_mask_shader;
};
} \ No newline at end of file
diff --git a/include/BodyItem.hpp b/include/BodyItem.hpp
index 5889d58..eef674e 100644
--- a/include/BodyItem.hpp
+++ b/include/BodyItem.hpp
@@ -2,10 +2,10 @@
#include "Text.hpp"
#include <memory>
-#include <SFML/Graphics/Text.hpp>
+#include <mglpp/graphics/Text.hpp>
-namespace sf {
- class RenderTarget;
+namespace mgl {
+ class Window;
}
namespace QuickMedia {
@@ -77,21 +77,21 @@ namespace QuickMedia {
dirty_timestamp = true;
}
- void set_title_color(sf::Color new_color) {
+ void set_title_color(mgl::Color new_color) {
if(new_color == title_color)
return;
title_color = new_color;
dirty = true;
}
- void set_description_color(sf::Color new_color) {
+ void set_description_color(mgl::Color new_color) {
if(new_color == description_color)
return;
description_color = new_color;
dirty_description = true;
}
- void set_author_color(sf::Color new_color) {
+ void set_author_color(mgl::Color new_color) {
if(new_color == author_color)
return;
author_color = new_color;
@@ -117,13 +117,13 @@ namespace QuickMedia {
// In milliseconds
int64_t get_timestamp() const { return timestamp; }
- sf::Color get_title_color() const { return title_color; }
- sf::Color get_description_color() const { return description_color; }
- sf::Color get_author_color() const { return author_color; }
+ mgl::Color get_title_color() const { return title_color; }
+ mgl::Color get_description_color() const { return description_color; }
+ mgl::Color get_author_color() const { return author_color; }
bool is_selectable() const { return selectable; }
- void draw_list(Body *body, sf::RenderTarget &render_target);
+ void draw_list(Body *body, mgl::Window &render_target);
// TODO: Use a list of strings instead, not all plugins need all of these fields
std::string url;
@@ -138,7 +138,7 @@ namespace QuickMedia {
std::unique_ptr<Text> title_text;
std::unique_ptr<Text> description_text;
std::unique_ptr<Text> author_text;
- std::unique_ptr<sf::Text> timestamp_text; // TODO: Remove
+ std::unique_ptr<mgl::Text> timestamp_text; // TODO: Remove
// Used by image boards for example. The elements are indices to other body items
std::vector<size_t> replies_to;
// Used by image boards for example. The elements are indices to other body items
@@ -148,7 +148,7 @@ namespace QuickMedia {
float loaded_height = 0.0f;
float height = 0.0f;
float prev_height = 0.0f;
- sf::Vector2f loaded_image_size;
+ mgl::vec2f loaded_image_size;
float loaded_content_height = 0.0f;
FetchStatus embedded_item_status = FetchStatus::NONE;
// Important! Should refer to a new BodyItem, not one that already exists in the body.
@@ -156,7 +156,7 @@ namespace QuickMedia {
// if an embedded item wraps but not the original body item.
std::shared_ptr<BodyItem> embedded_item; // Used by matrix for example to display reply message body. Note: only the first level of embedded items is rendered (not recursive, this is done on purpose)
ThumbnailMaskType thumbnail_mask_type = ThumbnailMaskType::NONE;
- sf::Vector2i thumbnail_size;
+ mgl::vec2i thumbnail_size;
std::vector<Reaction> reactions; // TODO: Move to a different body item type
std::shared_ptr<BodyItemExtra> extra; // TODO: Remove
@@ -171,9 +171,9 @@ namespace QuickMedia {
std::string description;
std::string author;
int64_t timestamp;
- sf::Color title_color;
- sf::Color author_color;
- sf::Color description_color;
+ mgl::Color title_color;
+ mgl::Color author_color;
+ mgl::Color description_color;
bool selectable;
};
diff --git a/include/Entry.hpp b/include/Entry.hpp
index 1ee237b..00c22a4 100644
--- a/include/Entry.hpp
+++ b/include/Entry.hpp
@@ -2,13 +2,13 @@
#include "Text.hpp"
#include "RoundedRectangle.hpp"
-#include <SFML/Graphics/Text.hpp>
+#include <mglpp/graphics/Text.hpp>
#include <functional>
-namespace sf {
+namespace mgl {
class Font;
class Event;
- class RenderWindow;
+ class Window;
class Shader;
}
@@ -18,24 +18,24 @@ namespace QuickMedia {
class Entry {
public:
- Entry(const std::string &placeholder_text, sf::Shader *rounded_rectangle_shader);
- void process_event(sf::Event &event);
- void draw(sf::RenderWindow &window);
+ Entry(const std::string &placeholder_text, mgl::Shader *rounded_rectangle_shader);
+ void process_event(mgl::Window &window, mgl::Event &event);
+ void draw(mgl::Window &window);
void set_single_line(bool single_line);
void set_editable(bool editable);
- void set_text(const std::string &text);
- void set_position(const sf::Vector2f &pos);
+ void set_text(std::string text);
+ void set_position(const mgl::vec2f &pos);
void set_max_width(float width);
void move_caret_to_end();
- void append_text(const std::string &str);
+ void insert_text_at_caret_position(const std::string &str);
- void replace(size_t start_index, size_t length, const sf::String &insert_str);
+ void replace(size_t start_index, size_t length, const std::string &insert_str);
int get_caret_index() const;
bool is_editable() const;
float get_height();
- const sf::String& get_text() const;
+ const std::string& get_text() const;
OnEntrySubmit on_submit_callback;
bool draw_background;
@@ -43,7 +43,7 @@ namespace QuickMedia {
Text text;
float width;
RoundedRectangle background;
- sf::Text placeholder;
+ mgl::Text placeholder;
bool mouse_left_inside;
};
} \ No newline at end of file
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp
index d503f82..182a6a2 100644
--- a/include/ImageViewer.hpp
+++ b/include/ImageViewer.hpp
@@ -3,16 +3,15 @@
#include "Path.hpp"
#include <string>
#include <vector>
-#include <SFML/Graphics/Texture.hpp>
-#include <SFML/Graphics/Sprite.hpp>
-#include <SFML/Graphics/Text.hpp>
-#include <SFML/System/Clock.hpp>
-#include <SFML/Window/Cursor.hpp>
+#include <mglpp/graphics/Texture.hpp>
+#include <mglpp/graphics/Sprite.hpp>
+#include <mglpp/graphics/Text.hpp>
+#include <mglpp/system/Clock.hpp>
#include <thread>
#include <memory>
-namespace sf {
- class RenderWindow;
+namespace mgl {
+ class Window;
}
namespace QuickMedia {
@@ -25,17 +24,17 @@ namespace QuickMedia {
};
struct ImageData {
- sf::Texture texture;
- sf::Sprite sprite;
+ mgl::Texture texture;
+ mgl::Sprite sprite;
ImageStatus image_status;
- std::unique_ptr<sf::Image> image;
+ std::unique_ptr<mgl::Image> image;
bool visible_on_screen;
float prev_height = 0.0f;
};
struct PageSize {
- sf::Vector2<double> size;
- sf::Vector2<double> prev_size;
+ mgl::vec2d size;
+ mgl::vec2d prev_size;
bool loaded;
};
@@ -47,7 +46,7 @@ namespace QuickMedia {
class ImageViewer {
public:
- ImageViewer(sf::RenderWindow *window, int num_pages, const std::string &content_title, const std::string &chapter_title, int current_page, const Path &chapter_cache_dir, bool *fit_image_to_window);
+ ImageViewer(mgl::Window *window, int num_pages, const std::string &content_title, const std::string &chapter_title, int current_page, const Path &chapter_cache_dir, bool *fit_image_to_window);
~ImageViewer();
ImageViewerAction draw();
// Returns page as 1 indexed
@@ -55,10 +54,10 @@ namespace QuickMedia {
int get_num_pages() const { return num_pages; }
private:
void load_image_async(const Path &path, std::shared_ptr<ImageData> image_data);
- bool render_page(sf::RenderWindow &window, int page, double offset_y);
- sf::Vector2<double> get_page_size(int page);
+ bool render_page(mgl::Window &window, int page, double offset_y);
+ mgl::vec2d get_page_size(int page);
private:
- sf::RenderWindow *window;
+ mgl::Window *window;
int current_page;
int num_pages;
@@ -75,20 +74,20 @@ namespace QuickMedia {
int focused_page;
int prev_focused_page = -1;
- sf::Font *font;
- sf::Clock frame_timer;
- sf::Text page_text;
+ mgl::Clock frame_timer;
+ mgl::Text page_text;
std::vector<std::shared_ptr<ImageData>> image_data;
std::vector<PageSize> page_size;
- sf::Vector2<double> window_size;
+ mgl::vec2d window_size;
bool window_size_set = false;
bool middle_mouse_scrolling = false;
double autoscroll_start_y = 0.0;
- sf::Cursor default_cursor;
- sf::Cursor size_vertical_cursor;
+ // TODO: Fix
+ //sf::Cursor default_cursor;
+ //sf::Cursor size_vertical_cursor;
bool has_default_cursor;
bool has_size_vertical_cursor;
diff --git a/include/NetUtils.hpp b/include/NetUtils.hpp
index a142884..f57f942 100644
--- a/include/NetUtils.hpp
+++ b/include/NetUtils.hpp
@@ -15,6 +15,5 @@ namespace QuickMedia {
std::string url_param_decode(const std::string &param);
std::vector<Range> extract_urls(const std::string &str);
std::vector<std::string> ranges_get_strings(const std::string &str, const std::vector<Range> &ranges);
- void convert_utf8_to_utf32_ranges(const std::string &str, std::vector<Range> &ranges);
std::string header_extract_value(const std::string &header, const std::string &type);
} \ No newline at end of file
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
+}
diff --git a/include/ResourceLoader.hpp b/include/ResourceLoader.hpp
index 52f4975..f2b2888 100644
--- a/include/ResourceLoader.hpp
+++ b/include/ResourceLoader.hpp
@@ -1,6 +1,6 @@
#pragma once
-namespace sf {
+namespace mgl {
class Font;
class Texture;
}
@@ -20,10 +20,10 @@ namespace QuickMedia::FontLoader {
};
// Note: not thread-safe
- sf::Font* get_font(FontType font_type);
+ mgl::Font* get_font(FontType font_type, unsigned int character_size);
}
namespace QuickMedia::TextureLoader {
- // Note: not thread-safe
- sf::Texture* get_texture(const char *filepath);
+ // Note: not thread-safe. Filepath is relative to the resource loader root path
+ mgl::Texture* get_texture(const char *filepath, bool pixel_coordinates = false);
} \ No newline at end of file
diff --git a/include/RoundedRectangle.hpp b/include/RoundedRectangle.hpp
index 96e57fd..dcf652c 100644
--- a/include/RoundedRectangle.hpp
+++ b/include/RoundedRectangle.hpp
@@ -1,28 +1,29 @@
#pragma once
-#include <SFML/System/Vector2.hpp>
-#include <SFML/Graphics/Vertex.hpp>
+#include <mglpp/graphics/Color.hpp>
+#include <mglpp/graphics/Vertex.hpp>
+#include <mglpp/system/vec.hpp>
-namespace sf {
- class RenderTarget;
+namespace mgl {
+ class Window;
class Shader;
}
namespace QuickMedia {
class RoundedRectangle {
public:
- RoundedRectangle(sf::Vector2f size, float radius, sf::Color color, sf::Shader *rounded_rectangle_shader);
- void set_position(sf::Vector2f pos);
- void set_size(sf::Vector2f size);
- void set_color(sf::Color color);
- sf::Vector2f get_position() const;
- sf::Vector2f get_size() const;
- void draw(sf::RenderTarget &target);
+ RoundedRectangle(mgl::vec2f size, float radius, mgl::Color color, mgl::Shader *rounded_rectangle_shader);
+ void set_position(mgl::vec2f pos);
+ void set_size(mgl::vec2f size);
+ void set_color(mgl::Color color);
+ mgl::vec2f get_position() const;
+ mgl::vec2f get_size() const;
+ void draw(mgl::Window &target);
private:
float radius;
- sf::Vector2f pos;
- sf::Vector2f size;
- sf::Vertex vertices[4];
- sf::Shader *rounded_rectangle_shader;
+ mgl::vec2f pos;
+ mgl::vec2f size;
+ mgl::Vertex vertices[4];
+ mgl::Shader *rounded_rectangle_shader;
};
} \ No newline at end of file
diff --git a/include/Scale.hpp b/include/Scale.hpp
index eb902cd..daf1e75 100644
--- a/include/Scale.hpp
+++ b/include/Scale.hpp
@@ -1,10 +1,10 @@
#pragma once
-#include <SFML/System/Vector2.hpp>
+#include <mglpp/system/vec.hpp>
namespace QuickMedia {
- template<typename T>
- static T wrap_to_size_x(const T &size, const T &clamp_size) {
+ template<typename T, typename A>
+ static T wrap_to_size_x(const T &size, A clamp_size) {
T new_size;
if(size.x == 0) {
new_size.x = 0;
@@ -12,13 +12,13 @@ namespace QuickMedia {
return new_size;
}
float size_ratio = (float)size.y / (float)size.x;
- new_size.x = clamp_size.x;
+ new_size.x = clamp_size;
new_size.y = new_size.x * size_ratio;
return new_size;
}
- template<typename T>
- static T wrap_to_size_y(const T &size, const T &clamp_size) {
+ template<typename T, typename A>
+ static T wrap_to_size_y(const T &size, A clamp_size) {
T new_size;
if(size.y == 0) {
new_size.x = 0;
@@ -26,7 +26,7 @@ namespace QuickMedia {
return new_size;
}
float size_ratio = (float)size.x / (float)size.y;
- new_size.y = clamp_size.y;
+ new_size.y = clamp_size;
new_size.x = new_size.y * size_ratio;
return new_size;
}
@@ -34,20 +34,28 @@ namespace QuickMedia {
template<typename T>
static T wrap_to_size(const T &size, const T &clamp_size) {
T new_size;
- new_size = wrap_to_size_x(size, clamp_size);
+ new_size = wrap_to_size_x(size, clamp_size.x);
if(new_size.y > clamp_size.y)
- new_size = wrap_to_size_y(size, clamp_size);
+ new_size = wrap_to_size_y(size, clamp_size.y);
return new_size;
}
- template<typename T>
- static T clamp_to_size_x(const T &size, const T &clamp_size) {
+ template<typename T, typename A>
+ static T clamp_to_size_x(const T &size, A clamp_size) {
T new_size = size;
- if(size.x > clamp_size.x)
+ if(size.x > clamp_size)
new_size = wrap_to_size_x(new_size, clamp_size);
return new_size;
}
+ template<typename T, typename A>
+ static T clamp_to_size_y(const T &size, const A clamp_size) {
+ T new_size = size;
+ if(size.y > clamp_size)
+ new_size = wrap_to_size_y(new_size, clamp_size);
+ return new_size;
+ }
+
template<typename T>
static T clamp_to_size(const T &size, const T &clamp_size) {
T new_size = size;
@@ -57,10 +65,10 @@ namespace QuickMedia {
}
template<typename T>
- static sf::Vector2f get_ratio(const T &original_size, const T &new_size) {
+ static mgl::vec2f get_ratio(const T &original_size, const T &new_size) {
if(original_size.x == 0 || original_size.y == 0)
- return sf::Vector2f(0.0f, 0.0f);
+ return mgl::vec2f(0.0f, 0.0f);
else
- return sf::Vector2f((float)new_size.x / (float)original_size.x, (float)new_size.y / (float)original_size.y);
+ return mgl::vec2f((float)new_size.x / (float)original_size.x, (float)new_size.y / (float)original_size.y);
}
} \ No newline at end of file
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index 12daf58..9170f7a 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -1,16 +1,17 @@
#pragma once
#include "RoundedRectangle.hpp"
-#include <SFML/Graphics/Text.hpp>
-#include <SFML/Graphics/RectangleShape.hpp>
-#include <SFML/Graphics/Sprite.hpp>
-#include <SFML/System/Clock.hpp>
+#include <mglpp/window/Event.hpp>
+#include <mglpp/graphics/Text.hpp>
+#include <mglpp/graphics/Rectangle.hpp>
+#include <mglpp/graphics/Sprite.hpp>
+#include <mglpp/system/Clock.hpp>
#include <functional>
+#include <string>
-namespace sf {
+namespace mgl {
class Font;
- class RenderWindow;
- class Event;
+ class Window;
class Shader;
}
@@ -21,15 +22,15 @@ namespace QuickMedia {
class SearchBar {
public:
- SearchBar(sf::Texture *plugin_logo, sf::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked = false);
- void draw(sf::RenderWindow &window, sf::Vector2f size, bool draw_background);
- void on_event(sf::Event &event);
+ SearchBar(mgl::Texture *plugin_logo, mgl::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked = false);
+ void draw(mgl::Window &window, mgl::vec2f size, bool draw_background);
+ void on_event(mgl::Window &window, mgl::Event &event);
void update();
- void onWindowResize(const sf::Vector2f &window_size);
+ void onWindowResize(const mgl::vec2f &window_size);
void clear();
void set_text(const std::string &text, bool update_search = true);
void append_text(const std::string &text_to_add);
- void set_position(sf::Vector2f pos);
+ void set_position(mgl::vec2f pos);
void set_editable(bool editable);
bool is_editable() const;
@@ -42,20 +43,20 @@ namespace QuickMedia {
TextUpdateCallback onTextUpdateCallback;
TextSubmitCallback onTextSubmitCallback;
TextBeginTypingCallback onTextBeginTypingCallback;
- int text_autosearch_delay;
+ int text_autosearch_delay_ms;
bool caret_visible;
float padding_top = 0.0f;
float padding_bottom = 0.0f;
float padding_x = 10.0f;
private:
- void onTextEntered(sf::Uint32 codepoint);
+ void onTextEntered(const mgl::Event::TextEvent &text_event);
private:
- sf::Text text;
+ mgl::Text text;
RoundedRectangle background;
- sf::RectangleShape shade;
- sf::RectangleShape caret;
- sf::Sprite plugin_logo_sprite;
+ mgl::Rectangle shade;
+ mgl::Rectangle caret;
+ mgl::Sprite plugin_logo_sprite;
std::string placeholder_str;
bool show_placeholder;
bool updated_search;
@@ -65,9 +66,9 @@ namespace QuickMedia {
bool typing;
bool backspace_pressed;
bool mouse_left_inside;
- sf::Vector2f pos;
- sf::Clock time_since_search_update;
- sf::Vector2f prev_size;
+ mgl::vec2f pos;
+ mgl::Clock time_since_search_update;
+ mgl::vec2f prev_size;
bool editable = true;
};
} \ No newline at end of file
diff --git a/include/SfmlFixes.hpp b/include/SfmlFixes.hpp
deleted file mode 100644
index fc893c5..0000000
--- a/include/SfmlFixes.hpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-#include <SFML/Graphics/Image.hpp>
-
-namespace QuickMedia {
- // See: https://github.com/SFML/SFML/issues/1711
- // TODO: Remove when above is fixed, or fix ourselves and include the fixed sfml version as a dependency,
- // or write our own image class (maybe even use stb like sfml does but no error reason printing)
- bool load_image_from_file(sf::Image &image, const std::string &filepath);
- bool load_image_from_memory(sf::Image &image, const void *data, size_t size);
-} \ No newline at end of file
diff --git a/include/Tabs.hpp b/include/Tabs.hpp
index 51a7e9d..a5ca8ab 100644
--- a/include/Tabs.hpp
+++ b/include/Tabs.hpp
@@ -1,14 +1,15 @@
#pragma once
#include "RoundedRectangle.hpp"
-#include <SFML/Graphics/RectangleShape.hpp>
-#include <SFML/Graphics/Text.hpp>
+#include <mglpp/graphics/Rectangle.hpp>
+#include <mglpp/graphics/Text.hpp>
+#include <mglpp/graphics/Sprite.hpp>
#include <vector>
#include <functional>
-namespace sf {
+namespace mgl {
class Event;
- class RenderWindow;
+ class Window;
class Shader;
}
@@ -17,16 +18,16 @@ namespace QuickMedia {
class Tabs {
public:
- Tabs(sf::Shader *rounded_rectangle_shader);
- Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color);
+ Tabs(mgl::Shader *rounded_rectangle_shader);
+ Tabs(mgl::Shader *rounded_rectangle_shader, mgl::Color shade_color);
static float get_height();
static float get_shade_height();
// Returns the id (index) of the tab. The ids start from 0
- int add_tab(const std::string &title, Body *body);
- void on_event(sf::Event &event);
- void draw(sf::RenderWindow &window, sf::Vector2f pos, float width);
+ int add_tab(std::string title, Body *body);
+ void on_event(mgl::Event &event);
+ void draw(mgl::Window &window, mgl::vec2f pos, float width);
void set_text(int index, const std::string &text);
@@ -39,19 +40,19 @@ namespace QuickMedia {
float tab_index_to_x_offset(int index);
private:
struct Tab {
- sf::Text text;
- std::string label_utf8; // TODO: Remove
+ mgl::Text text;
Body *body;
};
std::vector<Tab> tabs;
RoundedRectangle background;
- sf::RectangleShape shade;
+ mgl::Rectangle shade;
int selected_tab = 0;
float scroll = 0.0f;
float width_per_tab = 0.0f;
float tab_background_width = 0.0f;
float container_width = 0.0f;
int tab_offset = 0;
- sf::Color shade_color;
+ mgl::Color shade_color;
+ mgl::Sprite arrow_sprite;
};
} \ No newline at end of file
diff --git a/include/Text.hpp b/include/Text.hpp
index 8eb5c96..dc3a0f7 100644
--- a/include/Text.hpp
+++ b/include/Text.hpp
@@ -1,37 +1,26 @@
#pragma once
#include "NetUtils.hpp"
-#include <SFML/Graphics/VertexArray.hpp>
-#include <SFML/Graphics/VertexBuffer.hpp>
-#include <SFML/System/String.hpp>
-#include <SFML/System/Clock.hpp>
+#include <mglpp/system/FloatRect.hpp>
+#include <mglpp/system/vec.hpp>
+#include <mglpp/graphics/Color.hpp>
+#include <mglpp/graphics/VertexBuffer.hpp>
+#include <mglpp/graphics/Vertex.hpp>
+#include <mglpp/system/Clock.hpp>
#include <vector>
+#include <string_view>
+#include <array>
#include "types.hpp"
#include <assert.h>
-namespace sf {
+namespace mgl {
class Font;
class Event;
- class RenderTarget;
+ class Window;
}
namespace QuickMedia
{
- struct StringViewUtf32 {
- const u32 *data;
- size_t size;
-
- StringViewUtf32() : data(nullptr), size(0) {}
- StringViewUtf32(const u32 *data, usize size) : data(data), size(size) {}
-
- size_t find(const StringViewUtf32 &other, size_t offset = 0) const;
-
- u32 operator [] (usize index) const {
- assert(index < size);
- return data[index];
- }
- };
-
struct TextElement
{
enum class Type
@@ -47,10 +36,9 @@ namespace QuickMedia
};
TextElement() {}
- TextElement(const StringViewUtf32 &_text, Type _type) : text(_text), type(_type), text_type(TextType::LATIN) {}
+ TextElement(std::string_view text, Type type) : text(text), type(type), text_type(TextType::LATIN) {}
- StringViewUtf32 text;
- sf::Vector2f position;
+ std::string_view text;
Type type;
//bool ownLine; // Currently only used for emoji, to make emoji bigger when it's the only thing on a line
TextType text_type;
@@ -60,33 +48,34 @@ namespace QuickMedia
int vertices_index; // index to |vertices| VertexArray
int index; // index within vertices[vertices_index]
int line;
- sf::Uint32 codepoint;
+ uint32_t codepoint;
};
class Text
{
public:
- Text(sf::String str, bool bold_font, unsigned int characterSize, float maxWidth, bool highlight_urls = false);
+ Text(std::string str, bool bold_font, unsigned int characterSize, float maxWidth, bool highlight_urls = false);
- void setString(const sf::String &str);
- const sf::String& getString() const;
- void appendText(const sf::String &str);
+ void setString(std::string str);
+ const std::string& getString() const;
+ void appendText(const std::string &str);
+ void insert_text_at_caret_position(const std::string &str);
- void setPosition(float x, float y);
- void setPosition(const sf::Vector2f &position);
- sf::Vector2f getPosition() const;
+ void set_position(float x, float y);
+ void set_position(const mgl::vec2f &position);
+ mgl::vec2f get_position() const;
void setMaxWidth(float maxWidth);
float getMaxWidth() const;
void setCharacterSize(unsigned int characterSize);
- unsigned int getCharacterSize() const;
+ unsigned int get_character_size() const;
- void replace(size_t start_index, size_t length, const sf::String &insert_str);
+ void replace(size_t start_index, size_t length, const std::string &insert_str);
int getCaretIndex() const;
- void setFillColor(sf::Color color);
+ void set_color(mgl::Color color);
void setLineSpacing(float lineSpacing);
void setCharacterSpacing(float characterSpacing);
void setEditable(bool editable);
@@ -100,11 +89,11 @@ namespace QuickMedia
// Note: won't update until @draw is called
float getHeight() const;
- void processEvent(const sf::Event &event);
+ void processEvent(mgl::Window &window, const mgl::Event &event);
// Performs culling. @updateGeometry is called even if text is not visible if text is dirty, because updateGeometry might change the dimension of the text and make is visible.
// Returns true if text was drawn on screen (if text is within window borders)
- bool draw(sf::RenderTarget &target);
+ bool draw(mgl::Window &target);
void updateGeometry(bool update_even_if_not_dirty = false);
@@ -134,7 +123,7 @@ namespace QuickMedia
void splitTextByFont();
- float font_get_real_height(sf::Font *font);
+ float font_get_real_height(mgl::Font *font);
float get_text_quad_left_side(const VertexRef &vertex_ref) const;
float get_text_quad_right_side(const VertexRef &vertex_ref) const;
// If the index is past the end, then the caret offset is the right side of the last character, rather than the left side
@@ -142,23 +131,24 @@ namespace QuickMedia
VertexRef& get_vertex_ref_clamp(int index);
// Takes into consideration if index is the last vertex and the last vertex is a newline, then it should be on its own line
int get_vertex_line(int index) const;
- sf::Uint32 get_vertex_codepoint(int index) const;
+ uint32_t get_vertex_codepoint(int index) const;
+ size_t get_string_index_from_caret_index(size_t caret_index) const;
private:
- sf::String str; // TODO: Remove this for non-editable text??? also replace with std::string? then we get more efficient editing of text
+ std::string str; // TODO: Remove this for non-editable text??? also replace with std::string? then we get more efficient editing of text
const bool bold_font;
unsigned int characterSize;
- std::array<sf::VertexArray, 4> vertices;
- std::array<sf::VertexBuffer, 4> vertex_buffers;
+ std::array<std::vector<mgl::Vertex>, 4> vertices;
+ std::array<mgl::VertexBuffer, 4> vertex_buffers;
float maxWidth;
- sf::Vector2f position;
- sf::Color color;
+ mgl::vec2f position;
+ mgl::Color color;
bool dirty;
bool dirtyText;
bool dirtyCaret;
bool editable;
bool highlight_urls;
CaretMoveDirection caretMoveDirection;
- sf::FloatRect boundingBox;
+ mgl::FloatRect boundingBox;
int num_lines;
float lineSpacing;
float characterSpacing;
@@ -166,8 +156,8 @@ namespace QuickMedia
int caretIndex;
float caret_offset_x;
- sf::Vector2f caretPosition;
- sf::Vector2u renderTargetSize;
+ mgl::vec2f caretPosition;
+ mgl::vec2u renderTarget_size;
std::vector<VertexRef> vertices_linear; // TODO: Use textElements instead
diff --git a/include/Theme.hpp b/include/Theme.hpp
index 8f62040..974f4f7 100644
--- a/include/Theme.hpp
+++ b/include/Theme.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <SFML/Graphics/Color.hpp>
+#include <mglpp/graphics/Color.hpp>
namespace QuickMedia {
struct Theme {
@@ -8,28 +8,28 @@ namespace QuickMedia {
Theme(const Theme&) = delete;
Theme&operator=(const Theme&) = delete;
- sf::Color background_color = sf::Color(18, 21, 26);
- sf::Color text_color = sf::Color(255, 255, 255);
- sf::Color faded_text_color = sf::Color(255, 255, 255, 179);
- sf::Color shade_color = sf::Color(28, 32, 39);
- sf::Color selected_color = sf::Color(55, 60, 68);
- sf::Color card_item_background_color = sf::Color(28, 32, 39);
- sf::Color replies_text_color = sf::Color(129, 162, 190);
- sf::Color placeholder_text_color = sf::Color(255, 255, 255, 100);
- sf::Color image_loading_background_color = sf::Color(52, 58, 70);
- sf::Color attention_alert_text_color = sf::Color(255, 100, 100);
- sf::Color cancel_button_background_color = sf::Color(41, 45, 50);
- sf::Color confirm_button_background_color = sf::Color(31, 117, 255);
- sf::Color loading_bar_color = sf::Color(31, 117, 255);
- sf::Color embedded_item_border_color = sf::Color(255, 255, 255);
- sf::Color provisional_message_color = sf::Color(255, 255, 255, 150);
- sf::Color failed_text_color = sf::Color(255, 0, 0);
- sf::Color timestamp_text_color = sf::Color(185, 190, 198, 100);
- sf::Color new_items_alert_color = sf::Color(128, 50, 50);
- sf::Color arrow_color = sf::Color(255, 255, 255, 175);
- sf::Color url_text_color = sf::Color(35, 140, 245);
- sf::Color loading_page_color = sf::Color(175, 180, 188);
- sf::Color more_items_color = sf::Color(150, 175, 255, 100);
+ mgl::Color background_color = mgl::Color(18, 21, 26);
+ mgl::Color text_color = mgl::Color(255, 255, 255);
+ mgl::Color faded_text_color = mgl::Color(255, 255, 255, 179);
+ mgl::Color shade_color = mgl::Color(28, 32, 39);
+ mgl::Color selected_color = mgl::Color(55, 60, 68);
+ mgl::Color card_item_background_color = mgl::Color(28, 32, 39);
+ mgl::Color replies_text_color = mgl::Color(129, 162, 190);
+ mgl::Color placeholder_text_color = mgl::Color(255, 255, 255, 100);
+ mgl::Color image_loading_background_color = mgl::Color(52, 58, 70);
+ mgl::Color attention_alert_text_color = mgl::Color(255, 100, 100);
+ mgl::Color cancel_button_background_color = mgl::Color(41, 45, 50);
+ mgl::Color confirm_button_background_color = mgl::Color(31, 117, 255);
+ mgl::Color loading_bar_color = mgl::Color(31, 117, 255);
+ mgl::Color embedded_item_border_color = mgl::Color(255, 255, 255);
+ mgl::Color provisional_message_color = mgl::Color(255, 255, 255, 150);
+ mgl::Color failed_text_color = mgl::Color(255, 0, 0);
+ mgl::Color timestamp_text_color = mgl::Color(185, 190, 198, 100);
+ mgl::Color new_items_alert_color = mgl::Color(128, 50, 50);
+ mgl::Color arrow_color = mgl::Color(255, 255, 255, 175);
+ mgl::Color url_text_color = mgl::Color(35, 140, 245);
+ mgl::Color loading_page_color = mgl::Color(175, 180, 188);
+ mgl::Color more_items_color = mgl::Color(150, 175, 255, 100);
bool drop_shadow = false;
};
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 138d47e..fe0e583 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -2,7 +2,7 @@
#include <time.h>
#include <string>
-#include <SFML/System/Vector2.hpp>
+#include <mglpp/system/vec.hpp>
namespace QuickMedia {
void show_virtual_keyboard();
@@ -13,5 +13,5 @@ namespace QuickMedia {
std::string unix_time_to_local_time_str(time_t unix_time);
int64_t get_boottime_milliseconds();
- sf::Vector2f vec2f_floor(float x, float y);
+ mgl::vec2f vec2f_floor(float x, float y);
} \ No newline at end of file
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp
index 4eab812..2ccd280 100644
--- a/include/VideoPlayer.hpp
+++ b/include/VideoPlayer.hpp
@@ -1,8 +1,8 @@
#pragma once
#include "MediaChapter.hpp"
-#include <SFML/Window/WindowHandle.hpp>
-#include <SFML/System/Clock.hpp>
+#include <mglpp/window/Window.hpp>
+#include <mglpp/system/Clock.hpp>
#include <functional>
#include <json/value.h>
#include <sys/un.h>
@@ -10,7 +10,7 @@
namespace QuickMedia {
using EventCallbackFunc = std::function<void(const char *event_name)>;
- using VideoPlayerWindowCreateCallback = std::function<void(sf::WindowHandle window)>;
+ using VideoPlayerWindowCreateCallback = std::function<void(mgl::WindowHandle window)>;
// Currently this video player launches mpv and embeds it into the QuickMedia window
class VideoPlayer {
@@ -41,7 +41,7 @@ namespace QuickMedia {
VideoPlayer& operator=(const VideoPlayer&) = delete;
// |audio_path| is only set when video and audio are separate files/urls.
- Error load_video(const char *path, const char *audio_path, sf::WindowHandle parent_window, bool use_youtube_dl, const std::string &title, const std::string &start_time = "", const std::vector<MediaChapter> &chapters = {});
+ Error load_video(const char *path, const char *audio_path, mgl::WindowHandle parent_window, bool use_youtube_dl, const std::string &title, const std::string &start_time = "", const std::vector<MediaChapter> &chapters = {});
// Should be called every update frame
Error update();
@@ -56,7 +56,7 @@ namespace QuickMedia {
int exit_status;
private:
Error send_command(const char *cmd, size_t size);
- Error launch_video_process(const char *path, const char *audio_path, sf::WindowHandle parent_window, const std::string &title, const std::string &start_time);
+ Error launch_video_process(const char *path, const char *audio_path, mgl::WindowHandle parent_window, const std::string &title, const std::string &start_time);
VideoPlayer::Error read_ipc_func();
private:
std::string plugin_name;
@@ -66,7 +66,7 @@ namespace QuickMedia {
bool use_youtube_dl;
pid_t video_process_id;
bool connected_to_ipc;
- sf::Clock retry_timer;
+ mgl::Clock retry_timer;
int connect_tries;
int find_window_tries;
int monitor_height;
@@ -75,8 +75,8 @@ namespace QuickMedia {
char ipc_server_path[L_tmpnam];
EventCallbackFunc event_callback;
VideoPlayerWindowCreateCallback window_create_callback;
- sf::WindowHandle window_handle;
- sf::WindowHandle parent_window;
+ mgl::WindowHandle window_handle;
+ mgl::WindowHandle parent_window;
Display *display;
unsigned int request_id;
unsigned int expected_request_id;
diff --git a/include/gui/Button.hpp b/include/gui/Button.hpp
index ba6997b..2a22a88 100644
--- a/include/gui/Button.hpp
+++ b/include/gui/Button.hpp
@@ -2,12 +2,12 @@
#include "../RoundedRectangle.hpp"
#include <string>
-#include <SFML/Graphics/Text.hpp>
+#include <mglpp/graphics/Text.hpp>
-namespace sf {
+namespace mgl {
class Event;
class Font;
- class RenderTarget;
+ class Window;
class Shader;
}
@@ -19,21 +19,21 @@ namespace QuickMedia {
class Button {
public:
- Button(const std::string &label, sf::Font *font, unsigned int character_size, float width, sf::Shader *rounded_rectangle_shader, float scale = 1.0f);
+ Button(const std::string &label, mgl::Font *font, float width, mgl::Shader *rounded_rectangle_shader, float scale = 1.0f);
- ButtonEvent on_event(sf::Event &event);
- void draw(sf::RenderTarget &target);
+ ButtonEvent on_event(mgl::Event &event);
+ void draw(mgl::Window &target);
- void set_background_color(sf::Color color);
- void set_position(sf::Vector2f pos);
+ void set_background_color(mgl::Color color);
+ void set_position(mgl::vec2f pos);
- sf::Vector2f get_position() const;
+ mgl::vec2f get_position() const;
float get_width() const;
- float get_height() const;
+ float get_height();
private:
- sf::Text label;
+ mgl::Text label;
RoundedRectangle background;
- sf::Color background_color;
+ mgl::Color background_color;
float scale;
bool clicked_inside = false;
};