aboutsummaryrefslogtreecommitdiff
path: root/src/Body.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-03 01:26:14 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-03 01:26:14 +0200
commit6fbd76171b1f8f357524de20009380a93ca9bbf9 (patch)
treec6ac00d9ad26151f6357bc9b0823cc4b93481ccd /src/Body.cpp
parent8c4e3217bf3e3c675f181c34f79448ba036dfcaf (diff)
Add QM_FONT_SCALE environment variable to set font scale. Also add QM_SCALE to not have to rely on GDK_SCALE or xft.dpi
Diffstat (limited to 'src/Body.cpp')
-rw-r--r--src/Body.cpp94
1 files changed, 47 insertions, 47 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) {