aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp94
-rw-r--r--src/BodyItem.cpp2
-rw-r--r--src/Entry.cpp14
-rw-r--r--src/ImageViewer.cpp5
-rw-r--r--src/QuickMedia.cpp36
-rw-r--r--src/SearchBar.cpp12
-rw-r--r--src/Tabs.cpp4
-rw-r--r--src/Utils.cpp33
8 files changed, 116 insertions, 84 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 10f0d86..1762ba5 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -30,53 +30,53 @@ struct BodySpacing {
float embedded_item_font_size = 0.0f;
};
-static const int card_width = 250.0f * QuickMedia::get_ui_scale();
-static const int card_height = 350.0f * QuickMedia::get_ui_scale();
+namespace QuickMedia {
+ static const int card_width = 250.0f * get_ui_scale() * get_font_scale();
+ static const int card_height = 350.0f * get_ui_scale() * get_font_scale();
-static const int min_column_spacing = 10 * QuickMedia::get_ui_scale();
-static const int card_padding_x = 20 * QuickMedia::get_ui_scale();
-static const int card_padding_y = 20 * QuickMedia::get_ui_scale();
-static const int card_image_text_padding = 10 * QuickMedia::get_ui_scale();
-static const sf::Vector2i card_max_image_size(card_width - card_padding_x * 2, (card_height - card_padding_y * 2) / 2);
-static const int num_columns_switch_to_list = 1;
-static const int embedded_item_border_width = 4;
+ static const int min_column_spacing = 10 * get_ui_scale();
+ static const int card_padding_x = 20 * get_ui_scale();
+ static const int card_padding_y = 20 * get_ui_scale();
+ static const int card_image_text_padding = 10 * get_ui_scale();
+ static const sf::Vector2i card_max_image_size(card_width - card_padding_x * 2, (card_height - card_padding_y * 2) / 2);
+ static const int num_columns_switch_to_list = 1;
+ static const int embedded_item_border_width = 4;
-static BodySpacing body_spacing[2];
-static bool themes_initialized = false;
+ static BodySpacing body_spacing[2];
+ static bool themes_initialized = false;
-namespace QuickMedia {
static void init_body_theme_minimal() {
- body_spacing[BODY_THEME_MINIMAL].spacing_y = std::floor(10.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].padding_x = std::floor(10.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].image_padding_x = std::floor(5.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].padding_y = std::floor(5.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].padding_y_text_only = std::floor(5.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].embedded_item_padding_y = std::floor(0.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].body_padding_horizontal = std::floor(10.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].body_padding_vertical = std::floor(10.0f * QuickMedia::get_ui_scale());
-
- body_spacing[BODY_THEME_MINIMAL].reaction_background_padding_x = std::floor(7.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].reaction_background_padding_y = std::floor(3.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].reaction_spacing_x = std::floor(5.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].reaction_padding_y = std::floor(7.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MINIMAL].embedded_item_font_size = std::floor(14 * QuickMedia::get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].spacing_y = std::floor(10.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].padding_x = std::floor(10.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].image_padding_x = std::floor(5.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].padding_y = std::floor(5.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].padding_y_text_only = std::floor(5.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].embedded_item_padding_y = std::floor(0.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].body_padding_horizontal = std::floor(10.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].body_padding_vertical = std::floor(10.0f * get_ui_scale());
+
+ body_spacing[BODY_THEME_MINIMAL].reaction_background_padding_x = std::floor(7.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].reaction_background_padding_y = std::floor(3.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].reaction_spacing_x = std::floor(5.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].reaction_padding_y = std::floor(7.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MINIMAL].embedded_item_font_size = std::floor(14 * get_ui_scale());
}
static void init_body_theme_modern_spacious() {
- body_spacing[BODY_THEME_MODERN_SPACIOUS].spacing_y = std::floor(20.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].padding_x = std::floor(20.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].image_padding_x = std::floor(15.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].padding_y = std::floor(15.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].padding_y_text_only = std::floor(7.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].embedded_item_padding_y = std::floor(0.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].body_padding_horizontal = std::floor(20.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].body_padding_vertical = std::floor(20.0f * QuickMedia::get_ui_scale());
-
- body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_background_padding_x = std::floor(7.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_background_padding_y = std::floor(3.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_spacing_x = std::floor(5.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_padding_y = std::floor(7.0f * QuickMedia::get_ui_scale());
- body_spacing[BODY_THEME_MODERN_SPACIOUS].embedded_item_font_size = std::floor(14 * QuickMedia::get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].spacing_y = std::floor(20.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].padding_x = std::floor(20.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].image_padding_x = std::floor(15.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].padding_y = std::floor(15.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].padding_y_text_only = std::floor(7.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].embedded_item_padding_y = std::floor(0.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].body_padding_horizontal = std::floor(20.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].body_padding_vertical = std::floor(20.0f * get_ui_scale());
+
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_background_padding_x = std::floor(7.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_background_padding_y = std::floor(3.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_spacing_x = std::floor(5.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].reaction_padding_y = std::floor(7.0f * get_ui_scale());
+ body_spacing[BODY_THEME_MODERN_SPACIOUS].embedded_item_font_size = std::floor(14 * get_ui_scale());
}
static void init_body_themes() {
@@ -100,8 +100,8 @@ namespace QuickMedia {
selected_item(0),
prev_selected_item(0),
loading_icon(loading_icon_texture),
- progress_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14 * get_ui_scale())),
- replies_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14 * get_ui_scale())),
+ progress_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14 * get_ui_scale() * get_font_scale())),
+ replies_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14 * get_ui_scale() * get_font_scale())),
num_visible_items(0),
top_cut_off(false),
bottom_cut_off(false),
@@ -838,7 +838,7 @@ namespace QuickMedia {
body_item->title_text->setString(std::move(str));
body_item->title_text->setMaxWidth(width);
} else {
- body_item->title_text = std::make_unique<Text>(std::move(str), false, std::floor(16 * get_ui_scale()), width, title_mark_urls);
+ body_item->title_text = std::make_unique<Text>(std::move(str), false, std::floor(16 * get_ui_scale() * get_font_scale()), width, title_mark_urls);
}
body_item->title_text->setFillColor(body_item->get_title_color());
body_item->title_text->updateGeometry();
@@ -851,7 +851,7 @@ namespace QuickMedia {
body_item->description_text->setString(std::move(str));
body_item->description_text->setMaxWidth(width);
} else {
- body_item->description_text = std::make_unique<Text>(std::move(str), false, std::floor(14 * get_ui_scale()), width, true);
+ body_item->description_text = std::make_unique<Text>(std::move(str), false, std::floor(14 * get_ui_scale() * get_font_scale()), width, true);
}
body_item->description_text->setFillColor(body_item->get_description_color());
body_item->description_text->updateGeometry();
@@ -864,7 +864,7 @@ namespace QuickMedia {
body_item->author_text->setString(std::move(str));
body_item->author_text->setMaxWidth(width);
} else {
- body_item->author_text = std::make_unique<Text>(std::move(str), true, std::floor(14 * get_ui_scale()), width);
+ body_item->author_text = std::make_unique<Text>(std::move(str), true, std::floor(14 * get_ui_scale() * get_font_scale()), width);
}
body_item->author_text->setFillColor(body_item->get_author_color());
body_item->author_text->updateGeometry();
@@ -889,7 +889,7 @@ namespace QuickMedia {
if(body_item->timestamp_text) {
body_item->timestamp_text->setString(time_str);
} else {
- body_item->timestamp_text = std::make_unique<sf::Text>(time_str, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(10 * get_ui_scale()));
+ body_item->timestamp_text = std::make_unique<sf::Text>(time_str, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(10 * get_ui_scale() * get_font_scale()));
}
body_item->timestamp_text->setFillColor(get_current_theme().timestamp_text_color);
@@ -1412,7 +1412,7 @@ namespace QuickMedia {
text_offset_x += body_spacing[body_theme].image_padding_x + item->loaded_image_size.x;
}
- const float text_offset_y = std::floor(6.0f * get_ui_scale());
+ const float text_offset_y = std::floor(6.0f * get_ui_scale() * get_font_scale());
const float timestamp_text_y = std::floor(item_pos.y + padding_y - text_offset_y);
if(item->author_text && !merge_with_previous) {
diff --git a/src/BodyItem.cpp b/src/BodyItem.cpp
index bf6e45d..8fd5362 100644
--- a/src/BodyItem.cpp
+++ b/src/BodyItem.cpp
@@ -72,7 +72,7 @@ namespace QuickMedia {
void BodyItem::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, std::floor(14 * get_ui_scale()), 0.0f);
+ reaction.text = std::make_unique<Text>(std::move(str), false, std::floor(14 * get_ui_scale() * get_font_scale()), 0.0f);
reaction.userdata = userdata;
reactions.push_back(std::move(reaction));
}
diff --git a/src/Entry.cpp b/src/Entry.cpp
index ce86f8f..771e2fd 100644
--- a/src/Entry.cpp
+++ b/src/Entry.cpp
@@ -5,20 +5,20 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Window/Event.hpp>
-#include <cmath>
-
-const float background_margin_horizontal = std::floor(5.0f * QuickMedia::get_ui_scale());
-const float padding_vertical = std::floor(5.0f * QuickMedia::get_ui_scale());
-const float background_margin_vertical = std::floor(0.0f * QuickMedia::get_ui_scale());
+#include <math.h>
namespace QuickMedia {
+ static const float background_margin_horizontal = std::floor(5.0f * get_ui_scale());
+ static const float padding_vertical = std::floor(5.0f * get_ui_scale());
+ static const float background_margin_vertical = std::floor(0.0f * get_ui_scale());
+
Entry::Entry(const std::string &placeholder_text, sf::Shader *rounded_rectangle_shader) :
on_submit_callback(nullptr),
draw_background(true),
- text("", false, std::floor(16 * get_ui_scale()), 0.0f),
+ text("", false, std::floor(16 * get_ui_scale() * get_font_scale()), 0.0f),
width(0.0f),
background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_current_theme().selected_color, rounded_rectangle_shader),
- placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale())),
+ placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale() * get_font_scale())),
mouse_left_inside(false)
{
text.setEditable(true);
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index a30dd40..0f9e84e 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -4,6 +4,7 @@
#include "../include/SfmlFixes.hpp"
#include "../include/ResourceLoader.hpp"
#include "../include/Scale.hpp"
+#include "../include/Utils.hpp"
#include <cmath>
#include <malloc.h>
#include <SFML/Window/Event.hpp>
@@ -134,7 +135,7 @@ namespace QuickMedia {
msg = "Failed to load image for page " + page_str;
}
- sf::Text error_message(std::move(msg), *font, 30);
+ sf::Text error_message(std::move(msg), *font, 30 * get_ui_scale() * get_font_scale());
auto text_bounds = error_message.getLocalBounds();
error_message.setFillColor(sf::Color::Black);
sf::Vector2<double> render_pos_text(std::floor(window_size.x * 0.5 - text_bounds.width * 0.5), - text_bounds.height * 0.5 + scroll + offset_y);
@@ -153,7 +154,7 @@ namespace QuickMedia {
} else {
std::string page_str = std::to_string(1 + page);
- sf::Text error_message("Downloading page " + page_str, *font, 30);
+ sf::Text error_message("Downloading page " + page_str, *font, 30 * get_ui_scale() * get_font_scale());
auto text_bounds = error_message.getLocalBounds();
error_message.setFillColor(sf::Color::Black);
sf::Vector2<double> render_pos_text(std::floor(window_size.x * 0.5 - text_bounds.width * 0.5), - text_bounds.height * 0.5 + scroll + offset_y);
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 174d779..dd7690f 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1738,7 +1738,7 @@ namespace QuickMedia {
}
if(!tabs[selected_tab].page->is_ready()) {
- sf::Text loading_text("Loading...", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(30 * get_ui_scale()));
+ sf::Text loading_text("Loading...", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(30 * get_ui_scale() * get_font_scale()));
auto text_bounds = loading_text.getLocalBounds();
loading_text.setPosition(
std::floor(body_pos.x + body_size.x * 0.5f - text_bounds.width * 0.5f),
@@ -1845,7 +1845,7 @@ namespace QuickMedia {
std::vector<TabAssociatedData> tab_associated_data;
for(size_t i = 0; i < tabs.size(); ++i) {
TabAssociatedData data;
- data.search_result_text = sf::Text("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(30 * get_ui_scale()));
+ data.search_result_text = sf::Text("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(30 * get_ui_scale() * get_font_scale()));
tab_associated_data.push_back(std::move(data));
}
@@ -3588,7 +3588,7 @@ namespace QuickMedia {
sf::Texture image_texture;
sf::Sprite image;
- sf::Text error_message("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(30 * get_ui_scale()));
+ sf::Text error_message("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(30 * get_ui_scale() * get_font_scale()));
error_message.setFillColor(get_current_theme().text_color);
bool download_in_progress = false;
@@ -3644,7 +3644,7 @@ namespace QuickMedia {
bool error = !error_message.getString().isEmpty();
bool redraw = true;
- sf::Text chapter_text(images_page->manga_name + " | " + images_page->get_chapter_name() + " | Page " + std::to_string(image_index + 1) + "/" + std::to_string(num_manga_pages), *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14 * get_ui_scale()));
+ sf::Text chapter_text(images_page->manga_name + " | " + images_page->get_chapter_name() + " | Page " + std::to_string(image_index + 1) + "/" + std::to_string(num_manga_pages), *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14 * get_ui_scale() * get_font_scale()));
if(image_index == num_manga_pages)
chapter_text.setString(images_page->manga_name + " | " + images_page->get_chapter_name() + " | End");
chapter_text.setFillColor(sf::Color::White);
@@ -3918,7 +3918,7 @@ namespace QuickMedia {
std::string captcha_post_id;
std::string captcha_solution;
std::string comment_to_post;
- const int captcha_solution_text_height = 18 * get_ui_scale();
+ const int captcha_solution_text_height = 18 * get_ui_scale() * get_font_scale();
sf::Text captcha_solution_text("", *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD), captcha_solution_text_height);
int solved_captcha_ttl = 0;
int64_t last_posted_time = time(nullptr);
@@ -4544,7 +4544,7 @@ namespace QuickMedia {
time_left_bg.setFillColor(sf::Color(0, 0, 0, 100));
window.draw(time_left_bg);
- sf::Text time_left_text("Wait " + std::to_string(time_left_until_post_again) + " second(s) before posting again", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(18 * get_ui_scale()));
+ sf::Text time_left_text("Wait " + std::to_string(time_left_until_post_again) + " second(s) before posting again", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(18 * get_ui_scale() * get_font_scale()));
time_left_text.setPosition(time_left_bg.getPosition() +
sf::Vector2f(
std::floor(time_left_bg.getSize().x * 0.5f - time_left_text.getLocalBounds().width * 0.5f),
@@ -4962,23 +4962,23 @@ namespace QuickMedia {
ChatState chat_state = ChatState::NAVIGATING;
std::shared_ptr<BodyItem> currently_operating_on_item;
- sf::Text replying_to_text("Replying to:", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(18 * get_ui_scale()));
+ sf::Text replying_to_text("Replying to:", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(18 * get_ui_scale() * get_font_scale()));
sf::Sprite logo_sprite(plugin_logo);
logo_sprite.setScale(0.8f * get_ui_scale(), 0.8f * get_ui_scale());
sf::Vector2f logo_size(plugin_logo.getSize().x * logo_sprite.getScale().x, plugin_logo.getSize().y * logo_sprite.getScale().y);
- const float room_name_text_height = std::floor(18.0f * get_ui_scale());
+ const float room_name_text_height = std::floor(18.0f * get_ui_scale() * get_font_scale());
sf::Text room_name_text("", *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD), room_name_text_height);
const float room_name_text_padding_y = std::floor(10.0f * get_ui_scale());
const float room_name_total_height = room_name_text_height + room_name_text_padding_y * 2.0f;
const float room_avatar_height = 32.0f;
- const float room_topic_text_height = std::floor(12.0f * get_ui_scale());
+ const float room_topic_text_height = std::floor(12.0f * get_ui_scale() * get_font_scale());
sf::Text room_topic_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), room_topic_text_height);
room_topic_text.setFillColor(get_current_theme().faded_text_color);
- sf::Text room_label(matrix_chat_page->rooms_page->get_title(), *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD), std::floor(18 * get_ui_scale()));
+ sf::Text room_label(matrix_chat_page->rooms_page->get_title(), *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD), std::floor(18 * get_ui_scale() * get_font_scale()));
room_label.setPosition(15.0f, room_name_text_padding_y + 4.0f);
sf::Sprite room_avatar_sprite;
@@ -6787,7 +6787,7 @@ namespace QuickMedia {
overlay.setFillColor(sf::Color(0, 0, 0, 240));
window.draw(overlay);
- const float padding_x = std::floor(10.0f * QuickMedia::get_ui_scale());
+ const float padding_x = std::floor(10.0f * get_ui_scale());
sf::Vector2f body_item_pos(body_pos.x + padding_x, window_size.y - chat_input_height_full - item_height);
sf::Vector2f body_item_size(body_size.x - padding_x * 2.0f, item_height);
@@ -7287,11 +7287,11 @@ namespace QuickMedia {
const float spacing_y = std::floor(15.0f * get_ui_scale());
const float loading_bar_height = std::floor(20.0f * get_ui_scale());
- sf::Text progress_text("0kb/Unknown", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(20.0f * get_ui_scale()));
- sf::Text status_text("Downloading", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(20.0f * get_ui_scale()));
- sf::Text filename_text(filename.c_str(), *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14.0f * get_ui_scale()));
+ sf::Text progress_text("0kb/Unknown", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(20.0f * get_ui_scale() * get_font_scale()));
+ sf::Text status_text("Downloading", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(20.0f * get_ui_scale() * get_font_scale()));
+ sf::Text filename_text(filename.c_str(), *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14.0f * get_ui_scale() * get_font_scale()));
filename_text.setFillColor(get_current_theme().faded_text_color);
- sf::Text download_speed_text("0 bytes/s", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14.0f * get_ui_scale()));
+ sf::Text download_speed_text("0 bytes/s", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(14.0f * get_ui_scale() * get_font_scale()));
download_speed_text.setFillColor(get_current_theme().faded_text_color);
bool redraw = true;
@@ -7473,13 +7473,13 @@ namespace QuickMedia {
const float bottom_panel_padding = 10.0f;
const float bottom_panel_spacing = 10.0f;
- Button cancel_button("Cancel", FontLoader::get_font(FontLoader::FontType::LATIN), 16, 100.0f, &rounded_rectangle_shader, get_ui_scale());
+ Button cancel_button("Cancel", FontLoader::get_font(FontLoader::FontType::LATIN), 16, 100.0f, &rounded_rectangle_shader, get_ui_scale() * get_font_scale());
cancel_button.set_background_color(get_current_theme().cancel_button_background_color);
- Button save_button("Save", FontLoader::get_font(FontLoader::FontType::LATIN), 16, 100.0f, &rounded_rectangle_shader, get_ui_scale());
+ Button save_button("Save", FontLoader::get_font(FontLoader::FontType::LATIN), 16, 100.0f, &rounded_rectangle_shader, get_ui_scale() * get_font_scale());
save_button.set_background_color(get_current_theme().confirm_button_background_color);
- sf::Text file_name_label("File name:", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16.0f * get_ui_scale()));
+ sf::Text file_name_label("File name:", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16.0f * get_ui_scale() * get_font_scale()));
Entry file_name_entry("", &rounded_rectangle_shader);
file_name_entry.set_text(filename);
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index 5b2d6ec..a34b302 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -11,19 +11,19 @@
// TODO: Use a seperate placeholder sf::Text instead of switching the text to placeholder text....
-static const float background_margin_horizontal = 10.0f + std::floor(5.0f * QuickMedia::get_ui_scale());
-static const float padding_top_default = std::floor(10.0f * QuickMedia::get_ui_scale());
-static const float padding_bottom_default = std::floor(15.0f * QuickMedia::get_ui_scale());
-static const float background_margin_vertical = std::floor(4.0f * QuickMedia::get_ui_scale());
-
namespace QuickMedia {
+ static const float background_margin_horizontal = 10.0f + std::floor(5.0f * get_ui_scale());
+ static const float padding_top_default = std::floor(10.0f * get_ui_scale());
+ static const float padding_bottom_default = std::floor(15.0f * get_ui_scale());
+ static const float background_margin_vertical = std::floor(4.0f * get_ui_scale());
+
SearchBar::SearchBar(sf::Texture *plugin_logo, sf::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked) :
onTextUpdateCallback(nullptr),
onTextSubmitCallback(nullptr),
onTextBeginTypingCallback(nullptr),
text_autosearch_delay(50),
caret_visible(true),
- text(placeholder, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale())),
+ text(placeholder, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale() * get_font_scale())),
background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_current_theme().selected_color, rounded_rectangle_shader),
placeholder_str(placeholder),
show_placeholder(true),
diff --git a/src/Tabs.cpp b/src/Tabs.cpp
index 9237d3b..de9e2b3 100644
--- a/src/Tabs.cpp
+++ b/src/Tabs.cpp
@@ -9,8 +9,8 @@
#include <cmath>
namespace QuickMedia {
- static const float tab_text_size = std::floor(16.0f * QuickMedia::get_ui_scale());
- static const float tab_height = tab_text_size + std::floor(10.0f * QuickMedia::get_ui_scale());
+ static const float tab_text_size = std::floor(16.0f * get_ui_scale() * get_font_scale());
+ static const float tab_height = tab_text_size + std::floor(10.0f * get_ui_scale());
static const float tab_min_width = 250.0f;
static const float tab_margin_x = 10.0f;
diff --git a/src/Utils.cpp b/src/Utils.cpp
index c73932b..3919bec 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -7,6 +7,8 @@
namespace QuickMedia {
static float scale = 1.0f;
static bool scale_set = false;
+ static float font_scale = 1.0f;
+ static bool font_scale_set = false;
static bool qm_enable_touch = false;
static bool qm_enable_touch_set = false;
static bool wayland_display_set = false;
@@ -46,9 +48,19 @@ namespace QuickMedia {
if(scale_set)
return scale;
+ setlocale(LC_ALL, "C"); // Sigh... stupid C
+ char *qm_scale = getenv("QM_SCALE");
+ if(qm_scale) {
+ scale = atof(qm_scale);
+ if(scale < 0.0001f)
+ scale = 1.0f;
+
+ scale_set = true;
+ return scale;
+ }
+
char *gdk_scale = getenv("GDK_SCALE");
if(gdk_scale) {
- setlocale(LC_ALL, "C"); // Sigh... stupid C
scale = atof(gdk_scale);
if(scale < 0.0001f)
scale = 1.0f;
@@ -60,6 +72,24 @@ namespace QuickMedia {
return scale;
}
+ float get_font_scale() {
+ if(font_scale_set)
+ return font_scale;
+
+ char *qm_font_scale = getenv("QM_FONT_SCALE");
+ if(qm_font_scale) {
+ setlocale(LC_ALL, "C"); // Sigh... stupid C
+ font_scale = atof(qm_font_scale);
+ if(font_scale < 0.0001f)
+ font_scale = 1.0f;
+ } else {
+ font_scale = 1.0f;
+ }
+
+ font_scale_set = true;
+ return font_scale;
+ }
+
void show_virtual_keyboard() {
if(!is_touch_enabled())
return;
@@ -88,6 +118,7 @@ namespace QuickMedia {
return qm_enable_touch;
}
+ // TODO: Find a better way to detect this. This will return true on ubuntu when running gnome in x11 mode
bool is_running_wayland() {
if(wayland_display_set)
return wayland_display;