Skip to content

Commit

Permalink
USD Viewer: scroll stage tree to selected prim
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Dec 2, 2023
1 parent d0211d1 commit 4d71d10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Samples/USDViewer/src/USDViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ void USDViewer::PopulateSceneTree(const pxr::UsdPrim& Prim)

ImGui::TreePop();
}
else
{
if (m_ScrolllToSelectedTreeItem && (Flags & ImGuiTreeNodeFlags_Selected))
{
ImGui::SetScrollHereY();
m_ScrolllToSelectedTreeItem = false;
}
}
}

void USDViewer::UpdateUI()
Expand Down Expand Up @@ -579,6 +587,8 @@ void USDViewer::Update(double CurrTime, double ElapsedTime)
if (SelectPrim && SelectedPrimId != nullptr)
{
SetSelectedPrim(*SelectedPrimId);
if (!SelectedPrimId->IsEmpty())
m_ScrolllToSelectedTreeItem = true;
}

m_PrevMouse = Mouse;
Expand Down
3 changes: 2 additions & 1 deletion Samples/USDViewer/src/USDViewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ class USDViewer final : public SampleBase
};
SelectionMode m_SelectMode = SelectionMode::OnClick;
MouseState m_PrevMouse;
bool m_IsSelecting = false;
bool m_IsSelecting = false;
bool m_ScrolllToSelectedTreeItem = false;
};

} // namespace Diligent

0 comments on commit 4d71d10

Please sign in to comment.