@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
|
@@ -288,7 +288,14 @@ export class ButtonView<T extends ButtonState = ButtonState, R extends ISGNGroup
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
protected override updateViewStatus(viewStatus: ViewStatus) {
|
|
291
|
-
|
|
291
|
+
let resolvedStatus = viewStatus;
|
|
292
|
+
if (this.isSelected) {
|
|
293
|
+
if (viewStatus === ViewStatus.Normal) resolvedStatus = ViewStatus.Selected;
|
|
294
|
+
if (viewStatus === ViewStatus.Focused && this.activeStyle?.animated && this.activeStyle.focusSelected) {
|
|
295
|
+
resolvedStatus = ViewStatus.FocusSelected;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
super.updateViewStatus(resolvedStatus);
|
|
292
299
|
}
|
|
293
300
|
|
|
294
301
|
/**
|
|
@@ -308,8 +315,16 @@ export class ButtonView<T extends ButtonState = ButtonState, R extends ISGNGroup
|
|
|
308
315
|
override applyStateChanges(nextState?: T): void {
|
|
309
316
|
const pendingSelected = this.pendingState.isSelected;
|
|
310
317
|
const wasSelected = this.state.isSelected === true;
|
|
318
|
+
if (this.viewPhase === ViewPhase.Initial && pendingSelected === true && this.activeStyle?.animated) {
|
|
319
|
+
if (this.pendingState.viewStatus === undefined || this.pendingState.viewStatus === ViewStatus.Normal) {
|
|
320
|
+
this.pendingState.viewStatus = ViewStatus.Selected;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
311
323
|
super.applyStateChanges(nextState);
|
|
312
324
|
if (this.isFocused) {
|
|
325
|
+
if (pendingSelected !== undefined && this.activeStyle?.animated && this.activeStyle.focusSelected) {
|
|
326
|
+
this.updateViewStatus(this.isSelected ? ViewStatus.FocusSelected : ViewStatus.Focused);
|
|
327
|
+
}
|
|
313
328
|
return;
|
|
314
329
|
}
|
|
315
330
|
if (pendingSelected === true) {
|
|
@@ -74,6 +74,12 @@ export type ViewFragmentCallbackHandler = (
|
|
|
74
74
|
args?: unknown[],
|
|
75
75
|
) => void;
|
|
76
76
|
|
|
77
|
+
/** CollectionView presentation callback; receives a normalized focus value without rebinding content. */
|
|
78
|
+
export type ViewFragmentFocusPercentCallbackHandler = (
|
|
79
|
+
viewFragment: IViewFragment,
|
|
80
|
+
percent: number,
|
|
81
|
+
) => void;
|
|
82
|
+
|
|
77
83
|
export type ISpecificViewFragmentCallbackHandler = (
|
|
78
84
|
data: JsonData,
|
|
79
85
|
view: ISGNNode,
|
|
@@ -87,6 +93,8 @@ export enum ViewFragmentCallbackType {
|
|
|
87
93
|
OnApplyViewStatus = 'onApplyViewStatus',
|
|
88
94
|
OnDataChange = 'onDataChange',
|
|
89
95
|
OnSpecificViewDataChange = 'onSpecificViewDataChange',
|
|
96
|
+
OnFocusPercentChanged = 'onFocusPercentChanged',
|
|
97
|
+
OnRowFocusPercentChanged = 'onRowFocusPercentChanged',
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
export interface IViewFragmentCallbackMap {
|
|
@@ -95,10 +103,13 @@ export interface IViewFragmentCallbackMap {
|
|
|
95
103
|
onApplyViewStatus?: ViewFragmentCallbackHandler[];
|
|
96
104
|
onDataChange?: ViewFragmentCallbackHandler[];
|
|
97
105
|
onSpecificViewDataChange?: ISpecificViewFragmentCallbackHandler[];
|
|
106
|
+
onFocusPercentChanged?: ViewFragmentFocusPercentCallbackHandler[];
|
|
107
|
+
onRowFocusPercentChanged?: ViewFragmentFocusPercentCallbackHandler[];
|
|
98
108
|
}
|
|
99
109
|
|
|
100
110
|
export type FragmentCallbackEntry = string | AsyncFunctionPointer<ViewFragmentCallbackHandler>;
|
|
101
111
|
export type SpecificFragmentCallbackEntry = string | AsyncFunctionPointer<ISpecificViewFragmentCallbackHandler>;
|
|
112
|
+
export type FocusPercentFragmentCallbackEntry = string | AsyncFunctionPointer<ViewFragmentFocusPercentCallbackHandler>;
|
|
102
113
|
|
|
103
114
|
export interface IViewFragmentCallbackNameMap {
|
|
104
115
|
onMount?: FragmentCallbackEntry[];
|
|
@@ -106,6 +117,8 @@ export interface IViewFragmentCallbackNameMap {
|
|
|
106
117
|
onApplyViewStatus?: FragmentCallbackEntry[];
|
|
107
118
|
onDataChange?: FragmentCallbackEntry[];
|
|
108
119
|
onSpecificViewDataChange?: SpecificFragmentCallbackEntry[];
|
|
120
|
+
onFocusPercentChanged?: FocusPercentFragmentCallbackEntry[];
|
|
121
|
+
onRowFocusPercentChanged?: FocusPercentFragmentCallbackEntry[];
|
|
109
122
|
}
|
|
110
123
|
|
|
111
124
|
export interface IParsedFunctionMapping {
|
|
@@ -127,6 +140,10 @@ export interface IViewFragment {
|
|
|
127
140
|
styleKey: string;
|
|
128
141
|
view: ISGNGroup;
|
|
129
142
|
viewStatus: ViewStatus;
|
|
143
|
+
/** CollectionView-owned item focus from 0 to 1; present only for an opted-in cell fragment. */
|
|
144
|
+
focusPercent?: number;
|
|
145
|
+
/** CollectionView-owned row focus from 0 to 1; present only for an opted-in cell or header fragment. */
|
|
146
|
+
rowFocusPercent?: number;
|
|
130
147
|
dataMap: IViewFragmentDataMap;
|
|
131
148
|
/** Shared from the provider's resolved-style cache; avoids rebuilding the data/fn binding-id set per fragment and bind. */
|
|
132
149
|
dataMapBindingViewIds?: string[];
|
|
@@ -400,6 +417,13 @@ export type IStyle =
|
|
|
400
417
|
| IStyleDictionary;
|
|
401
418
|
|
|
402
419
|
|
|
420
|
+
/** Provisional focus-transition descriptor; endpoint values stay in the status styles. */
|
|
421
|
+
export interface IViewStyleAnimation {
|
|
422
|
+
properties: string[];
|
|
423
|
+
focusInMs: number;
|
|
424
|
+
focusOutMs: number;
|
|
425
|
+
}
|
|
426
|
+
|
|
403
427
|
export interface IStatefulStyle {
|
|
404
428
|
none?: IStyleDictionary;
|
|
405
429
|
normal: IStyleDictionary;
|
|
@@ -408,6 +432,8 @@ export interface IStatefulStyle {
|
|
|
408
432
|
error?: IStyleDictionary;
|
|
409
433
|
disabled?: IStyleDictionary;
|
|
410
434
|
focuseeSelected?: IStyleDictionary;
|
|
435
|
+
focusSelected?: IStyleDictionary;
|
|
436
|
+
animated?: IViewStyleAnimation;
|
|
411
437
|
}
|
|
412
438
|
|
|
413
439
|
export interface IFunctionMapping {
|
|
@@ -273,6 +273,11 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
273
273
|
protected _rendereredTranslationValue: [number, number] = [0, 0];
|
|
274
274
|
|
|
275
275
|
get _rendereredTranslation(): [number, number] {
|
|
276
|
+
const transition = this.activeAnimation;
|
|
277
|
+
if (transition && transition.ownsField(this as unknown as BaseView<ViewState>, 'translation')) {
|
|
278
|
+
const renderer = this.renderer;
|
|
279
|
+
if (renderer) return renderer.translation as [number, number];
|
|
280
|
+
}
|
|
276
281
|
return this._rendereredTranslationValue;
|
|
277
282
|
}
|
|
278
283
|
|
|
@@ -394,6 +399,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
394
399
|
}
|
|
395
400
|
|
|
396
401
|
set renderer(value: R | undefined) {
|
|
402
|
+
this.activeAnimation?.releaseView(this as unknown as BaseView<ViewState>);
|
|
397
403
|
if (this._renderer) {
|
|
398
404
|
// hs:exclude-from-platform roku - web only
|
|
399
405
|
this._renderer.boundView = undefined;
|
|
@@ -675,13 +681,15 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
675
681
|
if (!style) return undefined;
|
|
676
682
|
|
|
677
683
|
// Return the resolved style for the current viewStatus
|
|
678
|
-
this.activeStyleDictionary = style[this.viewStatus
|
|
684
|
+
this.activeStyleDictionary = ((style as JsonData)[this.viewStatus] ?? style.normal) as IStyleDictionary;
|
|
679
685
|
}
|
|
680
686
|
|
|
681
687
|
protected applyActiveStyleDictionary(): void {
|
|
682
688
|
|
|
683
689
|
|
|
684
690
|
if (this.activeStyle && (this.activeStyleViewStatus === ViewStatus.None || this.activeStyleViewStatus !== this.activeViewStatus)) {
|
|
691
|
+
const previousStatus = this.activeStyleViewStatus;
|
|
692
|
+
const previousTransition = this.activeAnimation;
|
|
685
693
|
if (this.activeViewStatus) {
|
|
686
694
|
this.activeStyleViewStatus = this.activeViewStatus;
|
|
687
695
|
} else {
|
|
@@ -721,6 +729,24 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
721
729
|
}
|
|
722
730
|
}
|
|
723
731
|
const nextState = nextStateData as T;
|
|
732
|
+
const focused = this.activeViewStatus === ViewStatus.Focused || this.activeViewStatus === ViewStatus.FocusSelected;
|
|
733
|
+
const previousWasFocusState = previousStatus === ViewStatus.Normal || previousStatus === ViewStatus.Selected
|
|
734
|
+
|| previousStatus === ViewStatus.Focused || previousStatus === ViewStatus.FocusSelected;
|
|
735
|
+
const isFocusState = focused || this.activeViewStatus === ViewStatus.Normal || this.activeViewStatus === ViewStatus.Selected;
|
|
736
|
+
const descriptor = this.activeStyle.animated;
|
|
737
|
+
let transition: HosannaViewAnimator | undefined;
|
|
738
|
+
if (descriptor && previousWasFocusState && isFocusState && this.viewPhase === ViewPhase.Mounted
|
|
739
|
+
&& Array.isArray(descriptor.properties)) {
|
|
740
|
+
const targets: JsonData = {};
|
|
741
|
+
for (const property of descriptor.properties) {
|
|
742
|
+
if (property === 'opacity' || property === 'scale' || property === 'labelOpacity'
|
|
743
|
+
|| property === 'backgroundColor' || property === 'color' || property === 'translation') {
|
|
744
|
+
targets[property] = nextStateData[property];
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
transition = HosannaViewAnimator.prepare(this as unknown as BaseView<ViewState>, targets,
|
|
748
|
+
focused ? descriptor.focusInMs : descriptor.focusOutMs);
|
|
749
|
+
}
|
|
724
750
|
// this.setState(nextState);
|
|
725
751
|
let isLayoutDirty = false;
|
|
726
752
|
const fields = layoutFields;
|
|
@@ -744,6 +770,10 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
744
770
|
//TODO - should we use the regular state invalidation api here, instead of this
|
|
745
771
|
//efficient shortcut.
|
|
746
772
|
this.applyStateChanges(nextState);
|
|
773
|
+
// Composite controls render their children, so their own layout fields also
|
|
774
|
+
// need the configured endpoint. Active transition fields remain excluded.
|
|
775
|
+
if (descriptor || previousTransition) this.applyLayoutStateToNativeRenderer(this.state);
|
|
776
|
+
transition?.startPrepared();
|
|
747
777
|
}
|
|
748
778
|
}
|
|
749
779
|
|
|
@@ -763,9 +793,19 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
763
793
|
this.nextViewId = 0;
|
|
764
794
|
|
|
765
795
|
//OPTIMIZE NO POINT MERGING IF WE ARE A NATIVE RENDERER
|
|
766
|
-
if (this.pendingState.styleKey) {
|
|
796
|
+
if (this.pendingState.styleKey && this.pendingState.styleKey !== this.activeStyleKey) {
|
|
767
797
|
console.debug('potential change that affects the style');
|
|
768
798
|
this.resolveActiveStyleDictionary(this.pendingState);
|
|
799
|
+
this.activeStyleKey = this.pendingState.styleKey;
|
|
800
|
+
if (this.pendingState.viewStatus !== undefined) {
|
|
801
|
+
this.activeViewStatus = this.pendingState.viewStatus;
|
|
802
|
+
delete this.pendingState.viewStatus;
|
|
803
|
+
}
|
|
804
|
+
if (this.activeStyle) {
|
|
805
|
+
this.applyActiveStyleDictionary();
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
this.activeAnimation?.handoff({}, {});
|
|
769
809
|
}
|
|
770
810
|
|
|
771
811
|
if (this.pendingState.viewStatus !== undefined) {
|
|
@@ -796,6 +836,8 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
796
836
|
}
|
|
797
837
|
}
|
|
798
838
|
|
|
839
|
+
const cancelledAnimation = this.activeAnimation?.reconcile(this as unknown as BaseView<ViewState>);
|
|
840
|
+
|
|
799
841
|
//NOTE - REALLY WE WILL WANT TO BE DOING SOMETHIG FAR MORE EFFICIENT HERE.
|
|
800
842
|
// Now that state is updated, calculate what the views should be
|
|
801
843
|
//WHAT SHOULD LIKELY HAPPEN HERE IS THAT WE SHOULD HAVE A CACHE OF STRUCTS LOCALLY BY INITIAL ID
|
|
@@ -831,7 +873,8 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
831
873
|
|
|
832
874
|
//TODO we might want to measure and tell the layout manager to lay us out.
|
|
833
875
|
// this.layoutChildren();
|
|
834
|
-
this.applyLayoutStateToNativeRenderer(this.isWaking ? this.buildLayoutStateForWakingNativeRenderer()
|
|
876
|
+
this.applyLayoutStateToNativeRenderer(this.isWaking ? this.buildLayoutStateForWakingNativeRenderer()
|
|
877
|
+
: cancelledAnimation ? this.state : this.pendingState);
|
|
835
878
|
//END: THERE IS AN ARGUMENT TO SAY DONT BOTHER GETTING VIEWS IN THIS CASE
|
|
836
879
|
|
|
837
880
|
// this.applyChildFocus();
|
|
@@ -1048,6 +1091,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
1048
1091
|
//HACK
|
|
1049
1092
|
//HACK
|
|
1050
1093
|
fieldsToUpdate['id'] = this._hid;
|
|
1094
|
+
this.excludeAnimatedRendererFields(fieldsToUpdate);
|
|
1051
1095
|
this.renderer.update(fieldsToUpdate);
|
|
1052
1096
|
}
|
|
1053
1097
|
}
|
|
@@ -1060,16 +1104,18 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
1060
1104
|
const renderer = this.renderer as any;
|
|
1061
1105
|
if (renderer) {
|
|
1062
1106
|
if (renderer.translation) {
|
|
1063
|
-
renderer.translation = [x, y];
|
|
1107
|
+
if (!this.activeAnimation?.ownsField(this as unknown as BaseView<ViewState>, 'translation')) renderer.translation = [x, y];
|
|
1064
1108
|
this._rendereredTranslation = [x, y];
|
|
1065
1109
|
}
|
|
1066
1110
|
// Use calculatedWidth/calculatedHeight if available (from measure()), otherwise use width/height
|
|
1067
1111
|
const width = this.calculatedWidth || this.width;
|
|
1068
|
-
if (width !== 0 && renderer.width !== undefined
|
|
1112
|
+
if (width !== 0 && renderer.width !== undefined
|
|
1113
|
+
&& !this.activeAnimation?.ownsField(this as unknown as BaseView<ViewState>, 'width')) {
|
|
1069
1114
|
renderer.width = width;
|
|
1070
1115
|
}
|
|
1071
1116
|
const height = this.calculatedHeight || this.height;
|
|
1072
|
-
if (height !== 0 && renderer.height !== undefined
|
|
1117
|
+
if (height !== 0 && renderer.height !== undefined
|
|
1118
|
+
&& !this.activeAnimation?.ownsField(this as unknown as BaseView<ViewState>, 'height')) {
|
|
1073
1119
|
renderer.height = height;
|
|
1074
1120
|
}
|
|
1075
1121
|
}
|
|
@@ -1859,9 +1905,24 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
1859
1905
|
}
|
|
1860
1906
|
}
|
|
1861
1907
|
|
|
1908
|
+
this.excludeAnimatedRendererFields(updateFields);
|
|
1862
1909
|
this.renderer.update(updateFields);
|
|
1863
1910
|
}
|
|
1864
1911
|
|
|
1912
|
+
private excludeAnimatedRendererFields(fields: Record<string, unknown>): void {
|
|
1913
|
+
const transition = this.activeAnimation;
|
|
1914
|
+
if (!transition) return;
|
|
1915
|
+
for (const field in fields) {
|
|
1916
|
+
if (transition.ownsField(this as unknown as BaseView<ViewState>, field)) delete fields[field];
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
/** @internal Reconcile remaining presentation after an explicit value cancels a transition. */
|
|
1921
|
+
invalidateAnimationPresentation(): void {
|
|
1922
|
+
this.isDirty = true;
|
|
1923
|
+
this.viewManager.invalidateViewState(this);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1865
1926
|
//sets the entire state
|
|
1866
1927
|
setState(state: Partial<T>): void {
|
|
1867
1928
|
for (const field in state) {
|
|
@@ -2188,6 +2249,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
2188
2249
|
* Only runs onReleaseRenderer when renderer is defined; overrides may treat `renderer` as non-null.
|
|
2189
2250
|
*/
|
|
2190
2251
|
protected releaseRenderer(): void {
|
|
2252
|
+
this.activeAnimation?.releaseView(this as unknown as BaseView<ViewState>);
|
|
2191
2253
|
const renderer = this.renderer;
|
|
2192
2254
|
if (renderer === undefined) {
|
|
2193
2255
|
return;
|
|
@@ -2202,6 +2264,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
2202
2264
|
* The recipient must eventually unmount and release the returned renderer.
|
|
2203
2265
|
*/
|
|
2204
2266
|
protected detachRenderer(): R | undefined {
|
|
2267
|
+
this.activeAnimation?.releaseView(this as unknown as BaseView<ViewState>);
|
|
2205
2268
|
const renderer = this._renderer;
|
|
2206
2269
|
this._renderer = undefined;
|
|
2207
2270
|
// hs:exclude-from-platform roku
|
|
@@ -2697,6 +2760,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
2697
2760
|
* even when the logical value equals the class default.
|
|
2698
2761
|
*/
|
|
2699
2762
|
onWillReuse(): void {
|
|
2763
|
+
this.activeAnimation?.releaseView(this as unknown as BaseView<ViewState>);
|
|
2700
2764
|
this.recycleViewModel();
|
|
2701
2765
|
this.cancelActiveViewDrag();
|
|
2702
2766
|
const className = this._cacheKey;
|
|
@@ -7,7 +7,7 @@ import { ISGNGroup, ISGNScene, ISGNNode, ISGNPoster } from '@hs-src/hosanna-brid
|
|
|
7
7
|
import { IBaseCollectionViewRow } from '@hs-src/hosanna-list/CollectionViewAPI';
|
|
8
8
|
import { JsonData } from '../../async/AsyncApi';
|
|
9
9
|
import { ViewStatus } from '../../hosanna-api';
|
|
10
|
-
import { IFragmentStyle, IStyleDictionary, IViewFragment, IViewFragmentDataMap, AppConfig, ViewFragmentCallbackHandler, ViewFragmentCallbackType, ISpecificViewFragmentCallbackHandler, IParsedFunctionMapping, FragmentCallbackEntry, SpecificFragmentCallbackEntry } from './AppConfig';
|
|
10
|
+
import { IFragmentStyle, IStyleDictionary, IViewFragment, IViewFragmentDataMap, AppConfig, ViewFragmentCallbackHandler, ViewFragmentCallbackType, ISpecificViewFragmentCallbackHandler, IParsedFunctionMapping, FragmentCallbackEntry, SpecificFragmentCallbackEntry, ViewFragmentFocusPercentCallbackHandler, FocusPercentFragmentCallbackEntry } from './AppConfig';
|
|
11
11
|
import { findNode, mapChildrenById } from './utils';
|
|
12
12
|
import { SystemMessageLevel } from '@hs-src/hosanna-bridge-lib/ISystemMessageManager';
|
|
13
13
|
import { isComputedReference, substituteComputedReferences } from '@hs-src/hosanna-ui/lib/FragmentComputed';
|
|
@@ -119,7 +119,7 @@ export interface IViewFragmentProvider {
|
|
|
119
119
|
* @param name - The name of the callback handler.
|
|
120
120
|
* @param handler - The callback handler function.
|
|
121
121
|
*/
|
|
122
|
-
registerViewFragmentCallback<T extends ViewFragmentCallbackHandler | ISpecificViewFragmentCallbackHandler>(type: ViewFragmentCallbackType, name: string, handler: T): void;
|
|
122
|
+
registerViewFragmentCallback<T extends ViewFragmentCallbackHandler | ISpecificViewFragmentCallbackHandler | ViewFragmentFocusPercentCallbackHandler>(type: ViewFragmentCallbackType, name: string, handler: T): void;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Debug-only: fragments currently checked out (not in available pool) with dangling hints.
|
|
@@ -183,7 +183,7 @@ export class ViewFragmentProvider implements IViewFragmentProvider {
|
|
|
183
183
|
private viewsThatNeedToBeRemovedById: Record<string, ISGNGroup> = {};
|
|
184
184
|
|
|
185
185
|
/** Registry for callback types and names mapped to handler functions. */
|
|
186
|
-
private callbackRegistry: { [type in ViewFragmentCallbackType]?: { [name: string]: ViewFragmentCallbackHandler | ISpecificViewFragmentCallbackHandler } } = {};
|
|
186
|
+
private callbackRegistry: { [type in ViewFragmentCallbackType]?: { [name: string]: ViewFragmentCallbackHandler | ISpecificViewFragmentCallbackHandler | ViewFragmentFocusPercentCallbackHandler } } = {};
|
|
187
187
|
private uniqueSGId = 0;
|
|
188
188
|
|
|
189
189
|
/** Fragments currently checked out from the available pool (not in free stacks). */
|
|
@@ -528,7 +528,7 @@ export class ViewFragmentProvider implements IViewFragmentProvider {
|
|
|
528
528
|
viewStatus: ViewStatus.Normal,
|
|
529
529
|
dataMapViewsById: {} as Record<string, ISGNGroup>,
|
|
530
530
|
$supportsDataMap: styleJson.$supportsDataMap || false,
|
|
531
|
-
callbacks: {} as { [type in ViewFragmentCallbackType]?: ViewFragmentCallbackHandler[] },
|
|
531
|
+
callbacks: {} as { [type in ViewFragmentCallbackType]?: (ViewFragmentCallbackHandler | ViewFragmentFocusPercentCallbackHandler)[] },
|
|
532
532
|
specificViewCallbacks: {} as { [key: string]: ISpecificViewFragmentCallbackHandler },
|
|
533
533
|
viewsById: viewsById,
|
|
534
534
|
refreshEffectStyles: Object.keys(effectStyleKeysById).length ? refreshEffectStyles : undefined,
|
|
@@ -563,6 +563,10 @@ export class ViewFragmentProvider implements IViewFragmentProvider {
|
|
|
563
563
|
const key = typeKey as ViewFragmentCallbackType;
|
|
564
564
|
const entries = callbacks[key];
|
|
565
565
|
if (entries) {
|
|
566
|
+
if (key === ViewFragmentCallbackType.OnFocusPercentChanged || key === ViewFragmentCallbackType.OnRowFocusPercentChanged) {
|
|
567
|
+
fragment.callbacks[key] = this.resolveFocusPercentCallbacks(key, entries as FocusPercentFragmentCallbackEntry[]);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
566
570
|
fragment.callbacks[key] = (entries as (FragmentCallbackEntry | SpecificFragmentCallbackEntry)[]).map(entry => {
|
|
567
571
|
if (typeof entry === 'string') {
|
|
568
572
|
const handler = this.callbackRegistry[key]?.[entry];
|
|
@@ -684,6 +688,36 @@ export class ViewFragmentProvider implements IViewFragmentProvider {
|
|
|
684
688
|
return fragment as unknown as IViewFragment;
|
|
685
689
|
}
|
|
686
690
|
|
|
691
|
+
private resolveFocusPercentCallbacks(
|
|
692
|
+
callbackType: ViewFragmentCallbackType,
|
|
693
|
+
entries: FocusPercentFragmentCallbackEntry[],
|
|
694
|
+
): ViewFragmentFocusPercentCallbackHandler[] {
|
|
695
|
+
const handlers: ViewFragmentFocusPercentCallbackHandler[] = [];
|
|
696
|
+
for (const entry of entries) {
|
|
697
|
+
let handler: ViewFragmentFocusPercentCallbackHandler | undefined;
|
|
698
|
+
if (typeof entry === 'string') {
|
|
699
|
+
handler = this.callbackRegistry[callbackType]?.[entry] as ViewFragmentFocusPercentCallbackHandler | undefined;
|
|
700
|
+
if (__ROKU__) {
|
|
701
|
+
if (!handler) {
|
|
702
|
+
try {
|
|
703
|
+
handler = hs_resolveAsyncFunctionPointer(entry as unknown as AsyncFunctionPointer<ViewFragmentFocusPercentCallbackHandler>);
|
|
704
|
+
} catch {
|
|
705
|
+
// An unregistered name may not be a resolvable native function pointer.
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
} else if (typeof entry === 'function') {
|
|
710
|
+
handler = entry;
|
|
711
|
+
}
|
|
712
|
+
if (handler) {
|
|
713
|
+
handlers.push(handler);
|
|
714
|
+
} else {
|
|
715
|
+
console.error(`Callback for ${callbackType} could not be resolved`);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return handlers;
|
|
719
|
+
}
|
|
720
|
+
|
|
687
721
|
/**
|
|
688
722
|
* Releases a fragment, making it available for reuse.
|
|
689
723
|
* @param fragment The fragment to release.
|
|
@@ -1155,7 +1189,7 @@ export class ViewFragmentProvider implements IViewFragmentProvider {
|
|
|
1155
1189
|
* @param name - The name used in style JSON.
|
|
1156
1190
|
* @param handler - The function implementation.
|
|
1157
1191
|
*/
|
|
1158
|
-
registerViewFragmentCallback<T extends ViewFragmentCallbackHandler | ISpecificViewFragmentCallbackHandler>(callbackType: ViewFragmentCallbackType, name: string, handler: T): void {
|
|
1192
|
+
registerViewFragmentCallback<T extends ViewFragmentCallbackHandler | ISpecificViewFragmentCallbackHandler | ViewFragmentFocusPercentCallbackHandler>(callbackType: ViewFragmentCallbackType, name: string, handler: T): void {
|
|
1159
1193
|
if (!this.callbackRegistry[callbackType]) {
|
|
1160
1194
|
this.callbackRegistry[callbackType] = {};
|
|
1161
1195
|
}
|
|
@@ -98,7 +98,7 @@ export class ImageView<T extends ImageState = ImageState, R extends ISGNPoster =
|
|
|
98
98
|
render(changes: Partial<T>): void {
|
|
99
99
|
super.render(changes);
|
|
100
100
|
if (this.renderer) {
|
|
101
|
-
this.renderer.blendColor = this.color;
|
|
101
|
+
if (!this.activeAnimation?.ownsField(this, 'blendColor')) this.renderer.blendColor = this.color;
|
|
102
102
|
this.renderer.loadingBitmapOpacity = this.loadingBitmapOpacity;
|
|
103
103
|
this.renderer.loadingBitmapUri = this.loadingBitmapUri;
|
|
104
104
|
this.renderer.failedBitmapOpacity = this.failedBitmapOpacity;
|
|
@@ -134,12 +134,12 @@ export class LabelView<T extends LabelState = LabelState, R extends ISGNLabel =
|
|
|
134
134
|
this.calculatedY = y;
|
|
135
135
|
|
|
136
136
|
if (this.renderer) {
|
|
137
|
-
this.renderer.translation = [x, y];
|
|
137
|
+
if (!this.activeAnimation?.ownsField(this, 'translation')) this.renderer.translation = [x, y];
|
|
138
138
|
this._rendereredTranslation = [x, y];
|
|
139
|
-
if (this.width) {
|
|
139
|
+
if (this.width && !this.activeAnimation?.ownsField(this, 'width')) {
|
|
140
140
|
this.renderer.width = this.width;
|
|
141
141
|
}
|
|
142
|
-
if (this.height) {
|
|
142
|
+
if (this.height && !this.activeAnimation?.ownsField(this, 'height')) {
|
|
143
143
|
this.renderer.height = this.height;
|
|
144
144
|
}
|
|
145
145
|
}
|