Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 24 additions & 22 deletions tsd/src/tsd/ui/imgui/windows/Viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ Viewport::Viewport(
: Window(app, name)
{
setManipulator(m);
m_overlayWindowName = "overlay_";
m_overlayWindowName += name;
setLibrary("");
}

Expand All @@ -63,6 +61,8 @@ void Viewport::buildUI()
updateImage();
updateCamera();

ui_menubar();

ImGui::BeginDisabled(!m_deviceReadyToUse);

if (m_outputPass) {
Expand All @@ -72,15 +72,16 @@ void Viewport::buildUI()
ImVec2(1, 0));
}

if (m_showOverlay)
ui_overlay();

ImGui::EndDisabled();

ui_gizmo();
ui_handleInput();
bool didPick = ui_picking(); // Needs to happen before ui_menubar
ui_menubar();

// Render the overlay after input handling so it does not interfere.
if (m_showOverlay) {
ui_overlay();
}

ImGui::EndDisabled();

if (m_anariPass && !didPick) {
bool needIDs = appCore()->getFirstSelected().valid()
Expand Down Expand Up @@ -1459,19 +1460,20 @@ bool Viewport::ui_picking()

void Viewport::ui_overlay()
{
ImGuiIO &io = ImGui::GetIO();
ImVec2 windowPos = ImGui::GetWindowPos();
windowPos.x += 10;
windowPos.y += 63 * io.FontGlobalScale;
ImVec2 contentStart = ImGui::GetCursorStartPos();
ImGui::SetCursorPos(ImVec2(contentStart[0] + 2.0f, contentStart[1] + 2.0f));

ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration
| ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize
| ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing
| ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove;
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.0f, 0.0f, 0.0f, 0.7f));

ImGui::SetNextWindowPos(windowPos, ImGuiCond_Always);
ImGuiChildFlags childFlags = ImGuiChildFlags_Border
| ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY;
ImGuiWindowFlags childWindowFlags =
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;

if (ImGui::Begin(m_overlayWindowName.c_str(), nullptr, window_flags)) {
// Render overlay as a child window within the viewport.
// This ensures it's properly occluded when other windows are on top.
if (ImGui::BeginChild(
"##viewportOverlay", ImVec2(0, 0), childFlags, childWindowFlags)) {
ImGui::Text(" device: %s", m_libName.c_str());

// Camera indicator
Expand All @@ -1493,7 +1495,6 @@ void Viewport::ui_overlay()
ImGui::Text(" (max): %.2fms", m_maxFL);

ImGui::Separator();

ImGui::Checkbox("camera config", &m_showCameraInfo);
if (m_showCameraInfo) {
auto at = m_arcball->at();
Expand All @@ -1516,9 +1517,10 @@ void Viewport::ui_overlay()
m_arcball->setFixedDistance(fixedDist);
}
}

ImGui::End();
}
ImGui::EndChild();

ImGui::PopStyleColor();
}

bool Viewport::canShowGizmo() const
Expand Down Expand Up @@ -1638,7 +1640,7 @@ void Viewport::ui_gizmo()

int Viewport::windowFlags() const
{
return ImGuiWindowFlags_MenuBar;
return ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar;
}

void Viewport::RendererUpdateDelegate::signalParameterUpdated(
Expand Down
2 changes: 0 additions & 2 deletions tsd/src/tsd/ui/imgui/windows/Viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ struct Viewport : public Window
float m_latestAnariFL{0.f};
float m_minFL{std::numeric_limits<float>::max()};
float m_maxFL{-std::numeric_limits<float>::max()};

std::string m_overlayWindowName;
};

} // namespace tsd::ui::imgui