@@ -36,8 +36,6 @@ Viewport::Viewport(
3636 : Window(app, name)
3737{
3838 setManipulator (m);
39- m_overlayWindowName = " overlay_" ;
40- m_overlayWindowName += name;
4139 setLibrary (" " );
4240}
4341
@@ -63,6 +61,8 @@ void Viewport::buildUI()
6361 updateImage ();
6462 updateCamera ();
6563
64+ ui_menubar ();
65+
6666 ImGui::BeginDisabled (!m_deviceReadyToUse);
6767
6868 if (m_outputPass) {
@@ -72,15 +72,16 @@ void Viewport::buildUI()
7272 ImVec2 (1 , 0 ));
7373 }
7474
75- if (m_showOverlay)
76- ui_overlay ();
77-
78- ImGui::EndDisabled ();
79-
8075 ui_gizmo ();
8176 ui_handleInput ();
8277 bool didPick = ui_picking (); // Needs to happen before ui_menubar
83- ui_menubar ();
78+
79+ // Render the overlay after input handling so it does not interfere.
80+ if (m_showOverlay) {
81+ ui_overlay ();
82+ }
83+
84+ ImGui::EndDisabled ();
8485
8586 if (m_anariPass && !didPick) {
8687 bool needIDs = appCore ()->getFirstSelected ().valid ()
@@ -1459,19 +1460,20 @@ bool Viewport::ui_picking()
14591460
14601461void Viewport::ui_overlay ()
14611462{
1462- ImGuiIO &io = ImGui::GetIO ();
1463- ImVec2 windowPos = ImGui::GetWindowPos ();
1464- windowPos.x += 10 ;
1465- windowPos.y += 63 * io.FontGlobalScale ;
1463+ ImVec2 contentStart = ImGui::GetCursorStartPos ();
1464+ ImGui::SetCursorPos (ImVec2 (contentStart[0 ] + 2 .0f , contentStart[1 ] + 2 .0f ));
14661465
1467- ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration
1468- | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize
1469- | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing
1470- | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove;
1466+ ImGui::PushStyleColor (ImGuiCol_ChildBg, ImVec4 (0 .0f , 0 .0f , 0 .0f , 0 .7f ));
14711467
1472- ImGui::SetNextWindowPos (windowPos, ImGuiCond_Always);
1468+ ImGuiChildFlags childFlags = ImGuiChildFlags_Border
1469+ | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY;
1470+ ImGuiWindowFlags childWindowFlags =
1471+ ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
14731472
1474- if (ImGui::Begin (m_overlayWindowName.c_str (), nullptr , window_flags)) {
1473+ // Render overlay as a child window within the viewport.
1474+ // This ensures it's properly occluded when other windows are on top.
1475+ if (ImGui::BeginChild (
1476+ " ##viewportOverlay" , ImVec2 (0 , 0 ), childFlags, childWindowFlags)) {
14751477 ImGui::Text (" device: %s" , m_libName.c_str ());
14761478
14771479 // Camera indicator
@@ -1493,7 +1495,6 @@ void Viewport::ui_overlay()
14931495 ImGui::Text (" (max): %.2fms" , m_maxFL);
14941496
14951497 ImGui::Separator ();
1496-
14971498 ImGui::Checkbox (" camera config" , &m_showCameraInfo);
14981499 if (m_showCameraInfo) {
14991500 auto at = m_arcball->at ();
@@ -1516,9 +1517,10 @@ void Viewport::ui_overlay()
15161517 m_arcball->setFixedDistance (fixedDist);
15171518 }
15181519 }
1519-
1520- ImGui::End ();
15211520 }
1521+ ImGui::EndChild ();
1522+
1523+ ImGui::PopStyleColor ();
15221524}
15231525
15241526bool Viewport::canShowGizmo () const
@@ -1638,7 +1640,7 @@ void Viewport::ui_gizmo()
16381640
16391641int Viewport::windowFlags () const
16401642{
1641- return ImGuiWindowFlags_MenuBar;
1643+ return ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar ;
16421644}
16431645
16441646void Viewport::RendererUpdateDelegate::signalParameterUpdated (
0 commit comments