all: remove traditional i3 titlebars, add corner rounding
This commit is contained in:
parent
e1928863d9
commit
a41dbae899
52 changed files with 1866 additions and 1047 deletions
12
src/gfx_apis/vulkan/shaders/legacy/rounded_fill.common.glsl
Normal file
12
src/gfx_apis/vulkan/shaders/legacy/rounded_fill.common.glsl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
layout(push_constant, std430) uniform Data {
|
||||
layout(offset = 0) vec2 pos[4];
|
||||
layout(offset = 32) vec4 color;
|
||||
layout(offset = 48) float size_x;
|
||||
layout(offset = 52) float size_y;
|
||||
layout(offset = 56) float corner_radius_tl;
|
||||
layout(offset = 60) float corner_radius_tr;
|
||||
layout(offset = 64) float corner_radius_br;
|
||||
layout(offset = 68) float corner_radius_bl;
|
||||
layout(offset = 72) float border_width;
|
||||
layout(offset = 76) float scale;
|
||||
} data;
|
||||
48
src/gfx_apis/vulkan/shaders/legacy/rounded_fill.frag
Normal file
48
src/gfx_apis/vulkan/shaders/legacy/rounded_fill.frag
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#version 450
|
||||
|
||||
#include "../frag_spec_const.glsl"
|
||||
#include "rounded_fill.common.glsl"
|
||||
|
||||
layout(location = 0) in vec2 geo_pos;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
float rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) {
|
||||
if (coords.x < 0.0 || coords.y < 0.0 || coords.x > size.x || coords.y > size.y) {
|
||||
return 0.0;
|
||||
}
|
||||
vec2 center;
|
||||
float radius;
|
||||
if (coords.x < corner_radius.x && coords.y < corner_radius.x) {
|
||||
radius = corner_radius.x;
|
||||
center = vec2(radius, radius);
|
||||
} else if (coords.x > size.x - corner_radius.y && coords.y < corner_radius.y) {
|
||||
radius = corner_radius.y;
|
||||
center = vec2(size.x - radius, radius);
|
||||
} else if (coords.x > size.x - corner_radius.z && coords.y > size.y - corner_radius.z) {
|
||||
radius = corner_radius.z;
|
||||
center = vec2(size.x - radius, size.y - radius);
|
||||
} else if (coords.x < corner_radius.w && coords.y > size.y - corner_radius.w) {
|
||||
radius = corner_radius.w;
|
||||
center = vec2(radius, size.y - radius);
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
float half_px = 0.5 / data.scale;
|
||||
float dist = distance(coords, center);
|
||||
return 1.0 - smoothstep(radius - half_px, radius + half_px, dist);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 size = vec2(data.size_x, data.size_y);
|
||||
vec4 corner_radius = vec4(data.corner_radius_tl, data.corner_radius_tr, data.corner_radius_br, data.corner_radius_bl);
|
||||
float outer_alpha = rounding_alpha(geo_pos, size, corner_radius);
|
||||
float alpha = outer_alpha;
|
||||
if (data.border_width > 0.0) {
|
||||
vec2 inner_coords = geo_pos - vec2(data.border_width);
|
||||
vec2 inner_size = size - vec2(2.0 * data.border_width);
|
||||
vec4 inner_radius = max(corner_radius - vec4(data.border_width), vec4(0.0));
|
||||
float inner_alpha = rounding_alpha(inner_coords, inner_size, inner_radius);
|
||||
alpha = outer_alpha * (1.0 - inner_alpha);
|
||||
}
|
||||
out_color = data.color * alpha;
|
||||
}
|
||||
17
src/gfx_apis/vulkan/shaders/legacy/rounded_fill.vert
Normal file
17
src/gfx_apis/vulkan/shaders/legacy/rounded_fill.vert
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 450
|
||||
|
||||
#include "rounded_fill.common.glsl"
|
||||
|
||||
layout(location = 0) out vec2 geo_pos;
|
||||
|
||||
void main() {
|
||||
vec2 size = vec2(data.size_x, data.size_y);
|
||||
vec2 pos;
|
||||
switch (gl_VertexIndex) {
|
||||
case 0: pos = data.pos[0]; geo_pos = vec2(size.x, 0.0); break;
|
||||
case 1: pos = data.pos[1]; geo_pos = vec2(0.0, 0.0); break;
|
||||
case 2: pos = data.pos[2]; geo_pos = vec2(size.x, size.y); break;
|
||||
case 3: pos = data.pos[3]; geo_pos = vec2(0.0, size.y); break;
|
||||
}
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
}
|
||||
12
src/gfx_apis/vulkan/shaders/legacy/rounded_tex.common.glsl
Normal file
12
src/gfx_apis/vulkan/shaders/legacy/rounded_tex.common.glsl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
layout(push_constant, std430) uniform Data {
|
||||
layout(offset = 0) vec2 pos[4];
|
||||
layout(offset = 32) vec2 tex_pos[4];
|
||||
layout(offset = 64) float mul;
|
||||
layout(offset = 68) float size_x;
|
||||
layout(offset = 72) float size_y;
|
||||
layout(offset = 76) float corner_radius_tl;
|
||||
layout(offset = 80) float corner_radius_tr;
|
||||
layout(offset = 84) float corner_radius_br;
|
||||
layout(offset = 88) float corner_radius_bl;
|
||||
layout(offset = 92) float scale;
|
||||
} data;
|
||||
51
src/gfx_apis/vulkan/shaders/legacy/rounded_tex.frag
Normal file
51
src/gfx_apis/vulkan/shaders/legacy/rounded_tex.frag
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#version 450
|
||||
|
||||
#include "../frag_spec_const.glsl"
|
||||
#include "rounded_tex.common.glsl"
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tex;
|
||||
layout(location = 0) in vec2 tex_pos;
|
||||
layout(location = 1) in vec2 geo_pos;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
float rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) {
|
||||
if (coords.x < 0.0 || coords.y < 0.0 || coords.x > size.x || coords.y > size.y) {
|
||||
return 0.0;
|
||||
}
|
||||
vec2 center;
|
||||
float radius;
|
||||
if (coords.x < corner_radius.x && coords.y < corner_radius.x) {
|
||||
radius = corner_radius.x;
|
||||
center = vec2(radius, radius);
|
||||
} else if (coords.x > size.x - corner_radius.y && coords.y < corner_radius.y) {
|
||||
radius = corner_radius.y;
|
||||
center = vec2(size.x - radius, radius);
|
||||
} else if (coords.x > size.x - corner_radius.z && coords.y > size.y - corner_radius.z) {
|
||||
radius = corner_radius.z;
|
||||
center = vec2(size.x - radius, size.y - radius);
|
||||
} else if (coords.x < corner_radius.w && coords.y > size.y - corner_radius.w) {
|
||||
radius = corner_radius.w;
|
||||
center = vec2(radius, size.y - radius);
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
float half_px = 0.5 / data.scale;
|
||||
float dist = distance(coords, center);
|
||||
return 1.0 - smoothstep(radius - half_px, radius + half_px, dist);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 size = vec2(data.size_x, data.size_y);
|
||||
vec4 corner_radius = vec4(data.corner_radius_tl, data.corner_radius_tr, data.corner_radius_br, data.corner_radius_bl);
|
||||
vec4 c = textureLod(tex, tex_pos, 0);
|
||||
if (has_alpha_multiplier) {
|
||||
if (src_has_alpha) {
|
||||
c *= data.mul;
|
||||
} else {
|
||||
c = vec4(c.rgb * data.mul, data.mul);
|
||||
}
|
||||
}
|
||||
float ra = rounding_alpha(geo_pos, size, corner_radius);
|
||||
c *= ra;
|
||||
out_color = c;
|
||||
}
|
||||
18
src/gfx_apis/vulkan/shaders/legacy/rounded_tex.vert
Normal file
18
src/gfx_apis/vulkan/shaders/legacy/rounded_tex.vert
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#version 450
|
||||
|
||||
#include "rounded_tex.common.glsl"
|
||||
|
||||
layout(location = 0) out vec2 tex_pos;
|
||||
layout(location = 1) out vec2 geo_pos;
|
||||
|
||||
void main() {
|
||||
vec2 size = vec2(data.size_x, data.size_y);
|
||||
vec2 pos;
|
||||
switch (gl_VertexIndex) {
|
||||
case 0: pos = data.pos[0]; tex_pos = data.tex_pos[0]; geo_pos = vec2(size.x, 0.0); break;
|
||||
case 1: pos = data.pos[1]; tex_pos = data.tex_pos[1]; geo_pos = vec2(0.0, 0.0); break;
|
||||
case 2: pos = data.pos[2]; tex_pos = data.tex_pos[2]; geo_pos = vec2(size.x, size.y); break;
|
||||
case 3: pos = data.pos[3]; tex_pos = data.tex_pos[3]; geo_pos = vec2(0.0, size.y); break;
|
||||
}
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue