@lightningtv/solid 3.0.7-0 → 3.0.7-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/intrinsicTypes.d.ts +2 -0
- package/dist/src/core/shaders.js +2 -272
- package/dist/src/core/shaders.js.map +1 -1
- package/dist/src/primitives/borderBox.jsx +30 -27
- package/dist/src/primitives/borderBox.jsx.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/core/intrinsicTypes.ts +2 -0
- package/src/core/shaders.ts +4 -291
- package/src/primitives/borderBox.tsx +32 -37
- package/dist/src/shaders/Rounded.d.ts +0 -7
- package/dist/src/shaders/Rounded.js +0 -88
- package/dist/src/shaders/Rounded.js.map +0 -1
- package/dist/src/shaders/RoundedWithBorder.d.ts +0 -3
- package/dist/src/shaders/RoundedWithBorder.js +0 -217
- package/dist/src/shaders/RoundedWithBorder.js.map +0 -1
- package/dist/src/shaders/index.d.ts +0 -4
- package/dist/src/shaders/index.js +0 -5
- package/dist/src/shaders/index.js.map +0 -1
- package/dist/src/shaders/templates/RoundedTemplate.d.ts +0 -12
- package/dist/src/shaders/templates/RoundedTemplate.js +0 -48
- package/dist/src/shaders/templates/RoundedTemplate.js.map +0 -1
- package/dist/src/shaders/templates/RoundedWithBorderTemplate.d.ts +0 -20
- package/dist/src/shaders/templates/RoundedWithBorderTemplate.js +0 -93
- package/dist/src/shaders/templates/RoundedWithBorderTemplate.js.map +0 -1
- package/dist/src/shaders/utils.d.ts +0 -3
- package/dist/src/shaders/utils.js +0 -31
- package/dist/src/shaders/utils.js.map +0 -1
- package/src/shaders/Rounded.ts +0 -100
- package/src/shaders/RoundedWithBorder.ts +0 -245
- package/src/shaders/index.ts +0 -4
- package/src/shaders/templates/RoundedTemplate.ts +0 -57
- package/src/shaders/templates/RoundedWithBorderTemplate.ts +0 -110
- package/src/shaders/utils.ts +0 -44
package/src/core/shaders.ts
CHANGED
|
@@ -73,6 +73,9 @@ export const defaultShaderRadialGradient: ShaderRadialGradient =
|
|
|
73
73
|
export const defaultShaderLinearGradient: ShaderLinearGradient =
|
|
74
74
|
lngr_shaders.LinearGradient;
|
|
75
75
|
|
|
76
|
+
export const defaultShaderRoundedWithBorder =
|
|
77
|
+
lngr_shaders.RoundedWithBorder as ShaderRoundedWithBorder;
|
|
78
|
+
|
|
76
79
|
function calcFactoredRadiusArray(
|
|
77
80
|
radius: Vec4,
|
|
78
81
|
width: number,
|
|
@@ -123,6 +126,7 @@ const roundedWithBorderProps: lngr.ShaderProps<ShaderRoundedWithBorderProps> = {
|
|
|
123
126
|
return toValidVec4(value);
|
|
124
127
|
},
|
|
125
128
|
},
|
|
129
|
+
'border-align': 0,
|
|
126
130
|
'top-left': {
|
|
127
131
|
default: 0,
|
|
128
132
|
set(value, props) {
|
|
@@ -206,297 +210,6 @@ const roundedWithBorderProps: lngr.ShaderProps<ShaderRoundedWithBorderProps> = {
|
|
|
206
210
|
'border-inset': true,
|
|
207
211
|
};
|
|
208
212
|
|
|
209
|
-
export const defaultShaderRoundedWithBorder: ShaderRoundedWithBorder = {
|
|
210
|
-
props: roundedWithBorderProps,
|
|
211
|
-
canBatch: () => false,
|
|
212
|
-
update(node) {
|
|
213
|
-
let props = this.props!;
|
|
214
|
-
let borderWidth = props['border-w'] as Vec4;
|
|
215
|
-
let borderGap = props['border-gap'];
|
|
216
|
-
let inset = props['border-inset'];
|
|
217
|
-
|
|
218
|
-
let [b_t, b_r, b_b, b_l] = borderWidth;
|
|
219
|
-
|
|
220
|
-
this.uniformRGBA('u_borderColor', props['border-color']);
|
|
221
|
-
this.uniform4fa('u_border', borderWidth);
|
|
222
|
-
this.uniform1f('u_gap', borderGap);
|
|
223
|
-
this.uniform1i('u_inset', inset ? 1 : 0);
|
|
224
|
-
|
|
225
|
-
// Check if border is zero (no border widths)
|
|
226
|
-
let borderZero = b_t === 0 && b_r === 0 && b_b === 0 && b_l === 0;
|
|
227
|
-
this.uniform1i('u_borderZero', borderZero ? 1 : 0);
|
|
228
|
-
|
|
229
|
-
let origWidth = node.w;
|
|
230
|
-
let origHeight = node.h;
|
|
231
|
-
this.uniform2f('u_dimensions_orig', origWidth, origHeight);
|
|
232
|
-
|
|
233
|
-
let finalWidth = origWidth;
|
|
234
|
-
let finalHeight = origHeight;
|
|
235
|
-
if (!inset) {
|
|
236
|
-
// For outside borders, expand dimensions
|
|
237
|
-
finalWidth = origWidth + b_l + b_r + borderGap * 2;
|
|
238
|
-
finalHeight = origHeight + b_t + b_b + borderGap * 2;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// u_dimensions for the shader's SDF functions
|
|
242
|
-
this.uniform2f('u_dimensions', finalWidth, finalHeight);
|
|
243
|
-
|
|
244
|
-
// The `radius` property is for the content rectangle.
|
|
245
|
-
// Factor it against the appropriate dimensions to prevent self-intersection.
|
|
246
|
-
let contentRadius = calcFactoredRadiusArray(
|
|
247
|
-
props.radius as Vec4,
|
|
248
|
-
origWidth,
|
|
249
|
-
origHeight,
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
// Calculate the appropriate radius for the shader based on inset mode
|
|
253
|
-
let finalRadius = contentRadius;
|
|
254
|
-
if (!inset) {
|
|
255
|
-
// For each corner, the total radius is content radius + gap + border thickness.
|
|
256
|
-
// Border thickness at a corner is approximated as the max of the two adjacent border sides.
|
|
257
|
-
let outerRadius: Vec4 = [
|
|
258
|
-
contentRadius[0] + borderGap + Math.max(b_t, b_l), // top-left
|
|
259
|
-
contentRadius[1] + borderGap + Math.max(b_t, b_r), // top-right
|
|
260
|
-
contentRadius[2] + borderGap + Math.max(b_b, b_r), // bottom-right
|
|
261
|
-
contentRadius[3] + borderGap + Math.max(b_b, b_l), // bottom-left
|
|
262
|
-
];
|
|
263
|
-
calcFactoredRadiusArray(
|
|
264
|
-
outerRadius,
|
|
265
|
-
finalWidth,
|
|
266
|
-
finalHeight,
|
|
267
|
-
finalRadius,
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
this.uniform4fa('u_radius', finalRadius);
|
|
272
|
-
},
|
|
273
|
-
vertex: /*glsl*/ `
|
|
274
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
275
|
-
precision highp float;
|
|
276
|
-
# else
|
|
277
|
-
precision mediump float;
|
|
278
|
-
# endif
|
|
279
|
-
|
|
280
|
-
/* Passed by lightning renderer */
|
|
281
|
-
attribute vec2 a_position;
|
|
282
|
-
attribute vec2 a_textureCoords;
|
|
283
|
-
attribute vec4 a_color;
|
|
284
|
-
attribute vec2 a_nodeCoords;
|
|
285
|
-
|
|
286
|
-
uniform vec2 u_resolution;
|
|
287
|
-
uniform float u_pixelRatio;
|
|
288
|
-
|
|
289
|
-
/* Passed by shader setup */
|
|
290
|
-
uniform vec2 u_dimensions;
|
|
291
|
-
uniform vec2 u_dimensions_orig;
|
|
292
|
-
uniform vec4 u_radius;
|
|
293
|
-
uniform vec4 u_border;
|
|
294
|
-
uniform float u_gap;
|
|
295
|
-
uniform bool u_inset;
|
|
296
|
-
uniform bool u_borderZero;
|
|
297
|
-
|
|
298
|
-
varying vec4 v_color;
|
|
299
|
-
varying vec2 v_texcoords;
|
|
300
|
-
varying vec2 v_nodeCoords;
|
|
301
|
-
varying vec4 v_borderEndRadius;
|
|
302
|
-
varying vec2 v_borderEndSize;
|
|
303
|
-
|
|
304
|
-
varying vec4 v_innerRadius;
|
|
305
|
-
varying vec2 v_innerSize;
|
|
306
|
-
varying vec2 v_halfDimensions;
|
|
307
|
-
|
|
308
|
-
void main() {
|
|
309
|
-
vec2 screen_space = vec2(2.0 / u_resolution.x, -2.0 / u_resolution.y);
|
|
310
|
-
|
|
311
|
-
v_color = a_color;
|
|
312
|
-
v_nodeCoords = a_nodeCoords;
|
|
313
|
-
|
|
314
|
-
float b_t = u_border.x;
|
|
315
|
-
float b_r = u_border.y;
|
|
316
|
-
float b_b = u_border.z;
|
|
317
|
-
float b_l = u_border.w;
|
|
318
|
-
|
|
319
|
-
// Calculate the offset to expand/contract the quad for border and gap
|
|
320
|
-
vec2 expansion_offset = vec2(0.0);
|
|
321
|
-
if (!u_inset) {
|
|
322
|
-
// Outside border: expand the quad
|
|
323
|
-
if (a_nodeCoords.x == 0.0) { // Left edge vertex
|
|
324
|
-
expansion_offset.x = -(b_l + u_gap);
|
|
325
|
-
} else { // Right edge vertex (a_nodeCoords.x == 1.0)
|
|
326
|
-
expansion_offset.x = (b_r + u_gap);
|
|
327
|
-
}
|
|
328
|
-
if (a_nodeCoords.y == 0.0) { // Top edge vertex
|
|
329
|
-
expansion_offset.y = -(b_t + u_gap);
|
|
330
|
-
} else { // Bottom edge vertex (a_nodeCoords.y == 1.0)
|
|
331
|
-
expansion_offset.y = (b_b + u_gap);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
// For inset borders, no expansion needed - use original position
|
|
335
|
-
|
|
336
|
-
// Texture coordinate calculation
|
|
337
|
-
v_texcoords = a_textureCoords;
|
|
338
|
-
if (!u_inset) { // For outside borders, adjust texture coordinates for expansion
|
|
339
|
-
v_texcoords *= u_dimensions;
|
|
340
|
-
v_texcoords.x -= b_l + u_gap;
|
|
341
|
-
v_texcoords.y -= b_t + u_gap;
|
|
342
|
-
v_texcoords /= u_dimensions_orig;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
v_halfDimensions = u_dimensions * 0.5;
|
|
346
|
-
if (!u_borderZero) {
|
|
347
|
-
|
|
348
|
-
float gap_x2 = u_gap * 2.0;
|
|
349
|
-
|
|
350
|
-
if (u_inset) {
|
|
351
|
-
// For inset borders, flip the meaning:
|
|
352
|
-
// v_borderEndRadius/Size represents the gap area
|
|
353
|
-
// v_innerRadius/Size represents the border area
|
|
354
|
-
|
|
355
|
-
// Gap area (v_borderEnd represents gap boundary) - uniform gap
|
|
356
|
-
v_borderEndRadius = u_radius - u_gap - 0.5;
|
|
357
|
-
v_borderEndSize = (u_dimensions - gap_x2 - 1.0) * 0.5;
|
|
358
|
-
|
|
359
|
-
// Border area (v_inner represents border boundary) - individual border widths
|
|
360
|
-
v_innerRadius.x = u_radius.x - u_gap - max(b_t, b_l) - 0.5;
|
|
361
|
-
v_innerRadius.y = u_radius.y - u_gap - max(b_t, b_r) - 0.5;
|
|
362
|
-
v_innerRadius.z = u_radius.z - u_gap - max(b_b, b_r) - 0.5;
|
|
363
|
-
v_innerRadius.w = u_radius.w - u_gap - max(b_b, b_l) - 0.5;
|
|
364
|
-
|
|
365
|
-
v_innerSize = (u_dimensions - gap_x2 - vec2(b_l + b_r, b_t + b_b) - 1.0) * 0.5;
|
|
366
|
-
} else {
|
|
367
|
-
// For outside borders, calculate from expanded dimensions inward
|
|
368
|
-
v_borderEndRadius.x = u_radius.x - max(b_t, b_l) - 0.5;
|
|
369
|
-
v_borderEndRadius.y = u_radius.y - max(b_t, b_r) - 0.5;
|
|
370
|
-
v_borderEndRadius.z = u_radius.z - max(b_b, b_r) - 0.5;
|
|
371
|
-
v_borderEndRadius.w = u_radius.w - max(b_b, b_l) - 0.5;
|
|
372
|
-
|
|
373
|
-
v_borderEndSize = (u_dimensions - vec2(b_l + b_r, b_t + b_b) - 1.0) * 0.5;
|
|
374
|
-
|
|
375
|
-
v_innerRadius.x = u_radius.x - max(b_t, b_l) - u_gap - 0.5;
|
|
376
|
-
v_innerRadius.y = u_radius.y - max(b_t, b_r) - u_gap - 0.5;
|
|
377
|
-
v_innerRadius.z = u_radius.z - max(b_b, b_r) - u_gap - 0.5;
|
|
378
|
-
v_innerRadius.w = u_radius.w - max(b_b, b_l) - u_gap - 0.5;
|
|
379
|
-
|
|
380
|
-
v_innerSize.x = u_dimensions.x - (b_l + b_r) - gap_x2 - 1.0;
|
|
381
|
-
v_innerSize.y = u_dimensions.y - (b_t + b_b) - gap_x2 - 1.0;
|
|
382
|
-
v_innerSize *= 0.5;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
v_borderEndRadius = max(v_borderEndRadius, vec4(0.0));
|
|
386
|
-
v_innerRadius = max(v_innerRadius, vec4(0.0));
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
vec2 normalized = (a_position + expansion_offset) * u_pixelRatio;
|
|
390
|
-
|
|
391
|
-
gl_Position = vec4(normalized.x * screen_space.x - 1.0, normalized.y * -abs(screen_space.y) + 1.0, 0.0, 1.0);
|
|
392
|
-
gl_Position.y = -sign(screen_space.y) * gl_Position.y;
|
|
393
|
-
}
|
|
394
|
-
`,
|
|
395
|
-
fragment: /*glsl*/ `
|
|
396
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
397
|
-
precision highp float;
|
|
398
|
-
# else
|
|
399
|
-
precision mediump float;
|
|
400
|
-
# endif
|
|
401
|
-
|
|
402
|
-
/* Passed by lightning renderer */
|
|
403
|
-
uniform vec2 u_resolution;
|
|
404
|
-
uniform float u_pixelRatio;
|
|
405
|
-
uniform float u_alpha;
|
|
406
|
-
uniform vec2 u_dimensions;
|
|
407
|
-
uniform sampler2D u_texture;
|
|
408
|
-
|
|
409
|
-
/* Passed by shader setup */
|
|
410
|
-
uniform vec4 u_radius;
|
|
411
|
-
|
|
412
|
-
uniform vec4 u_border;
|
|
413
|
-
uniform vec4 u_borderColor;
|
|
414
|
-
uniform bool u_inset;
|
|
415
|
-
uniform bool u_borderZero;
|
|
416
|
-
|
|
417
|
-
varying vec4 v_borderEndRadius;
|
|
418
|
-
varying vec2 v_borderEndSize;
|
|
419
|
-
|
|
420
|
-
varying vec4 v_color;
|
|
421
|
-
varying vec2 v_texcoords;
|
|
422
|
-
varying vec2 v_nodeCoords;
|
|
423
|
-
|
|
424
|
-
varying vec2 v_halfDimensions;
|
|
425
|
-
varying vec4 v_innerRadius;
|
|
426
|
-
varying vec2 v_innerSize;
|
|
427
|
-
|
|
428
|
-
float roundedBox(vec2 p, vec2 s, vec4 r) {
|
|
429
|
-
r.xy = (p.x > 0.0) ? r.yz : r.xw;
|
|
430
|
-
r.x = (p.y > 0.0) ? r.y : r.x;
|
|
431
|
-
vec2 q = abs(p) - s + r.x;
|
|
432
|
-
return (min(max(q.x, q.y), 0.0) + length(max(q, 0.0))) - r.x;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
void main() {
|
|
436
|
-
vec4 contentTexColor = texture2D(u_texture, v_texcoords) * v_color;
|
|
437
|
-
|
|
438
|
-
vec2 boxUv = v_nodeCoords.xy * u_dimensions - v_halfDimensions;
|
|
439
|
-
float outerShapeDist = roundedBox(boxUv, v_halfDimensions, u_radius);
|
|
440
|
-
float outerShapeAlpha = 1.0 - smoothstep(0.0, 1.0, outerShapeDist); // 1 inside, 0 outside
|
|
441
|
-
|
|
442
|
-
if (u_borderZero) { // No border, effectively no gap from border logic
|
|
443
|
-
gl_FragColor = mix(vec4(0.0), contentTexColor, outerShapeAlpha) * u_alpha;
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// Adjust boxUv for non-uniform borders
|
|
448
|
-
// This adjusted UV is used for calculating distances to border-end and content shapes
|
|
449
|
-
vec2 adjustedBoxUv = boxUv;
|
|
450
|
-
vec2 borderAdjustedBoxUv = boxUv;
|
|
451
|
-
|
|
452
|
-
if (!u_inset) {
|
|
453
|
-
// For outside borders, use same adjustment for both calculations
|
|
454
|
-
adjustedBoxUv.x += (u_border.y - u_border.w) * 0.5;
|
|
455
|
-
adjustedBoxUv.y += (u_border.z - u_border.x) * 0.5;
|
|
456
|
-
borderAdjustedBoxUv = adjustedBoxUv;
|
|
457
|
-
} else {
|
|
458
|
-
// For inset borders, gap calculation uses no adjustment (uniform gap)
|
|
459
|
-
// Border calculation uses adjustment (non-uniform border)
|
|
460
|
-
borderAdjustedBoxUv.x += (u_border.y - u_border.w) * 0.5;
|
|
461
|
-
borderAdjustedBoxUv.y += (u_border.z - u_border.x) * 0.5;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// Distance to the inner edge of the border (where the gap begins)
|
|
465
|
-
float borderEndDist = roundedBox(adjustedBoxUv, v_borderEndSize, v_borderEndRadius);
|
|
466
|
-
float borderEndAlpha = 1.0 - smoothstep(0.0, 1.0, borderEndDist); // 1 if inside gap or content, 0 if in border or outside
|
|
467
|
-
|
|
468
|
-
// Distance to the content area (after the gap)
|
|
469
|
-
float contentDist = roundedBox(borderAdjustedBoxUv, v_innerSize, v_innerRadius);
|
|
470
|
-
float contentAlpha = 1.0 - smoothstep(0.0, 1.0, contentDist); // 1 if inside content, 0 if in gap, border or outside
|
|
471
|
-
|
|
472
|
-
vec4 finalColor;
|
|
473
|
-
if (u_inset) { // For inset borders: border <- gap <- element
|
|
474
|
-
// flip the logic: borderEndAlpha becomes gap, contentAlpha becomes border+content
|
|
475
|
-
if (contentAlpha > 0.0) { // Pixel is inside the content area (innermost)
|
|
476
|
-
finalColor = contentTexColor;
|
|
477
|
-
} else if (borderEndAlpha > 0.0) { // Pixel is inside the border area (middle)
|
|
478
|
-
vec4 borderColor = u_borderColor;
|
|
479
|
-
finalColor = mix(contentTexColor, vec4(borderColor.rgb, 1.0), borderColor.a);
|
|
480
|
-
} else { // Pixel is in the gap area (outermost) - show content through gap
|
|
481
|
-
finalColor = contentTexColor;
|
|
482
|
-
}
|
|
483
|
-
} else { // For outside borders: element -> gap -> border
|
|
484
|
-
if (contentAlpha > 0.0) { // Pixel is inside the content area
|
|
485
|
-
finalColor = contentTexColor;
|
|
486
|
-
} else if (borderEndAlpha > 0.0) { // Pixel is inside the gap area
|
|
487
|
-
finalColor = vec4(0.0); // Transparent gap
|
|
488
|
-
} else { // Pixel is inside the border area
|
|
489
|
-
vec4 borderColor = u_borderColor;
|
|
490
|
-
finalColor = borderColor;
|
|
491
|
-
finalColor.rgb *= finalColor.a;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
gl_FragColor = mix(vec4(0.0), finalColor, outerShapeAlpha) * u_alpha;
|
|
496
|
-
}
|
|
497
|
-
`,
|
|
498
|
-
};
|
|
499
|
-
|
|
500
213
|
export function registerDefaultShaderRounded(
|
|
501
214
|
shManager: IRendererShaderManager,
|
|
502
215
|
) {
|
|
@@ -4,41 +4,38 @@ import {
|
|
|
4
4
|
type NodeProps,
|
|
5
5
|
type NodeStyles,
|
|
6
6
|
} from '@lightningtv/solid';
|
|
7
|
-
import {
|
|
8
|
-
createMemo,
|
|
9
|
-
getOwner,
|
|
10
|
-
onMount,
|
|
11
|
-
runWithOwner,
|
|
12
|
-
type Accessor,
|
|
13
|
-
} from 'solid-js';
|
|
14
|
-
import { fadeIn, fadeOut } from './FadeInOut.jsx';
|
|
7
|
+
import { getOwner, runWithOwner, type Accessor } from 'solid-js';
|
|
15
8
|
import { chainFunctions } from '@lightningtv/solid/primitives';
|
|
16
9
|
|
|
17
10
|
export const BorderBoxStyle: NodeStyles = {
|
|
18
|
-
alpha: 0,
|
|
11
|
+
alpha: 0.01,
|
|
19
12
|
borderSpace: 6,
|
|
20
13
|
borderRadius: 20,
|
|
21
14
|
border: { color: 0xffffff, width: 2 },
|
|
15
|
+
transition: { alpha: { duration: 100, easing: 'linear' } },
|
|
22
16
|
};
|
|
23
17
|
|
|
24
18
|
type BorderProps = NodeProps & { borderSpace?: number };
|
|
25
19
|
const borderComponent = (props: BorderProps) => {
|
|
26
|
-
const space =
|
|
27
|
-
() => props.borderSpace ?? (BorderBoxStyle.borderSpace as number),
|
|
28
|
-
);
|
|
20
|
+
const space = props.borderSpace ?? (BorderBoxStyle.borderSpace as number);
|
|
29
21
|
return (
|
|
30
22
|
<view
|
|
31
23
|
skipFocus
|
|
32
24
|
onCreate={(el) => {
|
|
33
25
|
const parent = el.parent!;
|
|
34
|
-
el.width = parent.width + space
|
|
35
|
-
el.height = parent.height + space
|
|
36
|
-
|
|
26
|
+
el.width = parent.width + space * 2;
|
|
27
|
+
el.height = parent.height + space * 2;
|
|
28
|
+
el.alpha = 1;
|
|
29
|
+
}}
|
|
30
|
+
onDestroy={(el) => {
|
|
31
|
+
return el
|
|
32
|
+
.animate({ alpha: 0 }, el.transition as any)
|
|
33
|
+
.start()
|
|
34
|
+
.waitUntilStopped();
|
|
37
35
|
}}
|
|
38
|
-
onDestroy={fadeOut}
|
|
39
36
|
style={BorderBoxStyle}
|
|
40
|
-
x={-space
|
|
41
|
-
y={-space
|
|
37
|
+
x={-space}
|
|
38
|
+
y={-space}
|
|
42
39
|
{...props}
|
|
43
40
|
/>
|
|
44
41
|
);
|
|
@@ -52,23 +49,21 @@ export function borderBox(
|
|
|
52
49
|
let border: ElementNode | null;
|
|
53
50
|
const owner = getOwner();
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, el.onFocusChanged);
|
|
73
|
-
});
|
|
52
|
+
el.onFocusChanged = chainFunctions((f) => {
|
|
53
|
+
if (f) {
|
|
54
|
+
if (border) return;
|
|
55
|
+
runWithOwner(owner, () => {
|
|
56
|
+
const props = accessor();
|
|
57
|
+
border = borderComponent(
|
|
58
|
+
props === true || props === undefined ? ({} as NodeProps) : props,
|
|
59
|
+
) as any as ElementNode;
|
|
60
|
+
insertNode(el, border);
|
|
61
|
+
border.render();
|
|
62
|
+
});
|
|
63
|
+
} else if (border) {
|
|
64
|
+
border.destroy();
|
|
65
|
+
el.removeChild(border!);
|
|
66
|
+
border = null;
|
|
67
|
+
}
|
|
68
|
+
}, el.onFocusChanged);
|
|
74
69
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { WebGlShaderType } from '@lightningjs/renderer/webgl';
|
|
2
|
-
import { type RoundedProps } from './templates/RoundedTemplate.js';
|
|
3
|
-
/**
|
|
4
|
-
* Similar to the {@link DefaultShader} but cuts out 4 rounded rectangle corners
|
|
5
|
-
* as defined by the specified corner {@link RoundedProps.radius}
|
|
6
|
-
*/
|
|
7
|
-
export declare const Rounded: WebGlShaderType<RoundedProps>;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { calcFactoredRadiusArray } from './utils.js';
|
|
2
|
-
import { RoundedTemplate, } from './templates/RoundedTemplate.js';
|
|
3
|
-
/**
|
|
4
|
-
* Similar to the {@link DefaultShader} but cuts out 4 rounded rectangle corners
|
|
5
|
-
* as defined by the specified corner {@link RoundedProps.radius}
|
|
6
|
-
*/
|
|
7
|
-
export const Rounded = {
|
|
8
|
-
props: RoundedTemplate.props,
|
|
9
|
-
update(node) {
|
|
10
|
-
this.uniform4fa('u_radius', calcFactoredRadiusArray(this.props.radius, node.w, node.h));
|
|
11
|
-
},
|
|
12
|
-
vertex: `
|
|
13
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
14
|
-
precision highp float;
|
|
15
|
-
# else
|
|
16
|
-
precision mediump float;
|
|
17
|
-
# endif
|
|
18
|
-
|
|
19
|
-
attribute vec2 a_position;
|
|
20
|
-
attribute vec2 a_textureCoords;
|
|
21
|
-
attribute vec4 a_color;
|
|
22
|
-
attribute vec2 a_nodeCoords;
|
|
23
|
-
|
|
24
|
-
uniform vec2 u_resolution;
|
|
25
|
-
uniform float u_pixelRatio;
|
|
26
|
-
|
|
27
|
-
varying vec4 v_color;
|
|
28
|
-
varying vec2 v_textureCoords;
|
|
29
|
-
varying vec2 v_nodeCoords;
|
|
30
|
-
|
|
31
|
-
void main() {
|
|
32
|
-
vec2 normalized = a_position * u_pixelRatio;
|
|
33
|
-
vec2 screenSpace = vec2(2.0 / u_resolution.x, -2.0 / u_resolution.y);
|
|
34
|
-
|
|
35
|
-
v_color = a_color;
|
|
36
|
-
v_nodeCoords = a_nodeCoords;
|
|
37
|
-
v_textureCoords = a_textureCoords;
|
|
38
|
-
|
|
39
|
-
gl_Position = vec4(
|
|
40
|
-
normalized.x * screenSpace.x - 1.0,
|
|
41
|
-
normalized.y * -abs(screenSpace.y) + 1.0,
|
|
42
|
-
0.0,
|
|
43
|
-
1.0
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
`,
|
|
47
|
-
fragment: `
|
|
48
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
49
|
-
precision highp float;
|
|
50
|
-
# else
|
|
51
|
-
precision mediump float;
|
|
52
|
-
# endif
|
|
53
|
-
|
|
54
|
-
uniform vec2 u_dimensions;
|
|
55
|
-
uniform float u_alpha;
|
|
56
|
-
uniform float u_pixelRatio;
|
|
57
|
-
uniform sampler2D u_texture;
|
|
58
|
-
uniform vec4 u_radius;
|
|
59
|
-
|
|
60
|
-
varying vec4 v_color;
|
|
61
|
-
varying vec2 v_textureCoords;
|
|
62
|
-
varying vec2 v_nodeCoords;
|
|
63
|
-
|
|
64
|
-
void main() {
|
|
65
|
-
vec2 halfDimensions = u_dimensions * 0.5;
|
|
66
|
-
vec2 boxUv = v_nodeCoords * u_dimensions - halfDimensions;
|
|
67
|
-
|
|
68
|
-
// Branchless radius selection based on quadrant
|
|
69
|
-
// x: TL, y: TR, z: BR, w: BL
|
|
70
|
-
vec2 stepVal = step(vec2(0.0), boxUv);
|
|
71
|
-
float r = mix(
|
|
72
|
-
mix(u_radius.x, u_radius.y, stepVal.x),
|
|
73
|
-
mix(u_radius.w, u_radius.z, stepVal.x),
|
|
74
|
-
stepVal.y
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
vec2 q = abs(boxUv) - halfDimensions + r;
|
|
78
|
-
float d = min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
|
|
79
|
-
|
|
80
|
-
float edgeWidth = 1.0 / u_pixelRatio;
|
|
81
|
-
float alpha = 1.0 - smoothstep(-0.5 * edgeWidth, 0.5 * edgeWidth, d);
|
|
82
|
-
|
|
83
|
-
vec4 color = texture2D(u_texture, v_textureCoords) * v_color;
|
|
84
|
-
gl_FragColor = color * alpha * u_alpha;
|
|
85
|
-
}
|
|
86
|
-
`,
|
|
87
|
-
};
|
|
88
|
-
//# sourceMappingURL=Rounded.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Rounded.js","sourceRoot":"","sources":["../../../src/shaders/Rounded.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAa,MAAM,YAAY,CAAC;AAChE,OAAO,EACL,eAAe,GAEhB,MAAM,gCAAgC,CAAC;AAOxC;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkC;IACpD,KAAK,EAAE,eAAe,CAAC,KAAK;IAC5B,MAAM,CAAC,IAAc;QACnB,IAAI,CAAC,UAAU,CACb,UAAU,EACV,uBAAuB,CAAC,IAAI,CAAC,KAAM,CAAC,MAAc,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CACpE,CAAC;IACJ,CAAC;IACD,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCT;IACC,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCT;CACF,CAAC"}
|