diff --git a/application/testing/CMakeLists.txt b/application/testing/CMakeLists.txt index fb19a41ef8..16d4b859da 100644 --- a/application/testing/CMakeLists.txt +++ b/application/testing/CMakeLists.txt @@ -926,6 +926,13 @@ f3d_test(NAME TestInteractionConsoleAutoCompleteHide DATA BoxAnimated.gltf INTER f3d_test(NAME TestInteractionConsoleHistory DATA BoxAnimated.gltf INTERACTION UI) #Escape;ro;Tab;45;Enter;set_c;Tab;top;Enter;Up;Up;Enter;Up;Up;Up;Up;Down;Down;Down;Down f3d_test(NAME TestInteractionConsoleHistoryEmpty DATA BoxAnimated.gltf INTERACTION UI)#Escape;Up;Down f3d_test(NAME TestInteractionConsoleHistoryHide DATA BoxAnimated.gltf INTERACTION UI)#Escape;a;Enter;b;Enter;Up;Escape;Escape;Escape;Up +f3d_test(NAME TestInteractionMinimalConsoleOpen DATA f3d.glb INTERACTION UI) #Colon +f3d_test(NAME TestInteractionMinimalConsoleEscape DATA f3d.glb INTERACTION UI) #Colon;Escape +f3d_test(NAME TestInteractionMinimalConsoleReturn DATA f3d.glb INTERACTION UI) #Colon;Return +f3d_test(NAME TestInteractionMinimalConsoleValidCommand DATA f3d.glb INTERACTION UI) #Colon;set_camera top;Return +f3d_test(NAME TestInteractionMinimalConsoleInvalidCommand DATA f3d.glb INTERACTION UI) #Colon;foo;Return +f3d_test(NAME TestInteractionMinimalConsoleResize DATA f3d.glb INTERACTION UI) #Colon;foo;Return;Colon +f3d_test(NAME TestInteractionMinimalConsoleBadgeRemains DATA f3d.glb INTERACTION UI) #Colon;foo;Return;Colon;Escape if (F3D_MODULE_TINYFILEDIALOGS) f3d_test(NAME TestInteractionFileOpen INTERACTION NO_BASELINE ENV CTEST_OPEN_DIALOG_FILE=${F3D_SOURCE_DIR}/testing/data/cow.vtp) diff --git a/doc/libf3d/OPTIONS.md b/doc/libf3d/OPTIONS.md index c6e69789da..7310ed160c 100644 --- a/doc/libf3d/OPTIONS.md +++ b/doc/libf3d/OPTIONS.md @@ -103,6 +103,7 @@ See the [APIs](#APIs) details below for more info. | ui.scalar_bar | bool
false
render | Show _scalar bar_ of the coloring by data array. | \-\-bar | | ui.cheatsheet | bool
false
render | Show a interaction cheatsheet | - | | ui.console | bool
false
render | Show the console | - | +| ui.minimal_console | bool
false
render | Show the minimal console. Useful to execute a quick command and exit. | - | | ui.filename | bool
false
render | Display the _filename info content_ on top of the window. | \-\-filename | | ui.filename_info | string
-
render | Content of _filename info_ to display. | - | | ui.font_file | path
optional
render | Use the provided FreeType compatible font file to display text.
Can be useful to display non-ASCII filenames. | \-\-font-file | diff --git a/doc/user/INTERACTIONS.md b/doc/user/INTERACTIONS.md index e13fe74441..9cb997a384 100644 --- a/doc/user/INTERACTIONS.md +++ b/doc/user/INTERACTIONS.md @@ -73,7 +73,8 @@ Other hotkeys and interactions are available: - H: key to toggle the display of a cheat sheet showing all these hotkeys and their statuses. - CTRL + Q: close the window and quit F3D. -- Esc: display/hide the console. +- Esc: display the console or hide console/minimal console. +- :: display the minimal console - Space: play the animation if any. - : load the previous file if any and reset the camera. - : load the next file if any and reset the camera. diff --git a/library/options.json b/library/options.json index 4e945b7268..092ae92c0e 100644 --- a/library/options.json +++ b/library/options.json @@ -178,6 +178,10 @@ "type": "bool", "default_value": "false" }, + "minimal_console": { + "type": "bool", + "default_value": "false" + }, "dropzone": { "type": "bool", "default_value": "false" diff --git a/library/src/interactor_impl.cxx b/library/src/interactor_impl.cxx index 5dea6b858b..67e1806253 100644 --- a/library/src/interactor_impl.cxx +++ b/library/src/interactor_impl.cxx @@ -259,10 +259,17 @@ class interactor_impl::internals const char* commandWithArgs = static_cast(data); self->Interactor.SetCommandBuffer(commandWithArgs); } - else if (event == vtkF3DConsoleOutputWindow::ShowEvent || - event == vtkF3DConsoleOutputWindow::HideEvent) + else if (event == vtkF3DConsoleOutputWindow::ShowEvent) { - self->Options.ui.console = (event == vtkF3DConsoleOutputWindow::ShowEvent); + // Invoked when console badge is clicked + self->Options.ui.console = true; + } + else if (event == vtkF3DConsoleOutputWindow::HideEvent) + { + // Invoked when esc key is pressed while in minimal console or console display, or when + // something is submitted to minimal console + self->Options.ui.console = false; + self->Options.ui.minimal_console = false; } self->RenderRequested = true; @@ -1153,6 +1160,7 @@ interactor& interactor_impl::initBindings() #if F3D_MODULE_UI this->addBinding({mod_t::NONE, "H"}, "toggle ui.cheatsheet", "Others", std::bind(docStr, "Toggle cheatsheet display")); this->addBinding({mod_t::NONE, "Escape"}, "toggle ui.console", "Others", std::bind(docStr, "Toggle console display")); + this->addBinding({mod_t::ANY, "Colon"}, "toggle ui.minimal_console", "Others", std::bind(docStr, "Toggle minimal console display")); #endif this->addBinding({mod_t::CTRL, "Q"}, "stop_interactor", "Others", std::bind(docStr, "Stop the interactor")); this->addBinding({mod_t::NONE, "Return"}, "reset_camera", "Others", std::bind(docStr, "Reset camera to initial parameters")); diff --git a/library/src/window_impl.cxx b/library/src/window_impl.cxx index 196f72045b..aeec9cae92 100644 --- a/library/src/window_impl.cxx +++ b/library/src/window_impl.cxx @@ -406,6 +406,7 @@ void window_impl::UpdateDynamicOptions() renderer->ShowMetaData(opt.ui.metadata); renderer->ShowCheatSheet(opt.ui.cheatsheet); renderer->ShowConsole(opt.ui.console); + renderer->ShowMinimalConsole(opt.ui.minimal_console); renderer->ShowDropZone(opt.ui.dropzone); renderer->SetDropZoneInfo(opt.ui.dropzone_info); renderer->ShowArmature(opt.render.armature.enable); diff --git a/testing/baselines/TestInteractionCheatsheetCentered.png b/testing/baselines/TestInteractionCheatsheetCentered.png index 9b5ec61b4a..a4ad5261b7 100644 --- a/testing/baselines/TestInteractionCheatsheetCentered.png +++ b/testing/baselines/TestInteractionCheatsheetCentered.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:46514e82883f45e7283b1a77cb2f9f9f7b52f87afc78e14cba55158a1f0eea98 -size 206924 +oid sha256:ae0094e51f36e6a6b41f648efa0988d311c8c068b0645a68e674ba657077c8b5 +size 210335 diff --git a/testing/baselines/TestInteractionCheatsheetOpacity.png b/testing/baselines/TestInteractionCheatsheetOpacity.png index 7dd5842f8e..bad5d21b1c 100644 --- a/testing/baselines/TestInteractionCheatsheetOpacity.png +++ b/testing/baselines/TestInteractionCheatsheetOpacity.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8774d57e505dc641ee6f33a062ae136bfb4f5d88c9bcf2b71af0121f1282d02d -size 83997 +oid sha256:e73dfad684c847db5f4dfa0cb206d4d3c0a5b2638cf6f6a74b74840c8a8f0a69 +size 86099 diff --git a/testing/baselines/TestInteractionMinimalConsoleBadgeRemains.png b/testing/baselines/TestInteractionMinimalConsoleBadgeRemains.png new file mode 100644 index 0000000000..338be15012 --- /dev/null +++ b/testing/baselines/TestInteractionMinimalConsoleBadgeRemains.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b60e0377387d31a0c47a8c7e4b3fa9195e3b80f46092e3d21e4f93a462391d85 +size 2698 diff --git a/testing/baselines/TestInteractionMinimalConsoleEscape.png b/testing/baselines/TestInteractionMinimalConsoleEscape.png new file mode 100644 index 0000000000..677455f95b --- /dev/null +++ b/testing/baselines/TestInteractionMinimalConsoleEscape.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48c3404e4042e16e6001231955a79779a8f8dd5fa3022547ddab3b0352bf2068 +size 2289 diff --git a/testing/baselines/TestInteractionMinimalConsoleInvalidCommand.png b/testing/baselines/TestInteractionMinimalConsoleInvalidCommand.png new file mode 100644 index 0000000000..338be15012 --- /dev/null +++ b/testing/baselines/TestInteractionMinimalConsoleInvalidCommand.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b60e0377387d31a0c47a8c7e4b3fa9195e3b80f46092e3d21e4f93a462391d85 +size 2698 diff --git a/testing/baselines/TestInteractionMinimalConsoleOpen.png b/testing/baselines/TestInteractionMinimalConsoleOpen.png new file mode 100644 index 0000000000..5abb7c4a21 --- /dev/null +++ b/testing/baselines/TestInteractionMinimalConsoleOpen.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68d521920052605e4367371b6fc0603613e1fc522a049521b5704beb3dc4b49e +size 2885 diff --git a/testing/baselines/TestInteractionMinimalConsoleResize.png b/testing/baselines/TestInteractionMinimalConsoleResize.png new file mode 100644 index 0000000000..df58f140de --- /dev/null +++ b/testing/baselines/TestInteractionMinimalConsoleResize.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f45fc9e7d89eeaa1a1374d6e9984128cfe240e9471385272a448507d620e89bf +size 3166 diff --git a/testing/baselines/TestInteractionMinimalConsoleReturn.png b/testing/baselines/TestInteractionMinimalConsoleReturn.png new file mode 100644 index 0000000000..677455f95b --- /dev/null +++ b/testing/baselines/TestInteractionMinimalConsoleReturn.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48c3404e4042e16e6001231955a79779a8f8dd5fa3022547ddab3b0352bf2068 +size 2289 diff --git a/testing/baselines/TestInteractionMinimalConsoleValidCommand.png b/testing/baselines/TestInteractionMinimalConsoleValidCommand.png new file mode 100644 index 0000000000..f19fe38665 --- /dev/null +++ b/testing/baselines/TestInteractionMinimalConsoleValidCommand.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c08f2d20734e52d4c1ba8a79a8640ba4fd1a59a563fb8b695dc8570fd7107bb +size 2183 diff --git a/testing/recordings/TestInteractionMinimalConsoleBadgeRemains.log b/testing/recordings/TestInteractionMinimalConsoleBadgeRemains.log new file mode 100644 index 0000000000..8fae369f70 --- /dev/null +++ b/testing/recordings/TestInteractionMinimalConsoleBadgeRemains.log @@ -0,0 +1,38 @@ +# StreamVersion 1.2 +RenderEvent 0 0 0 0 0 0 0 + +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +CharEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 + +KeyPressEvent 0 0 0 102 1 f 0 +CharEvent 0 0 0 102 1 f 0 +KeyReleaseEvent 0 0 0 102 1 f 0 + +KeyPressEvent 0 0 0 111 1 o 0 +CharEvent 0 0 0 111 1 o 0 +KeyReleaseEvent 0 0 0 111 1 o 0 + +KeyPressEvent 0 0 0 111 1 o 0 +CharEvent 0 0 0 111 1 o 0 +KeyReleaseEvent 0 0 0 111 1 o 0 + +KeyPressEvent 0 0 0 13 1 Return 0 +CharEvent 0 0 0 13 1 Return 0 +KeyReleaseEvent 0 0 0 13 1 Return 0 + +TimerEvent 351 169 0 0 0 0 0 + +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +CharEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 + +KeyPressEvent 0 0 0 27 1 Escape 0 +CharEvent 0 0 0 27 1 Escape 0 +KeyReleaseEvent 0 0 0 27 1 Escape 0 + +TimerEvent 351 169 0 0 0 0 0 diff --git a/testing/recordings/TestInteractionMinimalConsoleEscape.log b/testing/recordings/TestInteractionMinimalConsoleEscape.log new file mode 100644 index 0000000000..776e0fd14b --- /dev/null +++ b/testing/recordings/TestInteractionMinimalConsoleEscape.log @@ -0,0 +1,10 @@ +# StreamVersion 1.2 +RenderEvent 0 0 0 0 0 0 0 +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +CharEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 +KeyPressEvent 0 0 0 27 1 Escape 0 +CharEvent 0 0 0 27 1 Escape 0 +KeyReleaseEvent 0 0 0 27 1 Escape 0 diff --git a/testing/recordings/TestInteractionMinimalConsoleInvalidCommand.log b/testing/recordings/TestInteractionMinimalConsoleInvalidCommand.log new file mode 100644 index 0000000000..cb5ac7f672 --- /dev/null +++ b/testing/recordings/TestInteractionMinimalConsoleInvalidCommand.log @@ -0,0 +1,26 @@ +# StreamVersion 1.2 +RenderEvent 0 0 0 0 0 0 0 + +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +CharEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 + +KeyPressEvent 0 0 0 102 1 f 0 +CharEvent 0 0 0 102 1 f 0 +KeyReleaseEvent 0 0 0 102 1 f 0 + +KeyPressEvent 0 0 0 111 1 o 0 +CharEvent 0 0 0 111 1 o 0 +KeyReleaseEvent 0 0 0 111 1 o 0 + +KeyPressEvent 0 0 0 111 1 o 0 +CharEvent 0 0 0 111 1 o 0 +KeyReleaseEvent 0 0 0 111 1 o 0 + +KeyPressEvent 0 0 0 13 1 Return 0 +CharEvent 0 0 0 13 1 Return 0 +KeyReleaseEvent 0 0 0 13 1 Return 0 + +TimerEvent 351 169 0 0 0 0 0 diff --git a/testing/recordings/TestInteractionMinimalConsoleOpen.log b/testing/recordings/TestInteractionMinimalConsoleOpen.log new file mode 100644 index 0000000000..a0c8600add --- /dev/null +++ b/testing/recordings/TestInteractionMinimalConsoleOpen.log @@ -0,0 +1,6 @@ +# StreamVersion 1.2 +RenderEvent 0 0 0 0 0 0 0 +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 diff --git a/testing/recordings/TestInteractionMinimalConsoleResize.log b/testing/recordings/TestInteractionMinimalConsoleResize.log new file mode 100644 index 0000000000..b9590aa634 --- /dev/null +++ b/testing/recordings/TestInteractionMinimalConsoleResize.log @@ -0,0 +1,34 @@ +# StreamVersion 1.2 +RenderEvent 0 0 0 0 0 0 0 + +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +CharEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 + +KeyPressEvent 0 0 0 102 1 f 0 +CharEvent 0 0 0 102 1 f 0 +KeyReleaseEvent 0 0 0 102 1 f 0 + +KeyPressEvent 0 0 0 111 1 o 0 +CharEvent 0 0 0 111 1 o 0 +KeyReleaseEvent 0 0 0 111 1 o 0 + +KeyPressEvent 0 0 0 111 1 o 0 +CharEvent 0 0 0 111 1 o 0 +KeyReleaseEvent 0 0 0 111 1 o 0 + +KeyPressEvent 0 0 0 13 1 Return 0 +CharEvent 0 0 0 13 1 Return 0 +KeyReleaseEvent 0 0 0 13 1 Return 0 + +TimerEvent 351 169 0 0 0 0 0 + +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +CharEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 + +TimerEvent 351 169 0 0 0 0 0 diff --git a/testing/recordings/TestInteractionMinimalConsoleReturn.log b/testing/recordings/TestInteractionMinimalConsoleReturn.log new file mode 100644 index 0000000000..9752c413cd --- /dev/null +++ b/testing/recordings/TestInteractionMinimalConsoleReturn.log @@ -0,0 +1,10 @@ +# StreamVersion 1.2 +RenderEvent 0 0 0 0 0 0 0 +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +CharEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 +KeyPressEvent 0 0 0 13 1 Return 0 +CharEvent 0 0 0 13 1 Return 0 +KeyReleaseEvent 0 0 0 13 1 Return 0 diff --git a/testing/recordings/TestInteractionMinimalConsoleValidCommand.log b/testing/recordings/TestInteractionMinimalConsoleValidCommand.log new file mode 100644 index 0000000000..b0b3438252 --- /dev/null +++ b/testing/recordings/TestInteractionMinimalConsoleValidCommand.log @@ -0,0 +1,71 @@ +# StreamVersion 1.2 +RenderEvent 0 0 0 0 0 0 0 + +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 58 1 colon 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 59 1 semicolon 0 + +KeyPressEvent 0 0 0 115 1 s 0 +CharEvent 0 0 0 115 1 s 0 +KeyReleaseEvent 0 0 0 115 1 s 0 + +KeyPressEvent 0 0 0 101 1 e 0 +CharEvent 0 0 0 101 1 e 0 +KeyReleaseEvent 0 0 0 101 1 e 0 + +KeyPressEvent 0 0 0 116 1 t 0 +CharEvent 0 0 0 116 1 t 0 +KeyReleaseEvent 0 0 0 116 1 t 0 + +KeyPressEvent 0 0 1 0 1 Shift_L 0 +KeyPressEvent 0 0 1 95 1 underscore 0 +CharEvent 0 0 1 95 1 underscore 0 +KeyReleaseEvent 0 0 0 0 1 Shift_L 0 +KeyReleaseEvent 0 0 0 45 1 minus 0 + +KeyPressEvent 0 0 0 99 1 c 0 +CharEvent 0 0 0 99 1 c 0 +KeyReleaseEvent 0 0 0 99 1 c 0 + +KeyPressEvent 0 0 0 97 1 a 0 +CharEvent 0 0 0 97 1 a 0 +KeyReleaseEvent 0 0 0 97 1 a 0 + +KeyPressEvent 0 0 0 109 1 m 0 +CharEvent 0 0 0 109 1 m 0 +KeyReleaseEvent 0 0 0 109 1 m 0 + +KeyPressEvent 0 0 0 101 1 e 0 +CharEvent 0 0 0 101 1 e 0 +KeyReleaseEvent 0 0 0 101 1 e 0 + +KeyPressEvent 0 0 0 114 1 r 0 +CharEvent 0 0 0 114 1 r 0 +KeyReleaseEvent 0 0 0 114 1 r 0 + +KeyPressEvent 0 0 0 97 1 a 0 +CharEvent 0 0 0 97 1 a 0 +KeyReleaseEvent 0 0 0 97 1 a 0 + +KeyPressEvent 0 0 0 32 1 space 0 +CharEvent 0 0 0 32 1 space 0 +KeyReleaseEvent 0 0 0 32 1 space 0 + +KeyPressEvent 0 0 0 116 1 t 0 +CharEvent 0 0 0 116 1 t 0 +KeyReleaseEvent 0 0 0 116 1 t 0 + +KeyPressEvent 0 0 0 111 1 o 0 +CharEvent 0 0 0 111 1 o 0 +KeyReleaseEvent 0 0 0 111 1 o 0 + +KeyPressEvent 0 0 0 112 1 p 0 +CharEvent 0 0 0 112 1 p 0 +KeyReleaseEvent 0 0 0 112 1 p 0 + +KeyPressEvent 0 0 0 13 1 Return 0 +CharEvent 0 0 0 13 1 Return 0 +KeyReleaseEvent 0 0 0 13 1 Return 0 + +TimerEvent 351 169 0 0 0 0 0 diff --git a/vtkext/private/module/vtkF3DImguiActor.cxx b/vtkext/private/module/vtkF3DImguiActor.cxx index d5923fa6d6..63c505ee98 100644 --- a/vtkext/private/module/vtkF3DImguiActor.cxx +++ b/vtkext/private/module/vtkF3DImguiActor.cxx @@ -508,10 +508,10 @@ void vtkF3DImguiActor::RenderFpsCounter() } //---------------------------------------------------------------------------- -void vtkF3DImguiActor::RenderConsole() +void vtkF3DImguiActor::RenderConsole(bool minimal) { vtkF3DImguiConsole* console = vtkF3DImguiConsole::SafeDownCast(vtkOutputWindow::GetInstance()); - console->ShowConsole(); + console->ShowConsole(minimal); } //---------------------------------------------------------------------------- diff --git a/vtkext/private/module/vtkF3DImguiActor.h b/vtkext/private/module/vtkF3DImguiActor.h index f9516abd59..ac0ef22f80 100644 --- a/vtkext/private/module/vtkF3DImguiActor.h +++ b/vtkext/private/module/vtkF3DImguiActor.h @@ -84,7 +84,7 @@ class vtkF3DImguiActor : public vtkF3DUIActor /** * Render the console widget */ - void RenderConsole() override; + void RenderConsole(bool) override; /** * Render the console badge diff --git a/vtkext/private/module/vtkF3DImguiConsole.cxx b/vtkext/private/module/vtkF3DImguiConsole.cxx index 8a14d13246..3ba87ed95a 100644 --- a/vtkext/private/module/vtkF3DImguiConsole.cxx +++ b/vtkext/private/module/vtkF3DImguiConsole.cxx @@ -200,18 +200,42 @@ void vtkF3DImguiConsole::DisplayText(const char* text) } //---------------------------------------------------------------------------- -void vtkF3DImguiConsole::ShowConsole() +void vtkF3DImguiConsole::ShowConsole(bool minimal) { ImGuiViewport* viewport = ImGui::GetMainViewport(); - constexpr float margin = 30.f; + constexpr float marginConsole = 30.f; + constexpr float marginTopRight = 5.f; + const float padding = ImGui::GetStyle().WindowPadding.x + ImGui::GetStyle().FramePadding.x; - this->Pimpl->NewError = false; - this->Pimpl->NewWarning = false; + // explicitly calculate size of minimal console to avoid extra flashing frame + if (minimal) + { + if (this->Pimpl->NewError || this->Pimpl->NewWarning) + { + // prevent overlap with console badge in minimal console + ImGui::SetNextWindowPos(ImVec2(marginTopRight, marginTopRight)); + ImGui::SetNextWindowSize(ImVec2( + viewport->WorkSize.x - 2.f * marginConsole, ImGui::CalcTextSize(">").y + 2.f * padding)); + } + else + { + ImGui::SetNextWindowPos(ImVec2(marginTopRight, marginTopRight)); + ImGui::SetNextWindowSize(ImVec2( + viewport->WorkSize.x - 2.f * marginTopRight, ImGui::CalcTextSize(">").y + 2.f * padding)); + } + } + else + { + // minimal console shouldn't clear console badge + this->Pimpl->NewError = false; + this->Pimpl->NewWarning = false; + + ImGui::SetNextWindowPos(ImVec2(marginConsole, marginConsole)); + ImGui::SetNextWindowSize(ImVec2( + viewport->WorkSize.x - 2.f * marginConsole, viewport->WorkSize.y - 2.f * marginConsole)); + } - ImGui::SetNextWindowPos(ImVec2(margin, margin)); - ImGui::SetNextWindowSize( - ImVec2(viewport->WorkSize.x - 2.f * margin, viewport->WorkSize.y - 2.f * margin)); ImGui::SetNextWindowBgAlpha(0.9f); ImGuiWindowFlags winFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | @@ -228,58 +252,62 @@ void vtkF3DImguiConsole::ShowConsole() ImGui::Begin("Console", nullptr, winFlags); - // Log window - const float reservedHeight = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); - if (ImGui::BeginChild( - "LogRegion", ImVec2(0, -reservedHeight), 0, ImGuiWindowFlags_HorizontalScrollbar)) + // Log window, will only show if not in minimal mode + if (!minimal) { - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing - for (const auto& [severity, msg] : this->Pimpl->Logs) + const float reservedHeight = + ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); + if (ImGui::BeginChild( + "LogRegion", ImVec2(0, -reservedHeight), 0, ImGuiWindowFlags_HorizontalScrollbar)) { - bool hasColor = true; - - if (this->GetUseColoring()) + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing + for (const auto& [severity, msg] : this->Pimpl->Logs) { - switch (severity) + bool hasColor = true; + + if (this->GetUseColoring()) + { + switch (severity) + { + case Internals::LogType::Error: + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); + break; + case Internals::LogType::Warning: + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 0.0f, 1.0f)); + break; + case Internals::LogType::Typed: + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 1.0f, 1.0f, 1.0f)); + break; + case Internals::LogType::Completion: + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.6f, 1.0f, 0.6f, 1.0f)); + break; + default: + hasColor = false; + } + } + else { - case Internals::LogType::Error: - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); - break; - case Internals::LogType::Warning: - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 0.0f, 1.0f)); - break; - case Internals::LogType::Typed: - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 1.0f, 1.0f, 1.0f)); - break; - case Internals::LogType::Completion: - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.6f, 1.0f, 0.6f, 1.0f)); - break; - default: - hasColor = false; + hasColor = false; + } + + ImGui::TextUnformatted(msg.c_str()); + if (hasColor) + { + ImGui::PopStyleColor(); } - } - else - { - hasColor = false; } - ImGui::TextUnformatted(msg.c_str()); - if (hasColor) + if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) { - ImGui::PopStyleColor(); + ImGui::SetScrollHereY(1.0f); } - } - if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) - { - ImGui::SetScrollHereY(1.0f); + ImGui::PopStyleVar(); } + ImGui::EndChild(); - ImGui::PopStyleVar(); + ImGui::Separator(); } - ImGui::EndChild(); - - ImGui::Separator(); // input ImGuiInputTextFlags inputFlags = ImGuiInputTextFlags_EnterReturnsTrue | @@ -324,6 +352,12 @@ void vtkF3DImguiConsole::ShowConsole() { // No need to show completions after command is run this->Pimpl->ClearCompletions(); + + // exit console immediately after running command if in minimal mode + if (minimal) + { + this->InvokeEvent(vtkF3DImguiConsole::HideEvent); + } } ImGui::End(); @@ -337,16 +371,17 @@ void vtkF3DImguiConsole::ShowBadge() if (this->Pimpl->NewError || this->Pimpl->NewWarning) { constexpr float marginTopRight = 5.f; + const float padding = ImGui::GetStyle().WindowPadding.x + ImGui::GetStyle().FramePadding.x; ImVec2 winSize = ImGui::CalcTextSize("!"); - winSize.x += 2.f * (ImGui::GetStyle().WindowPadding.x + ImGui::GetStyle().FramePadding.x); - winSize.y += 2.f * (ImGui::GetStyle().WindowPadding.y + ImGui::GetStyle().FramePadding.y); + winSize.x += 2.f * padding; + winSize.y += 2.f * padding; ImGui::SetNextWindowPos( ImVec2(viewport->WorkSize.x - winSize.x - marginTopRight, marginTopRight)); ImGui::SetNextWindowSize(winSize); ImGuiWindowFlags winFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | - ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove; + ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove; ImGui::Begin("ConsoleAlert", nullptr, winFlags); diff --git a/vtkext/private/module/vtkF3DImguiConsole.h b/vtkext/private/module/vtkF3DImguiConsole.h index e918c10f46..d8069d35ae 100644 --- a/vtkext/private/module/vtkF3DImguiConsole.h +++ b/vtkext/private/module/vtkF3DImguiConsole.h @@ -37,7 +37,7 @@ class vtkF3DImguiConsole : public vtkF3DConsoleOutputWindow /** * Show console window */ - void ShowConsole(); + void ShowConsole(bool); /** * Show console badge diff --git a/vtkext/private/module/vtkF3DRenderer.cxx b/vtkext/private/module/vtkF3DRenderer.cxx index a42496d59f..d90a24150f 100644 --- a/vtkext/private/module/vtkF3DRenderer.cxx +++ b/vtkext/private/module/vtkF3DRenderer.cxx @@ -1536,6 +1536,17 @@ void vtkF3DRenderer::ShowConsole(bool show) } } +//---------------------------------------------------------------------------- +void vtkF3DRenderer::ShowMinimalConsole(bool show) +{ + if (this->MinimalConsoleVisible != show) + { + this->MinimalConsoleVisible = show; + this->UIActor->SetMinimalConsoleVisibility(show); + this->CheatSheetConfigured = false; + } +} + //---------------------------------------------------------------------------- void vtkF3DRenderer::ConfigureCheatSheet(const std::vector& info) { diff --git a/vtkext/private/module/vtkF3DRenderer.h b/vtkext/private/module/vtkF3DRenderer.h index 7919da8c10..a86a997f39 100644 --- a/vtkext/private/module/vtkF3DRenderer.h +++ b/vtkext/private/module/vtkF3DRenderer.h @@ -59,6 +59,7 @@ class vtkF3DRenderer : public vtkOpenGLRenderer void ShowFilename(bool show); void ShowCheatSheet(bool show); void ShowConsole(bool show); + void ShowMinimalConsole(bool show); void ShowDropZone(bool show); void ShowHDRISkybox(bool show); void ShowArmature(bool show); @@ -525,6 +526,7 @@ class vtkF3DRenderer : public vtkOpenGLRenderer bool MetaDataVisible = false; bool CheatSheetVisible = false; bool ConsoleVisible = false; + bool MinimalConsoleVisible = false; bool DropZoneVisible = false; bool HDRISkyboxVisible = false; bool ArmatureVisible = false; diff --git a/vtkext/private/module/vtkF3DUIActor.cxx b/vtkext/private/module/vtkF3DUIActor.cxx index fe861ecdf0..ec4162a1f6 100644 --- a/vtkext/private/module/vtkF3DUIActor.cxx +++ b/vtkext/private/module/vtkF3DUIActor.cxx @@ -60,6 +60,12 @@ void vtkF3DUIActor::SetConsoleVisibility(bool show) this->ConsoleVisible = show; } +//---------------------------------------------------------------------------- +void vtkF3DUIActor::SetMinimalConsoleVisibility(bool show) +{ + this->MinimalConsoleVisible = show; +} + //---------------------------------------------------------------------------- void vtkF3DUIActor::SetConsoleBadgeEnabled(bool enabled) { @@ -154,11 +160,17 @@ int vtkF3DUIActor::RenderOverlay(vtkViewport* vp) this->RenderFpsCounter(); } + // Only one console can be visible at a time, console has priority over minimal console if (this->ConsoleVisible) { - this->RenderConsole(); + this->RenderConsole(false); } - else if (this->ConsoleBadgeEnabled) + else if (this->MinimalConsoleVisible) + { + this->RenderConsole(true); + } + + if (this->ConsoleBadgeEnabled) { this->RenderConsoleBadge(); } diff --git a/vtkext/private/module/vtkF3DUIActor.h b/vtkext/private/module/vtkF3DUIActor.h index 462d68b972..d004ef5e40 100644 --- a/vtkext/private/module/vtkF3DUIActor.h +++ b/vtkext/private/module/vtkF3DUIActor.h @@ -78,6 +78,13 @@ class vtkF3DUIActor : public vtkProp */ void SetConsoleVisibility(bool show); + /** + * Set the minimal console visibility + * Console visibility has priority over minimal console visibility + * False by default + */ + void SetMinimalConsoleVisibility(bool show); + /** * Set the console badge enabled status * False by default @@ -181,7 +188,7 @@ class vtkF3DUIActor : public vtkProp /** * Render the console widget */ - virtual void RenderConsole() + virtual void RenderConsole(bool) { } @@ -205,6 +212,7 @@ class vtkF3DUIActor : public vtkProp std::vector CheatSheet; bool ConsoleVisible = false; + bool MinimalConsoleVisible = false; bool ConsoleBadgeEnabled = false; bool FpsCounterVisible = false;