Skip to content

Add ImGui Minimal Console Feature #2099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
3ca2e69
Added binding for minimal console mode, added option and documentatio…
wizzebit Mar 23, 2025
d81f926
renamed option, added minimal console behavior
wizzebit Mar 23, 2025
721bbd3
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Mar 24, 2025
f87d1db
extra functionality, need to make comments
wizzebit Mar 25, 2025
6826c62
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Mar 26, 2025
8cfc009
new version of minimal console
wizzebit Mar 27, 2025
09f411c
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Mar 27, 2025
afb0c81
updated options.md
wizzebit Mar 28, 2025
d8da20a
Update library/src/interactor_impl.cxx
wizzebit Mar 28, 2025
0f8c910
Update library/src/interactor_impl.cxx
wizzebit Mar 28, 2025
4a6968a
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
4cd259b
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
ca8a7a8
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
66d100d
minor fixes
wizzebit Mar 28, 2025
84830af
- changed minimal console format
wizzebit Mar 28, 2025
cb29634
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Mar 28, 2025
d264b9d
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
c920c8b
Update vtkext/private/module/vtkF3DImguiConsole.h
wizzebit Mar 28, 2025
22d9533
Update vtkext/private/module/vtkF3DImguiConsole.h
wizzebit Mar 28, 2025
56e860a
attempt to fix github actions issue
wizzebit Mar 28, 2025
523c83c
Update vtkext/private/module/vtkF3DImguiConsole.h
wizzebit Mar 28, 2025
cf5e92e
added priority for console
wizzebit Mar 29, 2025
d990f59
Update library/src/interactor_impl.cxx
wizzebit Mar 29, 2025
a362e58
Update library/src/window_impl.cxx
wizzebit Mar 29, 2025
9f65921
merged master and imgui minimal mode branch
wizzebit Mar 30, 2025
5daeb5a
Update doc/libf3d/OPTIONS.md
wizzebit Mar 30, 2025
aab3048
Update doc/libf3d/OPTIONS.md
wizzebit Mar 30, 2025
9396a05
added colon binding
wizzebit Mar 30, 2025
f86fcc5
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Mar 30, 2025
2ec2782
fixed flashing issue
wizzebit Apr 4, 2025
e5ef03a
Fixed unresponsive badge issue
wizzebit Apr 4, 2025
463a92b
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 4, 2025
99493fa
styling fixes
wizzebit Apr 4, 2025
b7f412d
styling
wizzebit Apr 4, 2025
a45c06b
styling
wizzebit Apr 4, 2025
31d4c02
styling
wizzebit Apr 4, 2025
2291004
styling
wizzebit Apr 4, 2025
26a4296
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Apr 4, 2025
91fb582
Update vtkF3DUIActor.h
wizzebit Apr 4, 2025
30eb9a3
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 13, 2025
307fb93
Added Minimal Console Interaction Tests
wizzebit Apr 13, 2025
5bf6f95
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 16, 2025
f88ea06
-modified console badge position to be level with minimal console
wizzebit Apr 16, 2025
1ded2e3
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Apr 16, 2025
42b6a77
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Apr 16, 2025
9c04f36
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 17, 2025
d82aa90
- Shortened log code
wizzebit Apr 17, 2025
21f8774
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 22, 2025
882ba5e
changed minimal console position and size
wizzebit Apr 22, 2025
ab5bba9
made minimal console resize when badge and updated test
wizzebit Apr 23, 2025
96dc206
updated cheatsheet test baseline
wizzebit Apr 24, 2025
25a6828
updated cheatsheet test baseline
wizzebit Apr 24, 2025
3b126e9
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Apr 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/libf3d/OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ See the [APIs](#APIs) details below for more info.
| ui.scalar_bar | bool<br>false<br>render | Show _scalar bar_ of the coloring by data array. | \-\-bar |
| ui.cheatsheet | bool<br>false<br>render | Show a interactor cheatsheet | - |
| ui.console | bool<br>false<br>render | Show the console | - |
| ui.minimal_console | bool<br>false<br>render | Show the minimal console. Useful to execute a quick command and exit. | - |
| ui.filename | bool<br>false<br>render | Display the _filename info content_ on top of the window. | \-\-filename |
| ui.filename_info | string<br>-<br>render | Content of _filename info_ to display. | - |
| ui.font_file | path<br>optional<br>render | Use the provided FreeType compatible font file to display text.<br>Can be useful to display non-ASCII filenames. | \-\-font-file |
Expand Down
3 changes: 2 additions & 1 deletion doc/user/INTERACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ Other hotkeys and interactions are available:

- <kbd>H</kbd>: key to toggle the display of a cheat sheet showing all these hotkeys and their statuses.
- <kbd>CTRL</kbd> + <kbd>Q</kbd>: close the window and quit F3D.
- <kbd>Esc</kbd>: display/hide the console.
- <kbd>Esc</kbd>: display the console or hide console/minimal console.
- <kbd>:</kbd>: display the minimal console
- <kbd>Space</kbd>: play the animation if any.
- <kbd>&larr;</kbd>: load the previous file if any and reset the camera.
- <kbd>&rarr;</kbd>: load the next file if any and reset the camera.
Expand Down
4 changes: 4 additions & 0 deletions library/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
"type": "bool",
"default_value": "false"
},
"minimal_console": {
"type": "bool",
"default_value": "false"
},
"dropzone": {
"type": "bool",
"default_value": "false"
Expand Down
14 changes: 11 additions & 3 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,17 @@ class interactor_impl::internals
const char* commandWithArgs = static_cast<const char*>(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;
Expand Down Expand Up @@ -1158,6 +1165,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"));
Expand Down
1 change: 1 addition & 0 deletions library/src/window_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,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);
Expand Down
4 changes: 2 additions & 2 deletions vtkext/private/module/vtkF3DImguiActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,10 @@ void vtkF3DImguiActor::RenderFpsCounter()
}

//----------------------------------------------------------------------------
void vtkF3DImguiActor::RenderConsole()
void vtkF3DImguiActor::RenderConsole(bool minimal)
{
vtkF3DImguiConsole* console = vtkF3DImguiConsole::SafeDownCast(vtkOutputWindow::GetInstance());
console->ShowConsole();
console->ShowConsole(minimal);
}

//----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DImguiActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class vtkF3DImguiActor : public vtkF3DUIActor
/**
* Render the console widget
*/
void RenderConsole() override;
void RenderConsole(bool) override;

/**
* Render the console badge
Expand Down
128 changes: 81 additions & 47 deletions vtkext/private/module/vtkF3DImguiConsole.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,41 @@ 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 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::SetNextWindowSize(ImVec2(viewport->WorkSize.x - 2.f * margin -
(ImGui::CalcTextSize("!").y + 2.f * padding) - marginTopRight,
ImGui::CalcTextSize(">").y + 2.f * padding));
}
else
{
ImGui::SetNextWindowSize(
ImVec2(viewport->WorkSize.x - 2.f * margin, ImGui::CalcTextSize(">").y + 2.f * padding));
}
}
else
{
// minimal console shouldn't clear console badge
this->Pimpl->NewError = false;
this->Pimpl->NewWarning = false;

ImGui::SetNextWindowSize(
ImVec2(viewport->WorkSize.x - 2.f * margin, viewport->WorkSize.y - 2.f * margin));
}

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 |
Expand All @@ -228,58 +251,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 |
Expand Down Expand Up @@ -324,6 +351,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();
Expand All @@ -337,16 +370,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);

Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DImguiConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class vtkF3DImguiConsole : public vtkF3DConsoleOutputWindow
/**
* Show console window
*/
void ShowConsole();
void ShowConsole(bool);

/**
* Show console badge
Expand Down
11 changes: 11 additions & 0 deletions vtkext/private/module/vtkF3DRenderer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<vtkF3DUIActor::CheatSheetGroup>& info)
{
Expand Down
2 changes: 2 additions & 0 deletions vtkext/private/module/vtkF3DRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 14 additions & 2 deletions vtkext/private/module/vtkF3DUIActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}
Expand Down
17 changes: 16 additions & 1 deletion vtkext/private/module/vtkF3DUIActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -181,7 +188,14 @@ class vtkF3DUIActor : public vtkProp
/**
* Render the console widget
*/
virtual void RenderConsole()
virtual void RenderConsole(bool)
{
}

/**
* Render the minimal console widget
*/
virtual void RenderMinimalConsole()
{
}

Expand All @@ -205,6 +219,7 @@ class vtkF3DUIActor : public vtkProp
std::vector<CheatSheetGroup> CheatSheet;

bool ConsoleVisible = false;
bool MinimalConsoleVisible = false;
bool ConsoleBadgeEnabled = false;

bool FpsCounterVisible = false;
Expand Down
Loading