Skip to content
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

Tree: add expand_all and collapse_all methods #22728

Closed
wants to merge 1 commit into from

Conversation

lupoDharkael
Copy link
Contributor

@lupoDharkael lupoDharkael commented Oct 4, 2018

Qt provides the methods expandAll() and collapseAll() for QTreeView.
It is an useful feature and it would be nice to have it in Godot :)

Here it is in action:
ezgif-5-ae28a54943f0

@groud
Copy link
Member

groud commented Oct 5, 2018

How is this useful on the tree Itself ?
Such behaviors are usually applied to selected items, so I'd better make this a method of TreeItem, and not Tree.

@groud
Copy link
Member

groud commented Oct 5, 2018

That being said, I'm not even sure this is required. I think I would simply define a call_recursive function to TreeItem, that would allow calling a function on a hierarchy of TreeItem.

So we could use tree_item.call_recusive("set_collapsed", true)

@lupoDharkael
Copy link
Contributor Author

@groud having this in the Tree class means not having to reinvent the wheel everytime someone wants to have an "Expand all" button.
I think it's more user friendly to call a method in the Tree itself when you want to do global modifications to the items contained in the Tree.

This could be used in the editor itself as a way to improve usability in some parts where we have trees with multiples levels and the users could need to have a global view of everything (That should be treated in other issue).

Anyway, I'm open to other views/ideas about how to implement this.

@groud
Copy link
Member

groud commented Oct 5, 2018

Well Godot's philosophy is simple : we add to the API things that are often needed OR hard to code. Expanding or collapsing all is probably 3 or 4 lines of code in GDscript, and such button is not that oftently used.

So, IMHO, there's no reason to add a shortcut in the API for that, unless we make this a more general purpose solution (like my call_recursive proposal). Otherwise, I think it's more API bloat than useful.

But other might disagree. :)

@lupoDharkael
Copy link
Contributor Author

lupoDharkael commented Oct 5, 2018

I like the idea of the call_recusive method and I might consider sending a PR for that :)
But I also think these methods are not mutually exclusive.
Maybe the discussion tag should be added to this PR (or is an issue a better place to discuss this?). Let's see what others think about this.

@lupoDharkael
Copy link
Contributor Author

I'm closing this as I'm working on the call_recursive() solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants