@@ -14,7 +14,7 @@ import {FileSystem} from "./filesystem.js";
14
14
15
15
export default class ImguiApp
16
16
{
17
- constructor ( appname = "UntitledImguiApp" , version = "1.0.0" )
17
+ constructor ( appname = "UntitledImguiApp" , version = "1.0.0" , initLog = true )
18
18
{
19
19
console . debug ( "App Init " + new Date ( ) . toLocaleString ( ) ) ;
20
20
this . appname = appname ;
@@ -50,6 +50,11 @@ export default class ImguiApp
50
50
return this . IsMobileDevice ( ) ;
51
51
}
52
52
53
+ OnLogActivity ( msg , level )
54
+ {
55
+ // overridable
56
+ }
57
+
53
58
IsMobileDevice ( )
54
59
{
55
60
if ( ( typeof window . orientation !== "undefined" ) ||
@@ -128,14 +133,16 @@ export default class ImguiApp
128
133
}
129
134
}
130
135
131
- OnLoop ( time ) // called e.g. 60 fps
136
+ OnLoop ( time ) // called e.g. 60 fps, subclass may override
132
137
{
133
138
if ( ! this . canvas ) return ;
134
139
if ( this . imgui . NewFrame ( time ) )
135
140
{
136
141
this . ShowContextMenu ( this . imgui ) ;
137
- this . FileBrowser . Show ( this . imgui ) ; // manages its own IsOpen state
138
- this . Log . Show ( this . imgui , "Log" ) ;
142
+ if ( this . FileBrowser )
143
+ this . FileBrowser . Show ( this . imgui ) ; // manages its own IsOpen state
144
+ if ( this . Log )
145
+ this . Log . Show ( this . imgui , "Log" ) ;
139
146
this . OnFrame ( this . imgui ) ; // subclass hooks in here
140
147
this . imgui . Render ( ) ; // calls EndFrame
141
148
}
@@ -158,9 +165,12 @@ export default class ImguiApp
158
165
{
159
166
if ( imgui . BeginPopupContextVoid ( "ContextMenu" , 1 ) )
160
167
{
161
- if ( imgui . MenuItem ( "Log" , null , this . Log . IsShowing . get ( ) ) )
168
+ if ( this . Log )
162
169
{
163
- this . Log . IsShowing . toggle ( ) ;
170
+ if ( imgui . MenuItem ( "Log" , null , this . Log . IsShowing . get ( ) ) )
171
+ {
172
+ this . Log . IsShowing . toggle ( ) ;
173
+ }
164
174
}
165
175
166
176
this . AppendContextMenu ( imgui ) ;
0 commit comments