@@ -107,7 +107,6 @@ namespace microgui {
107107 border ?: boolean ,
108108 showBackground ?: boolean
109109 } ) {
110-
111110 super ( )
112111
113112 this . alignment = opts . alignment ;
@@ -976,6 +975,7 @@ namespace microgui {
976975 width : ( font . charWidth * ( this . text . length + 1 ) ) + 1 , // + 1 for the cursor in ButtonCollection to draw on top of.
977976 height : font . charHeight + 2
978977 } ) ;
978+
979979 this . shadowBounds = new Bounds ( {
980980 top : this . bounds . top ,
981981 left : this . bounds . left + 1 ,
@@ -1079,6 +1079,12 @@ namespace microgui {
10791079 this . setupButtonBindings ( ) ;
10801080 }
10811081
1082+
1083+ public makeActive ( ) {
1084+ super . makeActive ( ) ;
1085+ this . setupButtonBindings ( ) ;
1086+ }
1087+
10821088 setupButtonBindings ( ) {
10831089 unbindShieldButtons ( ) ;
10841090
@@ -1145,78 +1151,74 @@ namespace microgui {
11451151 * One component is active at a time
11461152 */
11471153 export class Window extends Scene {
1148- private static components : GUIComponentAbstract [ ] ;
1149- private static componentQty : number ;
1150- private static currentComponentID : number ;
1151- private static actAsScene : boolean ;
1152- private static show : boolean ;
1154+ private components : GUIComponentAbstract [ ] ;
1155+ private currentComponentID : number ;
1156+ private actAsScene : boolean ;
1157+ private show : boolean ;
11531158
11541159 constructor ( opts : {
11551160 app : AppInterface ,
11561161 colour ?: number ,
11571162 next ?: ( arg0 : any [ ] ) => void ,
11581163 back ?: ( arg0 : any [ ] ) => void ,
11591164 components ?: GUIComponentAbstract [ ] ,
1160- actAsScene ?: boolean ,
1161- hideByDefault ?: boolean
1165+ actAsScene ?: boolean
11621166 } ) {
11631167 super ( opts . app )
11641168
11651169 if ( opts . colour != null )
11661170 this . backgroundColor = opts . colour
11671171
1168- Window . components = opts . components
1169- Window . componentQty = Window . components . length
1170- Window . currentComponentID = 0
1171- Window . actAsScene = ( opts . actAsScene != null ) ? opts . actAsScene : false ;
1172- Window . show = ( Window . actAsScene ) ? true : false ;
1172+ this . components = opts . components
1173+ this . currentComponentID = 0
1174+ this . actAsScene = ( opts . actAsScene != null ) ? opts . actAsScene : false ;
1175+ this . show = ( this . actAsScene ) ? true : false ;
11731176
1174- if ( Window . components != null && opts . hideByDefault )
1175- Window . focus ( true )
1177+ if ( this . components != null )
1178+ this . focus ( true )
11761179
11771180 input . onButtonPressed ( 1 , function ( ) {
1178- Window . currentComponentID = ( Window . currentComponentID + 1 ) % Window . componentQty
1179- Window . focus ( true )
1181+ this . currentComponentID = ( this . currentComponentID + 1 ) % this . componentQty
1182+ this . focus ( true )
11801183 } )
11811184 }
11821185
11831186 public activate ( ) {
1184- Window . show = true ;
1187+ this . show = true ;
11851188 }
11861189
11871190 public deactivate ( ) {
1188- Window . show = false ;
1191+ this . show = false ;
11891192 }
11901193
1191-
1192- public static makeComponentActive ( componentID : number , hideOthers : boolean ) {
1193- Window . currentComponentID = componentID ;
1194- Window . focus ( hideOthers ) ;
1194+ public makeComponentActive ( componentID : number , hideOthers : boolean ) {
1195+ this . currentComponentID = componentID ;
1196+ this . focus ( hideOthers ) ;
11951197 }
11961198
1197- public static updateComponentsContext ( componentID : number , context : any [ ] ) {
1199+ public updateComponentsContext ( componentID : number , context : any [ ] ) {
11981200 this . components [ componentID ] . addContext ( context )
11991201 }
12001202
12011203 /* override */ startup ( ) {
12021204 super . startup ( )
12031205 }
12041206
1205- private static focus ( hideOthers : boolean ) {
1207+ private focus ( hideOthers : boolean ) {
12061208 if ( hideOthers )
1207- Window . components . forEach ( component => { component . hide ( ) } )
1208- Window . components . forEach ( component => { component . unmakeActive ( ) } )
1209+ this . components . forEach ( component => { component . hide ( ) } )
1210+ this . components . forEach ( component => { component . unmakeActive ( ) } )
12091211
1210- Window . components [ Window . currentComponentID ] . unHide ( )
1211- Window . components [ Window . currentComponentID ] . makeActive ( )
1212+ this . components [ this . currentComponentID ] . unHide ( )
1213+ this . components [ this . currentComponentID ] . makeActive ( )
12121214 }
12131215
12141216 showAllComponents ( ) {
1215- Window . components . forEach ( component => component . unHide ( ) )
1217+ this . components . forEach ( component => component . unHide ( ) )
12161218 }
12171219
12181220 draw ( ) {
1219- if ( Window . show ) {
1221+ if ( this . show ) {
12201222 super . draw ( )
12211223
12221224 screen ( ) . fillRect (
@@ -1227,15 +1229,15 @@ namespace microgui {
12271229 this . backgroundColor
12281230 )
12291231
1230- if ( Window . components != null ) {
1231- Window . components . forEach ( component => {
1232+ if ( this . components != null ) {
1233+ this . components . forEach ( component => {
12321234 if ( ! component . hidden && ! component . active )
12331235 component . draw ( )
12341236 } )
12351237 }
12361238
12371239 // Always draw active ontop
1238- Window . components [ Window . currentComponentID ] . draw ( )
1240+ this . components [ this . currentComponentID ] . draw ( )
12391241 }
12401242 }
12411243 }
0 commit comments