@tantawowa/hosanna-ui 2.1.0 → 2.2.0
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-manifest.json +26 -22
- package/package.json +1 -1
- package/src/hosanna-bridge-core/color.ts +140 -0
- package/src/hosanna-game/color.ts +3 -115
- package/src/hosanna-list/BaseCell.ts +4 -0
- package/src/hosanna-list/BaseCollectionViewLayout.ts +59 -6
- package/src/hosanna-list/CollectionView.ts +14 -5
- package/src/hosanna-list/CollectionViewAPI.ts +41 -5
- package/src/hosanna-list/CollectionViewFocusManager.ts +415 -6
- package/src/hosanna-list/CollectionViewSupplementaryView.ts +49 -1
- package/src/hosanna-list/DynamicCell.ts +132 -2
- package/src/hosanna-list/EPGProgramLayout.ts +1 -0
- package/src/hosanna-list/GridRowLayout.ts +1 -0
- package/src/hosanna-list/HorizontalRowLayout.ts +1 -0
- package/src/hosanna-list/ListRowLayout.ts +1 -0
- package/src/hosanna-ui/lib/FragmentUtils.ts +26 -10
- package/src/hosanna-ui/lib/animation.ts +358 -235
- package/src/hosanna-ui/views/controls/Button.ts +16 -1
- package/src/hosanna-ui/views/lib/AppConfig.ts +26 -0
- package/src/hosanna-ui/views/lib/BaseView.ts +70 -6
- package/src/hosanna-ui/views/lib/ViewFragmentProvider.ts +39 -5
- package/src/hosanna-ui/views/primitives/Image.ts +1 -1
- package/src/hosanna-ui/views/primitives/Label.ts +3 -3
package/dist-manifest.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"artifact": "npm-sdk",
|
|
4
4
|
"packageName": "@tantawowa/hosanna-ui",
|
|
5
|
-
"version": "2.
|
|
6
|
-
"sourceCommit": "
|
|
5
|
+
"version": "2.2.0",
|
|
6
|
+
"sourceCommit": "ba69343a9746dae449a525b5998169dd20700726",
|
|
7
7
|
"files": [
|
|
8
8
|
{
|
|
9
9
|
"path": "LICENSE",
|
|
@@ -109,6 +109,10 @@
|
|
|
109
109
|
"path": "src/hosanna-bridge-core/brs-api.ts",
|
|
110
110
|
"sha256": "1df73683d24e69df0ea47edbb4c3b396cf3e1cccb7d1cf79859cf2c3e37e075e"
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
"path": "src/hosanna-bridge-core/color.ts",
|
|
114
|
+
"sha256": "c5e126cd37fe38d9a38a669d9c6c4cdb4676d0f809538bb039687c364ed31fd5"
|
|
115
|
+
},
|
|
112
116
|
{
|
|
113
117
|
"path": "src/hosanna-bridge-core/date-time-utils.ts",
|
|
114
118
|
"sha256": "8148ada6937ecec7a7822b83571b7ed260aa5b1a84e34d8b2dbe70222d480ac8"
|
|
@@ -1059,7 +1063,7 @@
|
|
|
1059
1063
|
},
|
|
1060
1064
|
{
|
|
1061
1065
|
"path": "src/hosanna-game/color.ts",
|
|
1062
|
-
"sha256": "
|
|
1066
|
+
"sha256": "462a48b6ccb5d51872c43278f9e04884b285054e79eee89d2ece964483af4960"
|
|
1063
1067
|
},
|
|
1064
1068
|
{
|
|
1065
1069
|
"path": "src/hosanna-game/control/Hs2dControlInput.ts",
|
|
@@ -1655,11 +1659,11 @@
|
|
|
1655
1659
|
},
|
|
1656
1660
|
{
|
|
1657
1661
|
"path": "src/hosanna-list/BaseCell.ts",
|
|
1658
|
-
"sha256": "
|
|
1662
|
+
"sha256": "c2aa02270647f9c2b7fdbc60256743a40711976b8581273819a068d524af3286"
|
|
1659
1663
|
},
|
|
1660
1664
|
{
|
|
1661
1665
|
"path": "src/hosanna-list/BaseCollectionViewLayout.ts",
|
|
1662
|
-
"sha256": "
|
|
1666
|
+
"sha256": "df7f4a535c326e3f659bcc98f1c8c6aedb6865cdf5c67a8af2883fc8caebbf09"
|
|
1663
1667
|
},
|
|
1664
1668
|
{
|
|
1665
1669
|
"path": "src/hosanna-list/BaseCollectionViewRow.ts",
|
|
@@ -1667,11 +1671,11 @@
|
|
|
1667
1671
|
},
|
|
1668
1672
|
{
|
|
1669
1673
|
"path": "src/hosanna-list/CollectionView.ts",
|
|
1670
|
-
"sha256": "
|
|
1674
|
+
"sha256": "846e9bcbbdd82e18b256911d30ee0460ed14a2dcc377f306e9d87991ae095155"
|
|
1671
1675
|
},
|
|
1672
1676
|
{
|
|
1673
1677
|
"path": "src/hosanna-list/CollectionViewAPI.ts",
|
|
1674
|
-
"sha256": "
|
|
1678
|
+
"sha256": "6ba666140f278d417343656b18b68d51a98a4cdceb1eab7ded390b947d0276e2"
|
|
1675
1679
|
},
|
|
1676
1680
|
{
|
|
1677
1681
|
"path": "src/hosanna-list/CollectionViewDSLManager.ts",
|
|
@@ -1703,7 +1707,7 @@
|
|
|
1703
1707
|
},
|
|
1704
1708
|
{
|
|
1705
1709
|
"path": "src/hosanna-list/CollectionViewFocusManager.ts",
|
|
1706
|
-
"sha256": "
|
|
1710
|
+
"sha256": "2fa86cc5900e7ffd181fb497cc13e3c2f1ae235b23df7ad8b234dc6a704d36a7"
|
|
1707
1711
|
},
|
|
1708
1712
|
{
|
|
1709
1713
|
"path": "src/hosanna-list/CollectionViewInteractions.ts",
|
|
@@ -1715,7 +1719,7 @@
|
|
|
1715
1719
|
},
|
|
1716
1720
|
{
|
|
1717
1721
|
"path": "src/hosanna-list/CollectionViewSupplementaryView.ts",
|
|
1718
|
-
"sha256": "
|
|
1722
|
+
"sha256": "9972c9b7c05cb75ec1bb26cf6ad969aca7b34cd399bc2effaacd8b18ef09f57a"
|
|
1719
1723
|
},
|
|
1720
1724
|
{
|
|
1721
1725
|
"path": "src/hosanna-list/CollectionViewUtils.ts",
|
|
@@ -1735,11 +1739,11 @@
|
|
|
1735
1739
|
},
|
|
1736
1740
|
{
|
|
1737
1741
|
"path": "src/hosanna-list/DynamicCell.ts",
|
|
1738
|
-
"sha256": "
|
|
1742
|
+
"sha256": "abc184ba3a1dc98bbaea80c14ee5eb6d631cb37f9b3b5254197104e66eecc396"
|
|
1739
1743
|
},
|
|
1740
1744
|
{
|
|
1741
1745
|
"path": "src/hosanna-list/EPGProgramLayout.ts",
|
|
1742
|
-
"sha256": "
|
|
1746
|
+
"sha256": "003a8efb6df5d3c8e7aa1041dc123b19d46df1f0ab62c35783b9fcbf76aea556"
|
|
1743
1747
|
},
|
|
1744
1748
|
{
|
|
1745
1749
|
"path": "src/hosanna-list/EPGProgramRow.ts",
|
|
@@ -1759,7 +1763,7 @@
|
|
|
1759
1763
|
},
|
|
1760
1764
|
{
|
|
1761
1765
|
"path": "src/hosanna-list/GridRowLayout.ts",
|
|
1762
|
-
"sha256": "
|
|
1766
|
+
"sha256": "20ef7d2b4c0f30c4faa0920784b394cd327081daa431c320244c053cb2e280d1"
|
|
1763
1767
|
},
|
|
1764
1768
|
{
|
|
1765
1769
|
"path": "src/hosanna-list/HorizontalRow.ts",
|
|
@@ -1767,7 +1771,7 @@
|
|
|
1767
1771
|
},
|
|
1768
1772
|
{
|
|
1769
1773
|
"path": "src/hosanna-list/HorizontalRowLayout.ts",
|
|
1770
|
-
"sha256": "
|
|
1774
|
+
"sha256": "d97c7d3c03bbdb954548f67f4dc90f528c5205268eff6b68f0f8e623bbcdf602"
|
|
1771
1775
|
},
|
|
1772
1776
|
{
|
|
1773
1777
|
"path": "src/hosanna-list/ListRow.ts",
|
|
@@ -1775,7 +1779,7 @@
|
|
|
1775
1779
|
},
|
|
1776
1780
|
{
|
|
1777
1781
|
"path": "src/hosanna-list/ListRowLayout.ts",
|
|
1778
|
-
"sha256": "
|
|
1782
|
+
"sha256": "0419addc599f6e4b275a12fa20d602b3d14d1bb9305f959bac87ae00486ec34c"
|
|
1779
1783
|
},
|
|
1780
1784
|
{
|
|
1781
1785
|
"path": "src/hosanna-list/ListUtil.ts",
|
|
@@ -2003,7 +2007,7 @@
|
|
|
2003
2007
|
},
|
|
2004
2008
|
{
|
|
2005
2009
|
"path": "src/hosanna-ui/lib/FragmentUtils.ts",
|
|
2006
|
-
"sha256": "
|
|
2010
|
+
"sha256": "1aa7ded7201d54810a2d68db45b89bf515fa041302e49c0f5a7985ceff2c379c"
|
|
2007
2011
|
},
|
|
2008
2012
|
{
|
|
2009
2013
|
"path": "src/hosanna-ui/lib/HosannaAppUtils.ts",
|
|
@@ -2063,7 +2067,7 @@
|
|
|
2063
2067
|
},
|
|
2064
2068
|
{
|
|
2065
2069
|
"path": "src/hosanna-ui/lib/animation.ts",
|
|
2066
|
-
"sha256": "
|
|
2070
|
+
"sha256": "8031efcba28441727da8d640fbddff85430141d12ab2a421654e8bf42094a66d"
|
|
2067
2071
|
},
|
|
2068
2072
|
{
|
|
2069
2073
|
"path": "src/hosanna-ui/lib/app-debug-utils.ts",
|
|
@@ -2491,7 +2495,7 @@
|
|
|
2491
2495
|
},
|
|
2492
2496
|
{
|
|
2493
2497
|
"path": "src/hosanna-ui/views/controls/Button.ts",
|
|
2494
|
-
"sha256": "
|
|
2498
|
+
"sha256": "b8e2366ea17cd53a7a92c511bffb8515ffe90e24fb28e7ca83039ee4cc886601"
|
|
2495
2499
|
},
|
|
2496
2500
|
{
|
|
2497
2501
|
"path": "src/hosanna-ui/views/controls/ButtonGroup.ts",
|
|
@@ -2627,11 +2631,11 @@
|
|
|
2627
2631
|
},
|
|
2628
2632
|
{
|
|
2629
2633
|
"path": "src/hosanna-ui/views/lib/AppConfig.ts",
|
|
2630
|
-
"sha256": "
|
|
2634
|
+
"sha256": "135dfab9f10549aa9e7259d1e2e893f8e8684f7a46645af6dacc9b3c2bdc992f"
|
|
2631
2635
|
},
|
|
2632
2636
|
{
|
|
2633
2637
|
"path": "src/hosanna-ui/views/lib/BaseView.ts",
|
|
2634
|
-
"sha256": "
|
|
2638
|
+
"sha256": "b381d39d4710b8b9b6bdab07772c1a1bf2d79b3438bff66d50e6b2f1e444fdfe"
|
|
2635
2639
|
},
|
|
2636
2640
|
{
|
|
2637
2641
|
"path": "src/hosanna-ui/views/lib/BuildConfig.ts",
|
|
@@ -2655,7 +2659,7 @@
|
|
|
2655
2659
|
},
|
|
2656
2660
|
{
|
|
2657
2661
|
"path": "src/hosanna-ui/views/lib/ViewFragmentProvider.ts",
|
|
2658
|
-
"sha256": "
|
|
2662
|
+
"sha256": "31db2af2c0431d5a1fd7d93ab41f5aeec8507047b02e495d5e71212ec64405e0"
|
|
2659
2663
|
},
|
|
2660
2664
|
{
|
|
2661
2665
|
"path": "src/hosanna-ui/views/lib/beacons.ts",
|
|
@@ -2691,11 +2695,11 @@
|
|
|
2691
2695
|
},
|
|
2692
2696
|
{
|
|
2693
2697
|
"path": "src/hosanna-ui/views/primitives/Image.ts",
|
|
2694
|
-
"sha256": "
|
|
2698
|
+
"sha256": "340d841c7089028b0faf2e758a014fe8ac0e764823361ccb474022649f97e271"
|
|
2695
2699
|
},
|
|
2696
2700
|
{
|
|
2697
2701
|
"path": "src/hosanna-ui/views/primitives/Label.ts",
|
|
2698
|
-
"sha256": "
|
|
2702
|
+
"sha256": "ec28af10d3a18c05edc3192102942d976563fd4901862ef3a83dbe39f4dd4194"
|
|
2699
2703
|
},
|
|
2700
2704
|
{
|
|
2701
2705
|
"path": "src/hosanna-ui/views/primitives/MultiStyleLabel.ts",
|
package/package.json
CHANGED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { roLongInteger } from './brs-api';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_COLOR = -1;
|
|
4
|
+
const UINT32_RANGE = 4294967296 as roLongInteger;
|
|
5
|
+
|
|
6
|
+
export type ColorInput = number | string | undefined | null;
|
|
7
|
+
|
|
8
|
+
// All numeric colors are RGBA (0xRRGGBBAA) — the roScreen/roBitmap convention
|
|
9
|
+
// used device-wide. '#rrggbb' strings gain an opaque alpha; '#rrggbbaa'
|
|
10
|
+
// strings are taken literally.
|
|
11
|
+
export function colorToRgba(color: ColorInput, fallback = DEFAULT_COLOR): number {
|
|
12
|
+
if (typeof color === 'number') {
|
|
13
|
+
return color;
|
|
14
|
+
}
|
|
15
|
+
if (typeof color !== 'string' || color.length === 0) {
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
const value = color.trim();
|
|
19
|
+
if (isHexColor(value, 6)) {
|
|
20
|
+
return toColor(hexToNumber(value.slice(1)), 0xff);
|
|
21
|
+
}
|
|
22
|
+
if (isHexColor(value, 8)) {
|
|
23
|
+
return hexToNumber(value.slice(1));
|
|
24
|
+
}
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Format all four RGBA bytes without large-number string conversion. */
|
|
29
|
+
export function colorToHex(color: number): string {
|
|
30
|
+
const packed = normalizeColor(color);
|
|
31
|
+
const digits = '0123456789ABCDEF';
|
|
32
|
+
let result = '#';
|
|
33
|
+
for (let shift = 24; shift >= 0; shift -= 8) {
|
|
34
|
+
const value = channel(packed, shift);
|
|
35
|
+
result += digits.charAt(Math.floor(value / 16)) + digits.charAt(value % 16);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Compare canonical RGBA values, including signed native integers. */
|
|
41
|
+
export function colorsEqual(left: ColorInput, right: ColorInput): boolean {
|
|
42
|
+
return normalizeColor(colorToRgba(left)) === normalizeColor(colorToRgba(right));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @deprecated The stack is RGBA end-to-end; nothing produces ARGB anymore. */
|
|
46
|
+
export function argbToRgba(color: number): number {
|
|
47
|
+
const normalized = normalizeColor(color);
|
|
48
|
+
const alpha = Math.floor(normalized / 0x1000000) % 0x100;
|
|
49
|
+
const rgb = normalized % 0x1000000;
|
|
50
|
+
const signedRgb = rgb >= 0x800000 ? rgb - 0x1000000 : rgb;
|
|
51
|
+
return signedRgb * 0x100 + alpha;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Replace an RGBA color's alpha (low byte) with opacity 0..1. */
|
|
55
|
+
export function withAlpha(color: number, alpha: number): number {
|
|
56
|
+
const a = clamp(Math.round(alpha * 255), 0, 255);
|
|
57
|
+
const normalized = normalizeColor(color);
|
|
58
|
+
return toColor(Math.floor(normalized / 0x100), a);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function blendColors(
|
|
62
|
+
from: ColorInput,
|
|
63
|
+
target: ColorInput,
|
|
64
|
+
amount: number,
|
|
65
|
+
fallback = DEFAULT_COLOR,
|
|
66
|
+
): number {
|
|
67
|
+
const fromColor = normalizeColor(colorToRgba(from, fallback));
|
|
68
|
+
const targetColor = normalizeColor(colorToRgba(target, fallback));
|
|
69
|
+
const t = clamp(amount, 0, 1);
|
|
70
|
+
|
|
71
|
+
const red = blendChannel(channel(fromColor, 24), channel(targetColor, 24), t);
|
|
72
|
+
const green = blendChannel(channel(fromColor, 16), channel(targetColor, 16), t);
|
|
73
|
+
const blue = blendChannel(channel(fromColor, 8), channel(targetColor, 8), t);
|
|
74
|
+
const alpha = blendChannel(channel(fromColor, 0), channel(targetColor, 0), t);
|
|
75
|
+
|
|
76
|
+
return toColor(red * 0x10000 + green * 0x100 + blue, alpha);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function blendChannel(from: number, target: number, amount: number): number {
|
|
80
|
+
return Math.round(from + (target - from) * amount);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Keep channel extraction in integer arithmetic. The native generic bitwise helper
|
|
84
|
+
// passes through floating-point conversion and can lose the low RGBA byte.
|
|
85
|
+
function channel(color: number, shift: number): number {
|
|
86
|
+
const packedColor = color as roLongInteger;
|
|
87
|
+
const shiftedColor = (packedColor >> shift) as roLongInteger;
|
|
88
|
+
const higherChannels = (shiftedColor >> 8) as roLongInteger;
|
|
89
|
+
return shiftedColor - higherChannels * 0x100;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function hexToNumber(hex: string): number {
|
|
93
|
+
let value = 0 as roLongInteger;
|
|
94
|
+
for (let i = 0; i < hex.length; i++) {
|
|
95
|
+
const code = hex.charCodeAt(i);
|
|
96
|
+
if (code >= 48 && code <= 57) {
|
|
97
|
+
value = (value * 16 + code - 48) as roLongInteger;
|
|
98
|
+
} else if (code >= 65 && code <= 70) {
|
|
99
|
+
value = (value * 16 + code - 55) as roLongInteger;
|
|
100
|
+
} else {
|
|
101
|
+
value = (value * 16 + code - 87) as roLongInteger;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function normalizeColor(color: number): number {
|
|
108
|
+
if (color < 0) {
|
|
109
|
+
return color + UINT32_RANGE;
|
|
110
|
+
}
|
|
111
|
+
return color;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function toColor(rgb: number, alpha: number): number {
|
|
115
|
+
const packedRgb = rgb as roLongInteger;
|
|
116
|
+
const packedAlpha = alpha as roLongInteger;
|
|
117
|
+
return packedRgb * 0x100 + packedAlpha;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function isHexColor(value: string, hexLength: number): boolean {
|
|
121
|
+
if (value.length !== hexLength + 1 || value.charAt(0) !== '#') {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
for (let i = 1; i < value.length; i++) {
|
|
125
|
+
if (!isHexDigit(value.charCodeAt(i))) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isHexDigit(code: number): boolean {
|
|
133
|
+
return (code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function clamp(value: number, min: number, max: number): number {
|
|
137
|
+
if (value < min) return min;
|
|
138
|
+
if (value > max) return max;
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
@@ -1,115 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type ColorInput = number | string | undefined | null;
|
|
6
|
-
|
|
7
|
-
// All numeric colors are RGBA (0xRRGGBBAA) — the roScreen/roBitmap convention
|
|
8
|
-
// used device-wide. '#rrggbb' strings gain an opaque alpha; '#rrggbbaa'
|
|
9
|
-
// strings are taken literally.
|
|
10
|
-
export function colorToRgba(color: ColorInput, fallback = DEFAULT_COLOR): number {
|
|
11
|
-
if (typeof color === 'number') {
|
|
12
|
-
return color;
|
|
13
|
-
}
|
|
14
|
-
if (typeof color !== 'string' || color.length === 0) {
|
|
15
|
-
return fallback;
|
|
16
|
-
}
|
|
17
|
-
const value = color.trim();
|
|
18
|
-
if (isHexColor(value, 6)) {
|
|
19
|
-
return toColor(hexToNumber(value.slice(1)), 0xff);
|
|
20
|
-
}
|
|
21
|
-
if (isHexColor(value, 8)) {
|
|
22
|
-
return hexToNumber(value.slice(1));
|
|
23
|
-
}
|
|
24
|
-
return fallback;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** @deprecated The stack is RGBA end-to-end; nothing produces ARGB anymore. */
|
|
28
|
-
export function argbToRgba(color: number): number {
|
|
29
|
-
const normalized = normalizeColor(color);
|
|
30
|
-
const alpha = Math.floor(normalized / 0x1000000) % 0x100;
|
|
31
|
-
const rgb = normalized % 0x1000000;
|
|
32
|
-
const signedRgb = rgb >= 0x800000 ? rgb - 0x1000000 : rgb;
|
|
33
|
-
return signedRgb * 0x100 + alpha;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Replace an RGBA color's alpha (low byte) with opacity 0..1. */
|
|
37
|
-
export function withAlpha(color: number, alpha: number): number {
|
|
38
|
-
const a = clamp(Math.round(alpha * 255), 0, 255);
|
|
39
|
-
const normalized = normalizeColor(color);
|
|
40
|
-
return toColor(Math.floor(normalized / 0x100), a);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function blendColors(
|
|
44
|
-
from: ColorInput,
|
|
45
|
-
target: ColorInput,
|
|
46
|
-
amount: number,
|
|
47
|
-
fallback = DEFAULT_COLOR,
|
|
48
|
-
): number {
|
|
49
|
-
const fromColor = normalizeColor(colorToRgba(from, fallback));
|
|
50
|
-
const targetColor = normalizeColor(colorToRgba(target, fallback));
|
|
51
|
-
const t = clamp(amount, 0, 1);
|
|
52
|
-
|
|
53
|
-
const red = blendChannel(channel(fromColor, 0x1000000), channel(targetColor, 0x1000000), t);
|
|
54
|
-
const green = blendChannel(channel(fromColor, 0x10000), channel(targetColor, 0x10000), t);
|
|
55
|
-
const blue = blendChannel(channel(fromColor, 0x100), channel(targetColor, 0x100), t);
|
|
56
|
-
const alpha = blendChannel(channel(fromColor, 1), channel(targetColor, 1), t);
|
|
57
|
-
|
|
58
|
-
return toColor(red * 0x10000 + green * 0x100 + blue, alpha);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function blendChannel(from: number, target: number, amount: number): number {
|
|
62
|
-
return Math.round(from + (target - from) * amount);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function channel(color: number, divisor: number): number {
|
|
66
|
-
return Math.floor(color / divisor) % 0x100;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function hexToNumber(hex: string): number {
|
|
70
|
-
let value = 0;
|
|
71
|
-
for (let i = 0; i < hex.length; i++) {
|
|
72
|
-
const code = hex.charCodeAt(i);
|
|
73
|
-
if (code >= 48 && code <= 57) {
|
|
74
|
-
value = value * 16 + code - 48;
|
|
75
|
-
} else if (code >= 65 && code <= 70) {
|
|
76
|
-
value = value * 16 + code - 55;
|
|
77
|
-
} else {
|
|
78
|
-
value = value * 16 + code - 87;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function normalizeColor(color: number): number {
|
|
85
|
-
if (color < 0) {
|
|
86
|
-
return color + UINT32_RANGE;
|
|
87
|
-
}
|
|
88
|
-
return color;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function toColor(rgb: number, alpha: number): number {
|
|
92
|
-
return rgb * 0x100 + alpha;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function isHexColor(value: string, hexLength: number): boolean {
|
|
96
|
-
if (value.length !== hexLength + 1 || value.charAt(0) !== '#') {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
for (let i = 1; i < value.length; i++) {
|
|
100
|
-
if (!isHexDigit(value.charCodeAt(i))) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function isHexDigit(code: number): boolean {
|
|
108
|
-
return (code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function clamp(value: number, min: number, max: number): number {
|
|
112
|
-
if (value < min) return min;
|
|
113
|
-
if (value > max) return max;
|
|
114
|
-
return value;
|
|
115
|
-
}
|
|
1
|
+
// Preserve the game API while sharing canonical RGBA operations with UI animations.
|
|
2
|
+
export { colorToRgba, argbToRgba, withAlpha, blendColors } from '../hosanna-bridge-core/color';
|
|
3
|
+
export type { ColorInput } from '../hosanna-bridge-core/color';
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
IBaseCollectionViewRow,
|
|
5
5
|
ICollectionView,
|
|
6
6
|
ICollectionViewCell,
|
|
7
|
+
ICollectionViewFocusPercentRegistration,
|
|
7
8
|
ICollectionViewDataSourceItem,
|
|
8
9
|
isSameRowItem,
|
|
9
10
|
} from './CollectionViewAPI';
|
|
@@ -18,6 +19,8 @@ import { getUniqueViewId } from '@hs-src/hosanna-ui/views/lib/view-api';
|
|
|
18
19
|
* including content management, recycling, and rendering capabilities.
|
|
19
20
|
*/
|
|
20
21
|
export class BaseCell implements ICollectionViewCell {
|
|
22
|
+
/** @internal Allocated only for opted-in cells, reused across pooled bindings. */
|
|
23
|
+
_focusPercentRegistration?: ICollectionViewFocusPercentRegistration;
|
|
21
24
|
/**
|
|
22
25
|
* The cache key for the cell.
|
|
23
26
|
* Initialized to an empty string by default.
|
|
@@ -156,6 +159,7 @@ export class BaseCell implements ICollectionViewCell {
|
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
|
|
162
|
+
if (this._focusPercentRegistration) this._focusPercentRegistration.needsInitialization = true;
|
|
159
163
|
this.row = row;
|
|
160
164
|
this.item = item;
|
|
161
165
|
this.itemVersion = (item as ICollectionViewDataSourceItem | undefined)?.__hsVersion;
|
|
@@ -290,6 +290,9 @@ export class BaseCollectionViewLayout {
|
|
|
290
290
|
this.lastHeaderVisibility = undefined;
|
|
291
291
|
this.applyMeasuredSupplementaryHeight('header', this.headerSupplementaryView.getMeasuredHeight());
|
|
292
292
|
this.hasHeader = this.headerSupplementaryView.getShouldDisplay();
|
|
293
|
+
if (this.row.isOnScreen && this.hasHeader && this.headerSupplementaryView.supportsRowFocusPercent) {
|
|
294
|
+
this.row.parent?.getFocusManager?.().registerRowFocusPercentHeader?.(this.row.index, this.headerSupplementaryView, true);
|
|
295
|
+
}
|
|
293
296
|
|
|
294
297
|
if (this.headerLabel) {
|
|
295
298
|
this.headerLabel.visible = false;
|
|
@@ -544,6 +547,7 @@ export class BaseCollectionViewLayout {
|
|
|
544
547
|
// cell (~40ms/row of applyDataMap + computed + constraints). Cells are only truly
|
|
545
548
|
// released on reset / hidden-row / pool-release (see releaseAllCells / onWillRelease).
|
|
546
549
|
for (const cell of this.renderedCells) {
|
|
550
|
+
cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
|
|
547
551
|
cell.setVisible(false);
|
|
548
552
|
}
|
|
549
553
|
// Cells are hidden above; clear the scroll throttle key so the next calculateVisibleCells
|
|
@@ -618,14 +622,19 @@ export class BaseCollectionViewLayout {
|
|
|
618
622
|
* can use different styles.
|
|
619
623
|
*
|
|
620
624
|
* @param index - The index of the cell to retrieve.
|
|
625
|
+
* @param deferVisibility - Let configureCell finish binding before showing the cell.
|
|
621
626
|
* @returns The cell at the specified index, or a newly reserved cell if it did not exist.
|
|
622
627
|
* @throws A warning if no cells are available in the instancePool.
|
|
623
628
|
*/
|
|
624
|
-
getCell(index: number): ICollectionViewCell {
|
|
629
|
+
getCell(index: number, deferVisibility = false): ICollectionViewCell {
|
|
625
630
|
let cell: BaseCell | undefined = this.cellsByIndex[index.toString()];
|
|
626
631
|
if (cell !== undefined) {
|
|
627
632
|
// Retained cells are hidden on exit (see onExitScreen); ensure they are shown again on reuse.
|
|
628
|
-
|
|
633
|
+
if (deferVisibility === false) {
|
|
634
|
+
if ((cell as ICollectionViewCell).supportsFocusPercent !== true) {
|
|
635
|
+
if ((cell as ICollectionViewCell).supportsRowFocusPercent !== true) cell.setVisible(true);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
629
638
|
// Retained cells keep the viewStatus they had when the row scrolled away, which can be a
|
|
630
639
|
// stale Focused (focus left the CV while this cell was off-screen). Re-derive the correct
|
|
631
640
|
// status on every materialization; applyViewStatus no-ops when unchanged, so this costs a
|
|
@@ -649,8 +658,12 @@ export class BaseCollectionViewLayout {
|
|
|
649
658
|
key = cellSettingsKey;
|
|
650
659
|
}
|
|
651
660
|
cell = this.instancePool.get<DynamicCell>(key, DynamicCell);
|
|
652
|
-
if (cell) {
|
|
653
|
-
|
|
661
|
+
if (cell !== undefined) {
|
|
662
|
+
if (deferVisibility === false) {
|
|
663
|
+
if ((cell as ICollectionViewCell).supportsFocusPercent !== true) {
|
|
664
|
+
if ((cell as ICollectionViewCell).supportsRowFocusPercent !== true) cell.setVisible(true);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
654
667
|
cell.index = index;
|
|
655
668
|
cell.applyViewStatus(this.getExpectedCellViewStatus(index, cell.viewStatus));
|
|
656
669
|
this.cellsByIndex[index.toString()] = cell;
|
|
@@ -902,6 +915,14 @@ export class BaseCollectionViewLayout {
|
|
|
902
915
|
)
|
|
903
916
|
) {
|
|
904
917
|
if (this.headerSupplementaryView) {
|
|
918
|
+
if (this.headerSupplementaryView.supportsRowFocusPercent) {
|
|
919
|
+
const focusManager = this.row.parent?.getFocusManager?.();
|
|
920
|
+
if (headerVisibility) {
|
|
921
|
+
focusManager?.registerRowFocusPercentHeader?.(this.row.index, this.headerSupplementaryView);
|
|
922
|
+
} else {
|
|
923
|
+
focusManager?.unregisterRowFocusPercentHeader?.(this.headerSupplementaryView);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
905
926
|
this.headerSupplementaryView.setVisible(headerVisibility);
|
|
906
927
|
} else if (this.headerFragment) {
|
|
907
928
|
this.headerFragment.view.visible = headerVisibility;
|
|
@@ -1076,6 +1097,7 @@ export class BaseCollectionViewLayout {
|
|
|
1076
1097
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
1077
1098
|
scrollJankLog('cell-flag-remove', `layout=base rowIndex=${row.index} rowId=${row.id} cellIndex=${cell.index} itemId=${cell.item?.id ?? ''} reason=not-visible`);
|
|
1078
1099
|
}
|
|
1100
|
+
cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
|
|
1079
1101
|
cell.setVisible(false);
|
|
1080
1102
|
this.instancePool.release(cell);
|
|
1081
1103
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
@@ -1100,6 +1122,7 @@ export class BaseCollectionViewLayout {
|
|
|
1100
1122
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
1101
1123
|
scrollJankLog('cell-flag-remove', `layout=base rowIndex=${row.index} rowId=${row.id} cellIndex=${cell.index} itemId=${cell.item?.id ?? ''} reason=release-all`);
|
|
1102
1124
|
}
|
|
1125
|
+
cell._focusPercentRegistration?.owner?.unregisterFocusPercentCell?.(cell);
|
|
1103
1126
|
cell.reset();
|
|
1104
1127
|
cell.setVisible(false);
|
|
1105
1128
|
this.instancePool.release(cell);
|
|
@@ -1172,13 +1195,23 @@ export class BaseCollectionViewLayout {
|
|
|
1172
1195
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
1173
1196
|
scrollJankStartMs = scrollJankNow();
|
|
1174
1197
|
}
|
|
1175
|
-
const cell = this.getCell(index);
|
|
1198
|
+
const cell = this.getCell(index, true);
|
|
1176
1199
|
if (cell) {
|
|
1177
1200
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
1178
1201
|
scrollJankLog('configure-cell-start', `layout=base rowIndex=${this.row.index} rowId=${this.row.id} cellIndex=${index} itemId=${content?.id ?? ''} hasExistingItem=${cell.item !== undefined}`);
|
|
1179
1202
|
}
|
|
1180
|
-
//
|
|
1203
|
+
// Bind before showing a newly acquired or retained hidden presentation.
|
|
1204
|
+
// Read capabilities afterwards: content/status callbacks may change them.
|
|
1181
1205
|
cell.setContent(this.row, content);
|
|
1206
|
+
if (cell.supportsFocusPercent === true) {
|
|
1207
|
+
this.syncCellFocusPercent(cell);
|
|
1208
|
+
} else if (cell.supportsRowFocusPercent === true) {
|
|
1209
|
+
this.syncCellFocusPercent(cell);
|
|
1210
|
+
} else if (cell._focusPercentRegistration !== undefined) {
|
|
1211
|
+
const owner = cell._focusPercentRegistration.owner;
|
|
1212
|
+
if (owner !== undefined) owner.unregisterFocusPercentCell?.(cell);
|
|
1213
|
+
}
|
|
1214
|
+
(cell as BaseCell).setVisible(true);
|
|
1182
1215
|
if (__SCROLL_JANK_TELEMETRY__) {
|
|
1183
1216
|
scrollJankLog('configure-cell-end', `layout=base rowIndex=${this.row.index} rowId=${this.row.id} cellIndex=${index} itemId=${content?.id ?? ''} durationMs=${scrollJankDuration(scrollJankStartMs)}`);
|
|
1184
1217
|
}
|
|
@@ -1188,6 +1221,23 @@ export class BaseCollectionViewLayout {
|
|
|
1188
1221
|
return cell! as BaseCell;
|
|
1189
1222
|
}
|
|
1190
1223
|
|
|
1224
|
+
/** Completes opt-in binding before a deferred cell becomes visible. */
|
|
1225
|
+
private syncCellFocusPercent(cell: ICollectionViewCell): void {
|
|
1226
|
+
if (cell.supportsFocusPercent || cell.supportsRowFocusPercent) {
|
|
1227
|
+
const registration = cell._focusPercentRegistration;
|
|
1228
|
+
if (registration?.owner === undefined || registration.needsInitialization
|
|
1229
|
+
|| registration.itemIndex !== cell.index
|
|
1230
|
+
|| registration.supportsFocusPercent !== (cell.supportsFocusPercent === true)
|
|
1231
|
+
|| registration.supportsRowFocusPercent !== (cell.supportsRowFocusPercent === true)
|
|
1232
|
+
|| (cell.supportsFocusPercent && cell.focusPercent === undefined)
|
|
1233
|
+
|| (cell.supportsRowFocusPercent && cell.rowFocusPercent === undefined)) {
|
|
1234
|
+
this.row.parent?.getFocusManager?.().registerFocusPercentCell?.(cell);
|
|
1235
|
+
}
|
|
1236
|
+
} else if (cell._focusPercentRegistration?.owner !== undefined) {
|
|
1237
|
+
cell._focusPercentRegistration.owner.unregisterFocusPercentCell?.(cell);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1191
1241
|
// IReusable implementation
|
|
1192
1242
|
|
|
1193
1243
|
/**
|
|
@@ -1407,6 +1457,9 @@ export class BaseCollectionViewLayout {
|
|
|
1407
1457
|
|
|
1408
1458
|
protected releaseHeaderSupplementaryView(): void {
|
|
1409
1459
|
if (this.headerSupplementaryView) {
|
|
1460
|
+
if (this.headerSupplementaryView.supportsRowFocusPercent) {
|
|
1461
|
+
this.row.parent?.getFocusManager?.().unregisterRowFocusPercentHeader?.(this.headerSupplementaryView);
|
|
1462
|
+
}
|
|
1410
1463
|
if (this.headerSupplementaryViewIsPooled) {
|
|
1411
1464
|
this.instancePool.release(this.headerSupplementaryView);
|
|
1412
1465
|
} else {
|