mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
Squashed commit of the following:
commit990d86d481Author: bbedward <bbedward@gmail.com> Date: Sat Jul 18 10:43:22 2026 -0400 flake: update-common commit526cb157fdAuthor: bbedward <bbedward@gmail.com> Date: Thu Jul 16 17:56:40 2026 -0400 i18n: update sync scrirpt for dank-qml-common commit92ba96d9f9Author: bbedward <bbedward@gmail.com> Date: Thu Jul 16 09:24:37 2026 -0400 qs: integrate with dank-qml-common
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
#version 450
|
||||
|
||||
// Standalone rounded rect with border and M3 elevation shadow as one SDF.
|
||||
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
float widthPx;
|
||||
float heightPx;
|
||||
float borderWidth;
|
||||
vec4 rectPx; // rounded rect in item px: x, y, w, h
|
||||
vec4 cornerRadius; // topLeft, topRight, bottomRight, bottomLeft
|
||||
vec4 fillColor; // straight (non-premultiplied) rgba
|
||||
vec4 borderColor; // straight rgba
|
||||
vec4 shadowColor; // straight rgba; a = 0 disables both shadow terms
|
||||
vec4 shadowParam; // key: x = blur px, y = spread px, z,w = offset px
|
||||
vec4 ambientParam; // ambient: x = blur px, y = spread px, z = alpha
|
||||
} ubuf;
|
||||
|
||||
float sdRoundBox4(vec2 p, vec2 c, vec2 hs, vec4 r) {
|
||||
p -= c;
|
||||
float rr = (p.x >= 0.0) ? (p.y >= 0.0 ? r.z : r.y) : (p.y >= 0.0 ? r.w : r.x);
|
||||
rr = min(rr, min(hs.x, hs.y));
|
||||
vec2 q = abs(p) - hs + rr;
|
||||
return min(max(q.x, q.y), 0.0) + length(max(q, vec2(0.0))) - rr;
|
||||
}
|
||||
|
||||
float rectDist(vec2 px) {
|
||||
vec2 hs = ubuf.rectPx.zw * 0.5;
|
||||
return sdRoundBox4(px, ubuf.rectPx.xy + hs, hs, ubuf.cornerRadius);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 px = qt_TexCoord0 * vec2(ubuf.widthPx, ubuf.heightPx);
|
||||
float d = rectDist(px);
|
||||
float fw = max(fwidth(d), 1e-4);
|
||||
float cov = 1.0 - smoothstep(-fw, fw, d);
|
||||
float covInner = 1.0 - smoothstep(-fw, fw, d + ubuf.borderWidth);
|
||||
vec4 col = vec4(ubuf.fillColor.rgb, 1.0) * (ubuf.fillColor.a * covInner)
|
||||
+ vec4(ubuf.borderColor.rgb, 1.0) * (ubuf.borderColor.a * max(0.0, cov - covInner));
|
||||
if (ubuf.shadowColor.a > 0.0) {
|
||||
float dk = rectDist(px - ubuf.shadowParam.zw) - ubuf.shadowParam.y;
|
||||
float bk = max(ubuf.shadowParam.x, fw);
|
||||
float covK = 1.0 - smoothstep(-bk, bk, dk);
|
||||
float ba = max(ubuf.ambientParam.x, fw);
|
||||
float covA = 1.0 - smoothstep(-ba, ba, d - ubuf.ambientParam.y);
|
||||
float sh = 1.0 - (1.0 - covK * ubuf.shadowColor.a) * (1.0 - covA * ubuf.ambientParam.z);
|
||||
col += vec4(ubuf.shadowColor.rgb, 1.0) * (sh * (1.0 - cov));
|
||||
}
|
||||
fragColor = col * ubuf.qt_Opacity;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
float widthPx;
|
||||
float heightPx;
|
||||
float cornerRadiusPx;
|
||||
float rippleCenterX;
|
||||
float rippleCenterY;
|
||||
float rippleRadius;
|
||||
float rippleOpacity;
|
||||
float offsetX;
|
||||
float offsetY;
|
||||
float parentWidth;
|
||||
float parentHeight;
|
||||
vec4 rippleCol;
|
||||
} ubuf;
|
||||
|
||||
float sdRoundRect(vec2 p, vec2 b, float r) {
|
||||
vec2 q = abs(p) - (b - vec2(r));
|
||||
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
|
||||
}
|
||||
|
||||
void main() {
|
||||
if (ubuf.rippleOpacity <= 0.0 || ubuf.rippleRadius <= 0.0) {
|
||||
fragColor = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 px = qt_TexCoord0 * vec2(ubuf.widthPx, ubuf.heightPx) + vec2(ubuf.offsetX, ubuf.offsetY);
|
||||
|
||||
float circleD = length(px - vec2(ubuf.rippleCenterX, ubuf.rippleCenterY)) - ubuf.rippleRadius;
|
||||
float aaCircle = max(fwidth(circleD), 0.001);
|
||||
float circleMask = 1.0 - smoothstep(-aaCircle, aaCircle, circleD);
|
||||
if (circleMask <= 0.0) {
|
||||
fragColor = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
float rrMask = 1.0;
|
||||
if (ubuf.cornerRadiusPx > 0.0) {
|
||||
vec2 halfSize = vec2(ubuf.parentWidth, ubuf.parentHeight) * 0.5;
|
||||
float r = clamp(ubuf.cornerRadiusPx, 0.0, min(halfSize.x, halfSize.y));
|
||||
float rrD = sdRoundRect(px - halfSize, halfSize, r);
|
||||
float aaRR = max(fwidth(rrD), 0.001);
|
||||
rrMask = 1.0 - smoothstep(-aaRR, aaRR, rrD);
|
||||
}
|
||||
|
||||
float mask = circleMask * rrMask;
|
||||
if (mask <= 0.0) {
|
||||
fragColor = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
float a = ubuf.rippleCol.a * ubuf.rippleOpacity * mask * ubuf.qt_Opacity;
|
||||
fragColor = vec4(ubuf.rippleCol.rgb * a, a);
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
float widthPx;
|
||||
float heightPx;
|
||||
float value;
|
||||
float actualValue;
|
||||
float phase;
|
||||
float ampPx;
|
||||
float wavelengthPx;
|
||||
float lineWidthPx;
|
||||
float showActual;
|
||||
vec4 fillColor;
|
||||
vec4 trackColor;
|
||||
vec4 playheadColor;
|
||||
vec4 actualColor;
|
||||
} ubuf;
|
||||
|
||||
const float TAU = 6.28318530718;
|
||||
const float AA = 0.75; // pixel-space antialias band
|
||||
|
||||
// Signed distance to a rounded box centered at the origin.
|
||||
float sdRoundBar(vec2 p, vec2 halfSize, float r) {
|
||||
vec2 q = abs(p) - halfSize + vec2(r);
|
||||
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
|
||||
}
|
||||
|
||||
// Composite a straight-alpha color over a premultiplied accumulator.
|
||||
vec4 blendOver(vec4 dst, vec3 rgb, float a) {
|
||||
return vec4(rgb * a + dst.rgb * (1.0 - a), a + dst.a * (1.0 - a));
|
||||
}
|
||||
|
||||
void main() {
|
||||
float w = ubuf.widthPx;
|
||||
float h = ubuf.heightPx;
|
||||
vec2 px = vec2(qt_TexCoord0.x * w, qt_TexCoord0.y * h);
|
||||
|
||||
float mid = h * 0.5;
|
||||
float halfW = ubuf.lineWidthPx * 0.5;
|
||||
float k = TAU / max(ubuf.wavelengthPx, 1e-3);
|
||||
|
||||
float playX = clamp(ubuf.value, 0.0, 1.0) * w;
|
||||
float actualX = clamp(ubuf.actualValue, 0.0, 1.0) * w;
|
||||
bool seeking = ubuf.showActual > 0.5;
|
||||
|
||||
float loX = min(playX, actualX);
|
||||
float hiX = max(playX, actualX);
|
||||
float fillEnd = seeking ? loX : playX; // filled progress ends here
|
||||
float actStart = seeking ? loX : playX; // seek-preview segment
|
||||
float actEnd = seeking ? hiX : playX;
|
||||
float trackStart = seeking ? hiX : playX; // unplayed remainder
|
||||
|
||||
// Perpendicular distance to the animated sine stroke.
|
||||
float ang = k * px.x + ubuf.phase;
|
||||
float wy = mid + ubuf.ampPx * sin(ang);
|
||||
float slope = ubuf.ampPx * k * cos(ang);
|
||||
float dWave = abs(px.y - wy) / sqrt(1.0 + slope * slope);
|
||||
float aaW = AA;
|
||||
float waveStroke = 1.0 - smoothstep(halfW - aaW, halfW + aaW, dWave);
|
||||
|
||||
// Straight remainder line.
|
||||
float dLine = abs(px.y - mid);
|
||||
float aaL = AA;
|
||||
float lineStroke = 1.0 - smoothstep(halfW - aaL, halfW + aaL, dLine);
|
||||
|
||||
vec4 col = vec4(0.0);
|
||||
|
||||
// 1. Track (unplayed remainder), to the right of the progress head.
|
||||
{
|
||||
float m = lineStroke * step(trackStart, px.x);
|
||||
col = blendOver(col, ubuf.trackColor.rgb, ubuf.trackColor.a * m);
|
||||
}
|
||||
|
||||
// 2. Seek-preview segment (only while seeking).
|
||||
if (seeking) {
|
||||
float m = waveStroke * step(actStart, px.x) * step(px.x, actEnd);
|
||||
col = blendOver(col, ubuf.actualColor.rgb, ubuf.actualColor.a * m);
|
||||
}
|
||||
|
||||
// 3. Filled progress wave.
|
||||
{
|
||||
float m = waveStroke * step(halfW, px.x) * step(px.x, fillEnd);
|
||||
// Rounded start cap.
|
||||
float capS = length(px - vec2(halfW, mid + ubuf.ampPx * sin(k * halfW + ubuf.phase))) - halfW;
|
||||
float capM = 1.0 - smoothstep(-aaW, aaW, capS);
|
||||
m = max(m, capM * step(halfW - 1.0, px.x));
|
||||
col = blendOver(col, ubuf.fillColor.rgb, ubuf.fillColor.a * m);
|
||||
}
|
||||
|
||||
// 4. Actual-position marker (only while seeking).
|
||||
if (seeking) {
|
||||
float amH = max(ubuf.lineWidthPx + 4.0, 10.0);
|
||||
float d = sdRoundBar(px - vec2(actualX, mid), vec2(1.0, amH * 0.5), 1.0);
|
||||
float aa = AA;
|
||||
float m = 1.0 - smoothstep(-aa, aa, d);
|
||||
col = blendOver(col, ubuf.actualColor.rgb, ubuf.actualColor.a * m);
|
||||
}
|
||||
|
||||
// 5. Playhead pill (on top).
|
||||
{
|
||||
float phW = 3.5;
|
||||
float phH = max(ubuf.lineWidthPx + 12.0, 16.0);
|
||||
float d = sdRoundBar(px - vec2(playX, mid), vec2(phW * 0.5, phH * 0.5), phW * 0.5);
|
||||
float aa = AA;
|
||||
float m = 1.0 - smoothstep(-aa, aa, d);
|
||||
col = blendOver(col, ubuf.playheadColor.rgb, ubuf.playheadColor.a * m);
|
||||
}
|
||||
|
||||
fragColor = col * ubuf.qt_Opacity;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user