See https://github.com/Textualize/textual/pull/1644#issuecomment-1401720808
where Darren raises the excellent point that while the "technically correct"
approach that I had was... well, technically correct I guess (it toggled all
the nodes from the target node down), it didn't have what was likely the
desired effect.
So this commit does away with the previous logic for doing the toggle and
instead simply calls on expand or collapse depending on the state of the
source node.
Somehow I'd managed to typo them as True when they obviously should be False
to maintain backward-compatibility (and generally this is the only sensible
default).
As pointed out in #1649, a `ChildrenUpdated` message is documented but it
doesn't exist in the code. It looks like it got added during development,
then removed after it was realised it wasn't needed, but presumably it got
left in the docs:
https://github.com/Textualize/textual/pull/1143#discussion_r1030409026
It might seem excessive for just a single argument, but I feel it's
worthwhile doing it here. It's a single boolean parameter on each of the
methods that, left bare, will always end up reading badly. Consider:
tree.toggle( True )
vs:
tree.toggle( toggle_all=True )
the former looks awkward at best and ugly at worst; toggle True? What does
that even mean? The latter, while a touch more verbose, makes it really
clear what's going on.
Trying this on for size.
This encourages importing it from `textual.widgets.tree` instead, keeping it
in line with the other changes made for #1637.
Note this is a breaking change.
This commit moves the bulk of the work of each action into an internal
method that does everything *apart* from invalidating the tree. The idea
being that all of the expanded states get updated, all of the update counts
get updated, and then finally one single tree invalidation takes place (the
latter taking place in the public method, which calls the related internal
method).
See #1430.
This was asked about on Discord; reading the docs over again it's not
obvious what an `int` is for, or a `str`. This change seeks to explain
things at the API level at least.
Without this information, grid-rows and grid-columns will have the same percent_unit for scalars that are relative and thus relative dimensions will be wrong.