@@ -333,8 +333,33 @@ typedef enum EditorMenuAction {
333333 EDITOR_MENU_ACTION_RESET_ACCUMULATION ,
334334} EditorMenuAction ;
335335
336- static void queueEditorMenuAction (Session * session , EditorMenuAction action , const char * currentScenePath ) {
336+ static bool editorMenuActionRequiresInactiveRender (EditorMenuAction action ) {
337+ switch (action ) {
338+ case EDITOR_MENU_ACTION_OPEN_SCENE :
339+ case EDITOR_MENU_ACTION_RESET_SCENE :
340+ case EDITOR_MENU_ACTION_SAVE_SCENE :
341+ case EDITOR_MENU_ACTION_SAVE_SCENE_AS :
342+ case EDITOR_MENU_ACTION_IMPORT_MESH :
343+ case EDITOR_MENU_ACTION_LOAD_ENVIRONMENT :
344+ case EDITOR_MENU_ACTION_CLEAR_ENVIRONMENT :
345+ case EDITOR_MENU_ACTION_RESET_ACCUMULATION :
346+ return true;
347+ case EDITOR_MENU_ACTION_SAVE_RENDER :
348+ default :
349+ return false;
350+ }
351+ }
352+
353+ static void queueEditorMenuAction (
354+ Session * session ,
355+ const VKRT_RenderStatusSnapshot * status ,
356+ EditorMenuAction action ,
357+ const char * currentScenePath
358+ ) {
337359 if (!session ) return ;
360+ if (status && VKRT_renderStatusIsActive (status ) && editorMenuActionRequiresInactiveRender (action )) {
361+ return ;
362+ }
338363
339364 switch (action ) {
340365 case EDITOR_MENU_ACTION_OPEN_SCENE :
@@ -388,30 +413,31 @@ static void applyMainMenuShortcuts(
388413
389414 bool haveCurrentScenePath = (currentScenePath && currentScenePath [0 ]) != 0 ;
390415 bool canSaveRender = (status && VKRT_renderStatusIsComplete (status )) != 0 ;
416+ bool renderModeActive = (status && VKRT_renderStatusIsActive (status )) != 0 ;
391417
392- if (ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiKey_O )) {
393- queueEditorMenuAction (session , EDITOR_MENU_ACTION_OPEN_SCENE , currentScenePath );
418+ if (! renderModeActive && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiKey_O )) {
419+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_OPEN_SCENE , currentScenePath );
394420 }
395- if (haveCurrentScenePath && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiKey_S )) {
396- queueEditorMenuAction (session , EDITOR_MENU_ACTION_SAVE_SCENE , currentScenePath );
421+ if (! renderModeActive && haveCurrentScenePath && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiKey_S )) {
422+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_SAVE_SCENE , currentScenePath );
397423 }
398- if (ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S )) {
399- queueEditorMenuAction (session , EDITOR_MENU_ACTION_SAVE_SCENE_AS , currentScenePath );
424+ if (! renderModeActive && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_S )) {
425+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_SAVE_SCENE_AS , currentScenePath );
400426 }
401- if (ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiKey_I )) {
402- queueEditorMenuAction (session , EDITOR_MENU_ACTION_IMPORT_MESH , currentScenePath );
427+ if (! renderModeActive && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiKey_I )) {
428+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_IMPORT_MESH , currentScenePath );
403429 }
404- if (ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_E )) {
405- queueEditorMenuAction (session , EDITOR_MENU_ACTION_LOAD_ENVIRONMENT , currentScenePath );
430+ if (! renderModeActive && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_E )) {
431+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_LOAD_ENVIRONMENT , currentScenePath );
406432 }
407- if (canClearEnvironment && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiMod_Alt | ImGuiKey_E )) {
408- queueEditorMenuAction (session , EDITOR_MENU_ACTION_CLEAR_ENVIRONMENT , currentScenePath );
433+ if (! renderModeActive && canClearEnvironment && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiMod_Alt | ImGuiKey_E )) {
434+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_CLEAR_ENVIRONMENT , currentScenePath );
409435 }
410436 if (canSaveRender && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_R )) {
411- queueEditorMenuAction (session , EDITOR_MENU_ACTION_SAVE_RENDER , currentScenePath );
437+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_SAVE_RENDER , currentScenePath );
412438 }
413439 if (status && ImGui_IsKeyChordPressed (ImGuiMod_Ctrl | ImGuiKey_R )) {
414- queueEditorMenuAction (session , EDITOR_MENU_ACTION_RESET_ACCUMULATION , currentScenePath );
440+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_RESET_ACCUMULATION , currentScenePath );
415441 }
416442}
417443
@@ -423,40 +449,42 @@ static void drawFileMenu(
423449) {
424450 bool haveCurrentScenePath = (currentScenePath && currentScenePath [0 ]) != 0 ;
425451 bool canSaveRender = (status && VKRT_renderStatusIsComplete (status )) != 0 ;
452+ bool renderModeActive = (status && VKRT_renderStatusIsActive (status )) != 0 ;
453+ bool canModifyScene = !renderModeActive ;
426454
427455 if (!ImGui_BeginMenu ("File" )) return ;
428456
429- if (ImGui_MenuItemEx ("Open" , "\tCtrl+O" , false, true )) {
430- queueEditorMenuAction (session , EDITOR_MENU_ACTION_OPEN_SCENE , currentScenePath );
457+ if (ImGui_MenuItemEx ("Open" , "\tCtrl+O" , false, canModifyScene )) {
458+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_OPEN_SCENE , currentScenePath );
431459 }
432- if (ImGui_MenuItemEx ("Reset Scene" , NULL , false, haveCurrentScenePath )) {
433- queueEditorMenuAction (session , EDITOR_MENU_ACTION_RESET_SCENE , currentScenePath );
460+ if (ImGui_MenuItemEx ("Reset Scene" , NULL , false, canModifyScene && haveCurrentScenePath )) {
461+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_RESET_SCENE , currentScenePath );
434462 }
435- if (ImGui_MenuItemEx ("Save" , "\tCtrl+S" , false, haveCurrentScenePath )) {
436- queueEditorMenuAction (session , EDITOR_MENU_ACTION_SAVE_SCENE , currentScenePath );
463+ if (ImGui_MenuItemEx ("Save" , "\tCtrl+S" , false, canModifyScene && haveCurrentScenePath )) {
464+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_SAVE_SCENE , currentScenePath );
437465 }
438- if (ImGui_MenuItemEx ("Save As" , "\tCtrl+Shift+S" , false, true )) {
439- queueEditorMenuAction (session , EDITOR_MENU_ACTION_SAVE_SCENE_AS , currentScenePath );
466+ if (ImGui_MenuItemEx ("Save As" , "\tCtrl+Shift+S" , false, canModifyScene )) {
467+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_SAVE_SCENE_AS , currentScenePath );
440468 }
441469
442470 ImGui_Separator ();
443471 if (ImGui_BeginMenu ("Import" )) {
444- if (ImGui_MenuItemEx ("Mesh" , "\tCtrl+I" , false, true )) {
445- queueEditorMenuAction (session , EDITOR_MENU_ACTION_IMPORT_MESH , currentScenePath );
472+ if (ImGui_MenuItemEx ("Mesh" , "\tCtrl+I" , false, canModifyScene )) {
473+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_IMPORT_MESH , currentScenePath );
446474 }
447475 ImGui_EndMenu ();
448476 }
449477 if (ImGui_BeginMenu ("Environment" )) {
450- if (ImGui_MenuItemEx ("Load" , "\tCtrl+Shift+E" , false, true )) {
451- queueEditorMenuAction (session , EDITOR_MENU_ACTION_LOAD_ENVIRONMENT , currentScenePath );
478+ if (ImGui_MenuItemEx ("Load" , "\tCtrl+Shift+E" , false, canModifyScene )) {
479+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_LOAD_ENVIRONMENT , currentScenePath );
452480 }
453- if (ImGui_MenuItemEx ("Clear" , "\tCtrl+Alt+E" , false, canClearEnvironment )) {
454- queueEditorMenuAction (session , EDITOR_MENU_ACTION_CLEAR_ENVIRONMENT , currentScenePath );
481+ if (ImGui_MenuItemEx ("Clear" , "\tCtrl+Alt+E" , false, canModifyScene && canClearEnvironment )) {
482+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_CLEAR_ENVIRONMENT , currentScenePath );
455483 }
456484 ImGui_EndMenu ();
457485 }
458486 if (ImGui_MenuItemEx ("Save Render" , "\tCtrl+Shift+R" , false, canSaveRender )) {
459- queueEditorMenuAction (session , EDITOR_MENU_ACTION_SAVE_RENDER , currentScenePath );
487+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_SAVE_RENDER , currentScenePath );
460488 }
461489 ImGui_EndMenu ();
462490}
@@ -465,7 +493,7 @@ static void drawViewMenu(Session* session, const VKRT_RenderStatusSnapshot* stat
465493 if (!ImGui_BeginMenu ("View" )) return ;
466494
467495 if (ImGui_MenuItemEx ("Reset Accumulation" , "\tCtrl+R" , false, status != NULL )) {
468- queueEditorMenuAction (session , EDITOR_MENU_ACTION_RESET_ACCUMULATION , currentScenePath );
496+ queueEditorMenuAction (session , status , EDITOR_MENU_ACTION_RESET_ACCUMULATION , currentScenePath );
469497 }
470498 ImGui_Separator ();
471499 ImGui_MenuItemEx ("Panels" , NULL , false, false);
0 commit comments