Skip to content

Commit cfc7f21

Browse files
authored
(rsg) Implemented ProgressDialog node (#899)
* (rsg) Implemented ProgressDialog node * Fixed formatting
1 parent e068117 commit cfc7f21

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

docs/limitations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The **BrightScript Engine** implements the BrightScript language specification u
1414
* The basic nodes: `ContentNode`, `Group`, `Scene`, `Global`, `Timer`, `Rectangle`, `Poster`, `LayoutGroup` and `RSGPalette`
1515
* Typographic nodes: `Font`, `Label`, `ScrollingLabel` and `ScrollableText`
1616
* Grids and list nodes based on `ArrayGrid`: `PosterGrid`, `LabelList`, `CheckList`, `RadioButtonList`, `MarkupList`, `MarkupGrid`, `RowList` and `ZoomRowList`
17-
* Dialog related nodes: `Dialog`, `KeyboardDialog`, `PinDialog`, `StandardDialog`, `StandardProgressDialog`, `StdDlgProgressItem`, `StdDlgContentArea` and `StdDlgTitleArea`
17+
* Dialog related nodes: `Dialog`, `KeyboardDialog`, `PinDialog`, `ProgressDialog`, `StandardDialog`, `StandardProgressDialog`, `StdDlgProgressItem`, `StdDlgContentArea` and `StdDlgTitleArea`
1818
* Media related nodes: `Audio`, `SoundEffect`, `Video` and `TrickPlayBar`
1919
* Animation related nodes: `AnimationBase`, `Animation`, `SequentialAnimation`, `ParallelAnimation`, `ColorFieldInterpolator`, `FloatFieldInterpolator` and `Vector2DFieldInterpolator`
2020
* Panel related nodes: `OverhangPanelSetScene`, `PanelSet`, `Panel`, `GridPanel` and `ListPanel`

src/extensions/scenegraph/factory/NodeFactory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
StandardDialog,
6666
StandardKeyboardDialog,
6767
StandardProgressDialog,
68+
ProgressDialog,
6869
StdDlgContentArea,
6970
StdDlgProgressItem,
7071
StdDlgTitleArea,
@@ -227,6 +228,8 @@ export class SGNodeFactory {
227228
return new StandardKeyboardDialog([], name);
228229
case SGNodeType.StandardProgressDialog.toLowerCase():
229230
return new StandardProgressDialog([], name);
231+
case SGNodeType.ProgressDialog.toLowerCase():
232+
return new ProgressDialog([], name);
230233
case SGNodeType.StdDlgContentArea.toLowerCase():
231234
return new StdDlgContentArea([], name);
232235
case SGNodeType.StdDlgTitleArea.toLowerCase():
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { AAMember, BrsBoolean, BrsString, Float } from "brs-engine";
2+
import { FieldModel } from "../SGTypes";
3+
import { SGNodeType } from ".";
4+
import { Dialog } from "./Dialog";
5+
import { BusySpinner } from "./BusySpinner";
6+
7+
export class ProgressDialog extends Dialog {
8+
readonly defaultFields: FieldModel[] = [{ name: "busySpinner", type: "node" }];
9+
10+
protected readonly minHeight: number;
11+
private readonly spinner: BusySpinner;
12+
13+
constructor(initializedFields: AAMember[] = [], readonly name: string = SGNodeType.ProgressDialog) {
14+
super([], name);
15+
this.setExtendsType(name, SGNodeType.Dialog);
16+
17+
this.registerDefaultFields(this.defaultFields);
18+
this.registerInitializedFields(initializedFields);
19+
20+
this.spinner = new BusySpinner();
21+
22+
// Resize the dialog and position the spinner, resolution-aware
23+
let spinnerSize: number;
24+
let spinnerY: number;
25+
26+
if (this.resolution === "FHD") {
27+
spinnerSize = 120;
28+
spinnerY = this.dialogTrans[1] + 105 + this.vertOffset + this.gap;
29+
this.minHeight = 159 + spinnerSize + this.vertOffset * 2;
30+
} else {
31+
spinnerSize = 80;
32+
spinnerY = this.dialogTrans[1] + 70 + this.vertOffset + this.gap;
33+
this.minHeight = 106 + spinnerSize + this.vertOffset * 2;
34+
}
35+
this.height = this.minHeight;
36+
37+
// Center spinner horizontally within the dialog
38+
const spinnerX = this.dialogTrans[0] + (this.width - spinnerSize) / 2;
39+
this.spinner.setTranslation([spinnerX, spinnerY]);
40+
this.spinner.setValue("control", new BrsString("start"));
41+
this.setValueSilent("busySpinner", this.spinner);
42+
43+
// Adjust background height
44+
this.background.setValueSilent("height", new Float(this.minHeight));
45+
46+
// Hide elements not used by ProgressDialog
47+
this.message.setValueSilent("visible", BrsBoolean.False);
48+
this.icon.setValueSilent("visible", BrsBoolean.False);
49+
this.setValueSilent("iconUri", new BrsString(""));
50+
51+
this.appendChildToParent(this.spinner);
52+
}
53+
54+
protected updateChildren() {
55+
this.height = this.minHeight;
56+
const width = this.getValueJS("width") as number;
57+
if (width) {
58+
this.background.setValue("width", new Float(width));
59+
this.width = width;
60+
}
61+
this.copyField(this.background, "uri", "backgroundUri");
62+
this.copyField(this.title, "text", "title");
63+
this.copyField(this.title, "color", "titleColor");
64+
this.copyField(this.title, "font", "titleFont");
65+
this.copyField(this.divider, "uri", "dividerUri");
66+
67+
// Set dialog height and reposition elements
68+
const newY = (this.sceneRect.height - this.height) / 2;
69+
const offsetY = newY - this.dialogTrans[1];
70+
this.dialogTrans[1] = newY;
71+
this.background.setTranslation(this.dialogTrans);
72+
this.background.setValue("height", new Float(this.height));
73+
this.title.setTranslationOffset(0, offsetY);
74+
this.divider.setTranslationOffset(0, offsetY);
75+
this.spinner.setTranslationOffset(0, offsetY);
76+
}
77+
}

src/extensions/scenegraph/nodes/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export * from "./SoundEffect";
4343
export * from "./StandardDialog";
4444
export * from "./StandardKeyboardDialog";
4545
export * from "./StandardProgressDialog";
46+
export * from "./ProgressDialog";
4647
export * from "./StdDlgContentArea";
4748
export * from "./StdDlgProgressItem";
4849
export * from "./StdDlgTitleArea";
@@ -89,7 +90,7 @@ export enum SGNodeType {
8990
StandardMessageDialog = "StandardMessageDialog", // Not yet implemented
9091
StandardPinPadDialog = "StandardPinPadDialog", // Not yet implemented
9192
StandardProgressDialog = "StandardProgressDialog",
92-
ProgressDialog = "ProgressDialog", // Not yet implemented
93+
ProgressDialog = "ProgressDialog",
9394
StdDlgActionCardItem = "StdDlgActionCardItem", // Not yet implemented
9495
StdDlgAreaBase = "StdDlgAreaBase", // Not yet implemented
9596
StdDlgBulletTextItem = "StdDlgBulletTextItem", // Not yet implemented

0 commit comments

Comments
 (0)