Skip to content

Add expand / collapse support to TreeView#7411

Open
MiriShulman wants to merge 4 commits intoisl-org:mainfrom
MiriShulman:feature/treeview-expand-collapse
Open

Add expand / collapse support to TreeView#7411
MiriShulman wants to merge 4 commits intoisl-org:mainfrom
MiriShulman:feature/treeview-expand-collapse

Conversation

@MiriShulman
Copy link

Type

Motivation and Context

TreeView currently does not expose a public API to programmatically expand or collapse items.
This makes it difficult to control TreeView state from application logic and from Python bindings.

This PR adds explicit Expand() and Collapse() methods to address this limitation.

Description of the Changes

  • Added Expand(ItemId) and Collapse(ItemId) methods to gui::TreeView
  • Exposed the new API to Python bindings
  • Added a C++ test covering TreeView expand / collapse behavior
  • Included a minimal GUI smoke test to ensure no crash when using TreeView in a window

Testing

  • Local C++ tests (logic + GUI smoke test)
  • Manual verification on Windows

Notes

  • The change is backward compatible
  • No existing behavior is modified

@update-docs
Copy link

update-docs bot commented Jan 22, 2026

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@ssheorey ssheorey requested review from Copilot and ssheorey January 22, 2026 22:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds programmatic expand/collapse functionality to the TreeView component, addressing the lack of a public API to control TreeView state. This change enables application logic and Python bindings to control tree expansion states.

Changes:

  • Added Expand() and Collapse() methods to TreeView API
  • Exposed new methods to Python bindings
  • Added C++ test suite with GUI smoke test

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cpp/open3d/visualization/gui/TreeView.h Declares new Expand() and Collapse() public methods
cpp/open3d/visualization/gui/TreeView.cpp Implements expand/collapse logic using optional expanded state tracking
cpp/pybind/visualization/gui/gui.cpp Exposes new methods to Python bindings
cpp/tests/visualization/TreeViewTest.cpp Adds GUI smoke test for TreeView
cpp/tests/visualization/CMakeLists.txt Adds TreeViewTest executable configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (it != impl_->id2item_.end()) {
it->second->expanded = true;
}
// Invalidate();
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out Invalidate() call should either be removed or uncommented with explanation. If invalidation is needed for proper UI updates after expansion, this should be active. If not needed, the comment should be removed to avoid confusion.

Suggested change
// Invalidate();
Invalidate(); // Ensure UI is updated after expanding an item.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +10
add_executable(TreeViewTest
TreeViewTest.cpp
)
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TreeViewTest is configured as a standalone executable rather than integrated with the test framework. Consider using the existing test infrastructure (similar to the rendering tests guarded by BUILD_GUI) to ensure this test runs as part of the automated test suite and reports results properly.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this new feature @MiriShulman !
Please check the highlighted copilot comment.

Comment on lines +8 to +10
add_executable(TreeViewTest
TreeViewTest.cpp
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MiriShulman MiriShulman reopened this Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the "collapse" and "open" functions to TreeView in python

2 participants