@@ -1148,19 +1148,16 @@ namespace microgui {
11481148 * Holds other components,
11491149 * One component is active at a time
11501150 */
1151- export class Window extends Scene {
1151+ export class GUIComponentScene extends Scene {
11521152 private components : GUIComponentAbstract [ ] ;
11531153 private currentComponentID : number ;
1154- private actAsScene : boolean ;
1155- private show : boolean ;
11561154
11571155 constructor ( opts : {
11581156 app : AppInterface ,
11591157 colour ?: number ,
11601158 next ?: ( arg0 : any [ ] ) => void ,
11611159 back ?: ( arg0 : any [ ] ) => void ,
1162- components ?: GUIComponentAbstract [ ] ,
1163- actAsScene ?: boolean
1160+ components ?: GUIComponentAbstract [ ]
11641161 } ) {
11651162 super ( opts . app )
11661163
@@ -1169,24 +1166,18 @@ namespace microgui {
11691166
11701167 this . components = opts . components
11711168 this . currentComponentID = 0
1172- this . actAsScene = ( opts . actAsScene != null ) ? opts . actAsScene : false ;
1173- this . show = ( this . actAsScene ) ? true : false ;
1174-
1175- if ( this . components != null )
1176- this . focus ( true )
1177-
1178- input . onButtonPressed ( 1 , function ( ) {
1179- this . currentComponentID = ( this . currentComponentID + 1 ) % this . componentQty
1180- this . focus ( true )
1181- } )
11821169 }
11831170
11841171 public activate ( ) {
1185- this . show = true ;
1172+ super . activate ( ) ;
1173+ this . focus ( true )
11861174 }
11871175
11881176 public deactivate ( ) {
1189- this . show = false ;
1177+ super . activate ( ) ;
1178+
1179+ this . components [ this . currentComponentID ] . hide ( )
1180+ this . components [ this . currentComponentID ] . unmakeActive ( )
11901181 }
11911182
11921183 public makeComponentActive ( componentID : number , hideOthers : boolean ) {
@@ -1216,27 +1207,25 @@ namespace microgui {
12161207 }
12171208
12181209 draw ( ) {
1219- if ( this . show ) {
1220- super . draw ( )
1221-
1222- screen ( ) . fillRect (
1223- 0 ,
1224- 0 ,
1225- screen ( ) . width ,
1226- screen ( ) . height ,
1227- this . backgroundColor
1228- )
1210+ super . draw ( )
12291211
1230- if ( this . components != null ) {
1231- this . components . forEach ( component => {
1232- if ( ! component . hidden && ! component . active )
1233- component . draw ( )
1234- } )
1235- }
1212+ screen ( ) . fillRect (
1213+ 0 ,
1214+ 0 ,
1215+ screen ( ) . width ,
1216+ screen ( ) . height ,
1217+ this . backgroundColor
1218+ )
12361219
1237- // Always draw active ontop
1238- this . components [ this . currentComponentID ] . draw ( )
1220+ if ( this . components != null ) {
1221+ this . components . forEach ( component => {
1222+ if ( ! component . hidden && ! component . active )
1223+ component . draw ( )
1224+ } )
12391225 }
1226+
1227+ // Always draw active ontop
1228+ this . components [ this . currentComponentID ] . draw ( )
12401229 }
12411230 }
12421231
0 commit comments