aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-21 18:19:10 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-21 18:19:10 +0200
commit9d2fbadd55a1c7c89660fcec430a945867ded527 (patch)
tree8293964dcf68e6d536ba0e18caa8f8ac50f5708c
parent933ceeabb339cdf0583a8687528941593381a268 (diff)
Add theme option to disable rounded rectangle drop shadow
-rw-r--r--include/Theme.hpp2
-rw-r--r--shaders/rounded_rectangle_no_shadow.glsl24
-rw-r--r--src/QuickMedia.cpp13
-rw-r--r--src/Theme.cpp1
4 files changed, 37 insertions, 3 deletions
diff --git a/include/Theme.hpp b/include/Theme.hpp
index e466931..653cfe9 100644
--- a/include/Theme.hpp
+++ b/include/Theme.hpp
@@ -33,6 +33,8 @@ namespace QuickMedia {
sf::Color arrow_color;
sf::Color url_text_color;
sf::Color loading_page_color;
+
+ bool blur_enabled;
};
void init_themes();
diff --git a/shaders/rounded_rectangle_no_shadow.glsl b/shaders/rounded_rectangle_no_shadow.glsl
new file mode 100644
index 0000000..4fc32cf
--- /dev/null
+++ b/shaders/rounded_rectangle_no_shadow.glsl
@@ -0,0 +1,24 @@
+uniform float radius;
+uniform vec2 band_pos;
+uniform vec2 band_size;
+uniform vec4 band_color;
+uniform vec2 resolution;
+
+float rounded_rect(vec2 coord, vec2 size, float r) {
+ return length(max(abs(coord) - size+r, 0.0)) - r;
+}
+
+void main() {
+ vec2 shadow_offset = vec2(20.0, 20.0);
+ vec2 uv = gl_TexCoord[0].xy * resolution;
+ vec2 center = resolution * 0.5;
+ vec2 size = (resolution - shadow_offset * 2.0) * 0.5;
+
+ float rect_dist = rounded_rect(uv - center, size, radius);
+ float a = 1.0 - smoothstep(0.0, 2.0, rect_dist);
+ // same as: if(uv.x >= band_pos.x && uv.x <= band_pos.x + band_size.x && uv.y >= band_pos.y && uv.y <= band_pos.y + band_size.y)
+ vec2 band_blend = step(band_pos, uv) - step(band_pos + band_size, uv);
+ vec4 front_color = mix(gl_Color, band_color, band_blend.x*band_blend.y);
+ front_color.a *= a;
+ gl_FragColor = front_color;
+} \ No newline at end of file
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index bcd9a53..e2d1d8c 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -666,9 +666,16 @@ namespace QuickMedia {
abort();
}
- if(!rounded_rectangle_shader.loadFromFile(resources_root + "shaders/rounded_rectangle.glsl", sf::Shader::Type::Fragment)) {
- show_notification("QuickMedia", "Failed to load " + resources_root + "/shaders/rounded_rectangle.glsl", Urgency::CRITICAL);
- abort();
+ if(get_current_theme().blur_enabled) {
+ if(!rounded_rectangle_shader.loadFromFile(resources_root + "shaders/rounded_rectangle.glsl", sf::Shader::Type::Fragment)) {
+ show_notification("QuickMedia", "Failed to load " + resources_root + "/shaders/rounded_rectangle.glsl", Urgency::CRITICAL);
+ abort();
+ }
+ } else {
+ if(!rounded_rectangle_shader.loadFromFile(resources_root + "shaders/rounded_rectangle_no_shadow.glsl", sf::Shader::Type::Fragment)) {
+ show_notification("QuickMedia", "Failed to load " + resources_root + "/shaders/rounded_rectangle_no_shadow.glsl", Urgency::CRITICAL);
+ abort();
+ }
}
if(!rounded_rectangle_mask_shader.loadFromFile(resources_root + "shaders/rounded_rectangle_mask.glsl", sf::Shader::Type::Fragment)) {
diff --git a/src/Theme.cpp b/src/Theme.cpp
index 1f4feca..6616721 100644
--- a/src/Theme.cpp
+++ b/src/Theme.cpp
@@ -32,6 +32,7 @@ namespace QuickMedia {
themes[Theme::THEME_DARK].arrow_color = sf::Color(255, 255, 255, 175);
themes[Theme::THEME_DARK].url_text_color = sf::Color(35, 140, 245);
themes[Theme::THEME_DARK].loading_page_color = sf::Color(175, 180, 188);
+ themes[Theme::THEME_DARK].blur_enabled = true;
}
void init_themes() {