@tantawowa/hosanna-ui 2.0.4 → 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 +33 -29
- package/package.json +1 -1
- package/src/hosanna-bridge-core/color.ts +140 -0
- package/src/hosanna-bridge-targets/web/brs/WebRoBitmap.ts +14 -0
- package/src/hosanna-bridge-targets/web/sg/WebSGPoster.ts +1 -1
- 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/app-roku/HosannaApp.xml +2 -1
- package/src/hosanna-ui/async/ImageGeneratorCommands.ts +0 -20
- package/src/hosanna-ui/lib/BaseApp.ts +11 -6
- package/src/hosanna-ui/lib/ConfigurationLoader.ts +11 -3
- package/src/hosanna-ui/lib/FragmentUtils.ts +26 -10
- package/src/hosanna-ui/lib/animation.ts +358 -235
- package/src/hosanna-ui/lib/shapes/ShapeLoader.ts +22 -27
- 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 +98 -21
- 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.0
|
|
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"
|
|
@@ -359,7 +363,7 @@
|
|
|
359
363
|
},
|
|
360
364
|
{
|
|
361
365
|
"path": "src/hosanna-bridge-targets/web/brs/WebRoBitmap.ts",
|
|
362
|
-
"sha256": "
|
|
366
|
+
"sha256": "b4be6ac206646f3cab6d8170b6115ec844577fb3a621fbf81b3dc3b1ad9b8b20"
|
|
363
367
|
},
|
|
364
368
|
{
|
|
365
369
|
"path": "src/hosanna-bridge-targets/web/brs/WebRoByteArray.ts",
|
|
@@ -887,7 +891,7 @@
|
|
|
887
891
|
},
|
|
888
892
|
{
|
|
889
893
|
"path": "src/hosanna-bridge-targets/web/sg/WebSGPoster.ts",
|
|
890
|
-
"sha256": "
|
|
894
|
+
"sha256": "8690f7310f0f3ee124530ec016f82a252aa408da403b514566b2ddfdd2f893e1"
|
|
891
895
|
},
|
|
892
896
|
{
|
|
893
897
|
"path": "src/hosanna-bridge-targets/web/sg/WebSGRectangle.ts",
|
|
@@ -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",
|
|
@@ -1843,7 +1847,7 @@
|
|
|
1843
1847
|
},
|
|
1844
1848
|
{
|
|
1845
1849
|
"path": "src/hosanna-ui/app-roku/HosannaApp.xml",
|
|
1846
|
-
"sha256": "
|
|
1850
|
+
"sha256": "027475b9fe1446b65f6961e690d150f3be988cac26be6578bf5cbc770cf5098f"
|
|
1847
1851
|
},
|
|
1848
1852
|
{
|
|
1849
1853
|
"path": "src/hosanna-ui/app-roku/HosannaMainThreadScene.xml",
|
|
@@ -1899,7 +1903,7 @@
|
|
|
1899
1903
|
},
|
|
1900
1904
|
{
|
|
1901
1905
|
"path": "src/hosanna-ui/async/ImageGeneratorCommands.ts",
|
|
1902
|
-
"sha256": "
|
|
1906
|
+
"sha256": "2bb5bef67aaafcb6877d3a43b790490d418659c8ca2e4db48b7cbeb25d58f7e6"
|
|
1903
1907
|
},
|
|
1904
1908
|
{
|
|
1905
1909
|
"path": "src/hosanna-ui/async/LivePlaylistCommands.ts",
|
|
@@ -1943,7 +1947,7 @@
|
|
|
1943
1947
|
},
|
|
1944
1948
|
{
|
|
1945
1949
|
"path": "src/hosanna-ui/lib/BaseApp.ts",
|
|
1946
|
-
"sha256": "
|
|
1950
|
+
"sha256": "b300ace1436dcfc41f7bb15e2d9ec5ebbf85f5c594e2967742311279a5968e2f"
|
|
1947
1951
|
},
|
|
1948
1952
|
{
|
|
1949
1953
|
"path": "src/hosanna-ui/lib/BuildConfigRuntimePath.ts",
|
|
@@ -1951,7 +1955,7 @@
|
|
|
1951
1955
|
},
|
|
1952
1956
|
{
|
|
1953
1957
|
"path": "src/hosanna-ui/lib/ConfigurationLoader.ts",
|
|
1954
|
-
"sha256": "
|
|
1958
|
+
"sha256": "be039919478eeb7eba4d686637731855c693676c18c517ff6700a9610029e643"
|
|
1955
1959
|
},
|
|
1956
1960
|
{
|
|
1957
1961
|
"path": "src/hosanna-ui/lib/ConfigurationValidator.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",
|
|
@@ -2343,7 +2347,7 @@
|
|
|
2343
2347
|
},
|
|
2344
2348
|
{
|
|
2345
2349
|
"path": "src/hosanna-ui/lib/shapes/ShapeLoader.ts",
|
|
2346
|
-
"sha256": "
|
|
2350
|
+
"sha256": "2ccc633a272f9efdacb5e7e52a7c5d7b2bf4db2d7131a9900542f68b8143146f"
|
|
2347
2351
|
},
|
|
2348
2352
|
{
|
|
2349
2353
|
"path": "src/hosanna-ui/lib/shapes/ShapeMaskResolver.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,6 +1,7 @@
|
|
|
1
1
|
import { WebDraw2D, WebDrawableSource } from './draw2d/WebDraw2D';
|
|
2
2
|
import { WebBrsComponent } from './WebBrsComponent';
|
|
3
3
|
import { WebRoFont } from './WebRoFont';
|
|
4
|
+
import { WebRoByteArray } from './WebRoByteArray';
|
|
4
5
|
|
|
5
6
|
interface BitmapSize {
|
|
6
7
|
width: number;
|
|
@@ -66,6 +67,19 @@ export class WebRoBitmap extends WebBrsComponent {
|
|
|
66
67
|
return this.height;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
GetPng(x: number, y: number, width: number, height: number): WebRoByteArray {
|
|
71
|
+
const canvas = document.createElement('canvas');
|
|
72
|
+
canvas.width = width;
|
|
73
|
+
canvas.height = height;
|
|
74
|
+
const context = canvas.getContext('2d');
|
|
75
|
+
if (!context) {
|
|
76
|
+
throw new Error('WebRoBitmap.GetPng requires a 2D canvas context');
|
|
77
|
+
}
|
|
78
|
+
context.drawImage(this.canvas, x, y, width, height, 0, 0, width, height);
|
|
79
|
+
const encoded = canvas.toDataURL('image/png').split(',')[1];
|
|
80
|
+
return new WebRoByteArray(Uint8Array.from(atob(encoded), character => character.charCodeAt(0)));
|
|
81
|
+
}
|
|
82
|
+
|
|
69
83
|
getCanvas(): CanvasImageSource {
|
|
70
84
|
return this.canvas;
|
|
71
85
|
}
|
|
@@ -285,7 +285,7 @@ export class WebSGPoster extends WebSGGroup implements ISGNPoster {
|
|
|
285
285
|
|
|
286
286
|
// Detect if content-related fields changed since last render
|
|
287
287
|
const resolvedUri = resolveImageUri(this.uri);
|
|
288
|
-
const ninePatch = isNinePatch(resolvedUri);
|
|
288
|
+
const ninePatch = isNinePatch(this.uri) || isNinePatch(resolvedUri);
|
|
289
289
|
const contentChanged = this._contentDirty ||
|
|
290
290
|
resolvedUri !== this._lastRenderedUri ||
|
|
291
291
|
this.blendColor !== this._lastRenderedBlendColor ||
|
|
@@ -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;
|