aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-16 02:35:49 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-16 02:35:49 +0200
commit8574d6c7da09f5d5929df8ff8c35cb4d82389459 (patch)
tree0ff6f173a199db293a1223a6efb3f21dc188a3ef /src
parentc35d035e22822515545edc2587d0d29871fad01c (diff)
Scale roundness with dpi, use XGetDefault instead of x db
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp4
-rw-r--r--src/Config.cpp17
-rw-r--r--src/Entry.cpp2
-rw-r--r--src/QuickMedia.cpp2
-rw-r--r--src/SearchBar.cpp2
-rw-r--r--src/Tabs.cpp2
-rw-r--r--src/gui/Button.cpp3
7 files changed, 11 insertions, 21 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index a8a1966..d4b6c5c 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -108,8 +108,8 @@ namespace QuickMedia {
num_visible_items(0),
top_cut_off(false),
bottom_cut_off(false),
- item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().selected_color, rounded_rectangle_shader),
- reaction_background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().shade_color, rounded_rectangle_shader),
+ item_background(sf::Vector2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().selected_color, rounded_rectangle_shader),
+ reaction_background(sf::Vector2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().shade_color, rounded_rectangle_shader),
rounded_rectangle_shader(rounded_rectangle_shader),
rounded_rectangle_mask_shader(rounded_rectangle_mask_shader)
{
diff --git a/src/Config.cpp b/src/Config.cpp
index 9c67723..146527a 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -3,7 +3,6 @@
#include <json/value.h>
#include <assert.h>
#include <X11/Xlib.h>
-#include <X11/Xresource.h>
namespace QuickMedia {
static bool config_initialized = false;
@@ -22,19 +21,9 @@ namespace QuickMedia {
return xft_dpi;
}
- XrmInitialize();
-
- char *resource_manager = XResourceManagerString(display);
- if(resource_manager) {
- XrmDatabase db = XrmGetStringDatabase(resource_manager);
- if(db) {
- char *type = nullptr;
- XrmValue val;
- if(XrmGetResource(db, "Xft.dpi", "*", &type, &val) && type && strcmp(type, "String") == 0)
- xft_dpi = strtol(val.addr, nullptr, 10);
- XrmDestroyDatabase(db);
- }
- }
+ char *dpi = XGetDefault(display, "Xft", "dpi");
+ if(dpi)
+ xft_dpi = strtol(dpi, nullptr, 10);
XCloseDisplay(display);
return xft_dpi;
diff --git a/src/Entry.cpp b/src/Entry.cpp
index 8f63945..f0c02fd 100644
--- a/src/Entry.cpp
+++ b/src/Entry.cpp
@@ -18,7 +18,7 @@ namespace QuickMedia {
draw_background(true),
text("", false, std::floor(get_config().input.font_size * get_config().scale * get_config().font_scale), 0.0f),
width(0.0f),
- background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().selected_color, rounded_rectangle_shader),
+ background(sf::Vector2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().selected_color, rounded_rectangle_shader),
placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(get_config().input.font_size * get_config().scale * get_config().font_scale)),
mouse_left_inside(false)
{
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 03e67be..4fd76c5 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -4534,7 +4534,7 @@ namespace QuickMedia {
SearchBar *inputs[num_inputs] = { &login_input, &password_input, &homeserver_input };
int focused_input = 0;
- RoundedRectangle background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().shade_color, &rounded_rectangle_shader);
+ RoundedRectangle background(sf::Vector2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().shade_color, &rounded_rectangle_shader);
auto text_submit_callback = [this, inputs](const sf::String&) {
for(int i = 0; i < num_inputs; ++i) {
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index 2a6b089..0a7254b 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -25,7 +25,7 @@ namespace QuickMedia {
text_autosearch_delay(50),
caret_visible(true),
text(placeholder, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(get_config().search.font_size * get_config().scale * get_config().font_scale)),
- background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().selected_color, rounded_rectangle_shader),
+ background(sf::Vector2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().selected_color, rounded_rectangle_shader),
placeholder_str(placeholder),
show_placeholder(true),
updated_search(false),
diff --git a/src/Tabs.cpp b/src/Tabs.cpp
index 059a8d8..4605f2c 100644
--- a/src/Tabs.cpp
+++ b/src/Tabs.cpp
@@ -24,7 +24,7 @@ namespace QuickMedia {
return tab_height + std::floor(10.0f * get_config().scale);
}
- Tabs::Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color) : background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().selected_color, rounded_rectangle_shader), shade_color(shade_color) {
+ Tabs::Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color) : background(sf::Vector2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().selected_color, rounded_rectangle_shader), shade_color(shade_color) {
shade.setFillColor(shade_color);
}
diff --git a/src/gui/Button.cpp b/src/gui/Button.cpp
index 63850d5..e44843d 100644
--- a/src/gui/Button.cpp
+++ b/src/gui/Button.cpp
@@ -1,5 +1,6 @@
#include "../../include/gui/Button.hpp"
#include "../../include/Theme.hpp"
+#include "../../include/Config.hpp"
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Window/Event.hpp>
#include <cmath>
@@ -9,7 +10,7 @@ namespace QuickMedia {
Button::Button(const std::string &label, sf::Font *font, unsigned int character_size, float width, sf::Shader *rounded_rectangle_shader, float scale) :
label(label, *font, character_size * scale),
- background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_theme().shade_color, rounded_rectangle_shader),
+ background(sf::Vector2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().shade_color, rounded_rectangle_shader),
scale(scale)
{
background.set_size(sf::Vector2f(std::floor(width * scale), get_height()));