I'm working on setting panel expansion when switching tabs, currently with this diff: P1651
I currently get the following behavior though. I'll describe why I think that is and propose
a couple solutions.
Imagine the search is for "sdklfjghs". There will be no results. Then imagine you switch
to a new tab where all the panels were previously open.
While the buttons inside the panel still need to be added for searching, they should be
removed / hidden because they should not be shown. You'd think it would be as simple as that--
no results, so hide the buttons. BUT, at the point where the panels are hidden, the subpanels
have not been searched, because the panel layout pass uses a breadth first tree traversal.
Because of that there's no way if the subpanels have results, and we don't have enough
information to know if the panel should close or not.
As "proof", here is how the search only field is set for the panel contents layout:
uiLayoutRootSetSearchOnly(panel->layout, search_only || !open);
This works fine (although only by accident) when staying in the same tab because there can
be multiple redraws. The first redraw finds whether there are results and sets the expansion
then the next redraw uses that proper expansion to properly remove buttons. But when
switching tabs there shouldn't be animation, so this all has to be done in one redraw.
There could be multiple ways to fix this:
1
I first thought of tying "other-tab" search (D8859) more closely to single tab search, so that
the expansion for ALL panels would be set on every redraw. This could probably work fine,
but I think the original idea was to separate the multi-tab search because it could possibly
be dangerous, and this means the same panel list would need to be used.
2
Convert the panel layout pass to be depth first so the subpanels would build their layout first.
I'm notsure if this would have any adverse consequences, but it would probably be pretty simple
to try, and it resolves this situation in theory.
3
Do a property search pass first that sets the panel expansion, then do a normal layout pass
(which would still need to include search in order to highlight buttons properly). This seems
pretty foolproof, and although this could be limited to when the tab changes, it's still double
the work in this situation, and it doesn't properly resolve the dependence on the panels'
previous expansion state.