Skip to content

Commit 3aef9c5

Browse files
committed
Code to make the Window optionally behave as if it were a scene from user-interface-base
1 parent dd8cb44 commit 3aef9c5

1 file changed

Lines changed: 32 additions & 17 deletions

File tree

guiComponents.ts

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ namespace microgui {
66
import FORWARD_BUTTON_ERROR_KIND = user_interface_base.FORWARD_BUTTON_ERROR_KIND
77
import INavigator = user_interface_base.INavigator
88

9-
109
import Cursor = user_interface_base.Cursor
1110
import CursorDir = user_interface_base.CursorDir
1211
import Picker = user_interface_base.Picker
@@ -1149,13 +1148,16 @@ namespace microgui {
11491148
private static components: GUIComponentAbstract[];
11501149
private static componentQty: number;
11511150
private static currentComponentID: number;
1151+
private static actAsScene: boolean;
1152+
private static show: boolean;
11521153

11531154
constructor(opts: {
11541155
app: AppInterface,
11551156
colour?: number,
11561157
next?: (arg0: any[]) => void,
11571158
back?: (arg0: any[]) => void,
11581159
components?: GUIComponentAbstract[],
1160+
actAsScene?: boolean,
11591161
hideByDefault?: boolean
11601162
}) {
11611163
super(opts.app)
@@ -1166,6 +1168,8 @@ namespace microgui {
11661168
Window.components = opts.components
11671169
Window.componentQty = Window.components.length
11681170
Window.currentComponentID = 0
1171+
Window.actAsScene = (opts.actAsScene != null) ? opts.actAsScene : false;
1172+
Window.show = (Window.actAsScene) ? true : false;
11691173

11701174
if (Window.components != null && opts.hideByDefault)
11711175
Window.focus(true)
@@ -1176,6 +1180,15 @@ namespace microgui {
11761180
})
11771181
}
11781182

1183+
public activate() {
1184+
Window.show = true;
1185+
}
1186+
1187+
public deactivate() {
1188+
Window.show = false;
1189+
}
1190+
1191+
11791192
public static makeComponentActive(componentID: number, hideOthers: boolean) {
11801193
Window.currentComponentID = componentID;
11811194
Window.focus(hideOthers);
@@ -1203,25 +1216,27 @@ namespace microgui {
12031216
}
12041217

12051218
draw() {
1206-
super.draw()
1219+
if (Window.show) {
1220+
super.draw()
12071221

1208-
screen().fillRect(
1209-
0,
1210-
0,
1211-
screen().width,
1212-
screen().height,
1213-
this.backgroundColor
1214-
)
1222+
screen().fillRect(
1223+
0,
1224+
0,
1225+
screen().width,
1226+
screen().height,
1227+
this.backgroundColor
1228+
)
12151229

1216-
if (Window.components != null) {
1217-
Window.components.forEach(component => {
1218-
if (!component.hidden && !component.active)
1219-
component.draw()
1220-
})
1221-
}
1230+
if (Window.components != null) {
1231+
Window.components.forEach(component => {
1232+
if (!component.hidden && !component.active)
1233+
component.draw()
1234+
})
1235+
}
12221236

1223-
// Always draw active ontop
1224-
Window.components[Window.currentComponentID].draw()
1237+
// Always draw active ontop
1238+
Window.components[Window.currentComponentID].draw()
1239+
}
12251240
}
12261241
}
12271242

0 commit comments

Comments
 (0)