@@ -20,7 +20,6 @@ public class PanelRendering extends Panel {
20
20
public Map <String , String > layersStatus = new HashMap <>();
21
21
public String [] layers ;
22
22
public int layerIdx = 0 ;
23
- public SkijaLayer layer ;
24
23
25
24
// Layer status displayed on the right side from the layer name
26
25
public static final String CHECKED = "+" ;
@@ -48,57 +47,40 @@ public void bumpCounter(String reason) {
48
47
}
49
48
50
49
public void changeLayer () {
51
- if (layer != null ) {
52
- layer .close ();
53
- layer = null ;
54
- }
55
-
56
50
int attemptsCount = layers .length ;
57
51
58
- while (layer == null && attemptsCount > 0 ) {
52
+ while (attemptsCount > 0 ) {
59
53
attemptsCount -= 1 ;
60
54
String layerName = layers [layerIdx ];
61
55
String className = "io.github.humbleui.jwm.examples." + layerName ;
62
56
63
57
try {
64
- layer = (SkijaLayer ) Example .class .forName (className ).getDeclaredConstructor ().newInstance ();
58
+ SkijaLayer layer = (SkijaLayer ) Example .class .forName (className ).getDeclaredConstructor ().newInstance ();
65
59
layer .attach (window );
60
+ break ;
66
61
} catch (Exception e ) {
67
62
System .err .println ("Failed to create layer " + className );
68
63
e .printStackTrace ();
69
- layer = null ;
70
64
layersStatus .put (layerName , FAILED ); // Update layer status
71
65
nextLayerIdx ();
72
66
}
73
67
}
74
68
75
- if (layer == null )
69
+ if (window . _layer == null )
76
70
throw new RuntimeException ("No available layer to create" );
77
71
78
72
layersStatus .put (layers [layerIdx ], CHECKED ); // Mark layer as checked
79
- layer .reconfigure ();
80
- layer .resize (window .getContentRect ().getWidth (), window .getContentRect ().getHeight ());
81
73
}
82
74
83
75
@ Override
84
76
public void accept (Event e ) {
85
- if (e instanceof EventWindowScreenChange ) {
86
- layer .reconfigure ();
87
- accept (new EventWindowResize (window .getWindowRect ().getWidth (),
88
- window .getWindowRect ().getHeight (),
89
- window .getContentRect ().getWidth (),
90
- window .getContentRect ().getHeight ()));
91
- } else if (e instanceof EventWindowResize ee ) {
92
- layer .resize (ee .getContentWidth (), ee .getContentHeight ());
93
- } else if (e instanceof EventKey ee && ee .isPressed ()) {
77
+ if (e instanceof EventKey ee && ee .isPressed ()) {
94
78
Key key = ee .getKey ();
95
79
boolean modifier = ee .isModifierDown (Example .MODIFIER );
96
80
if (Key .L == key && modifier ) {
97
81
nextLayerIdx ();
98
82
changeLayer ();
99
83
}
100
- } else if (e instanceof EventWindowCloseRequest ) {
101
- layer .close ();
102
84
}
103
85
}
104
86
0 commit comments