<SplitContainer Orientation="Horizontal" HorizontalExpand="True" Name="Split">
<!-- Guide select -->
<BoxContainer Orientation="Horizontal" Name="TreeBox">
- <fancyTree:FancyTree Name="Tree" VerticalExpand="True" HorizontalExpand="True"/>
+ <fancyTree:FancyTree Name="Tree" VerticalExpand="True" HorizontalExpand="True" Access="Public"/>
<cc:VSeparator StyleClasses="LowDivider" Margin="0 -2"/>
</BoxContainer>
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
OnSelectedItemChanged?.Invoke(newSelection);
}
- public void SetAllExpanded(bool value)
+ /// <summary>
+ /// Recursively expands or collapse all entries, optionally up to some depth.
+ /// </summary>
+ /// <param name="value">Whether to expand or collapse the entries</param>
+ /// <param name="depth">The recursion depth. If negative, implies no limit. Zero will expand only the top-level entries.</param>
+ public void SetAllExpanded(bool value, int depth = -1)
{
foreach (var item in Body.Children)
{
- RecursiveSetExpanded((TreeItem) item, value);
+ RecursiveSetExpanded((TreeItem) item, value, depth);
}
}
- public void RecursiveSetExpanded(TreeItem item, bool value)
+ public void RecursiveSetExpanded(TreeItem item, bool value, int depth)
{
item.SetExpanded(value);
+
+ if (depth == 0)
+ return;
+ depth--;
+
foreach (var child in item.Body.Children)
{
- RecursiveSetExpanded((TreeItem) child, value);
+ RecursiveSetExpanded((TreeItem) child, value, depth);
}
}
}
/// <summary>
- /// Opens the guidebook.
+ /// Opens or closes the guidebook.
/// </summary>
/// <param name="guides">What guides should be shown. If not specified, this will instead list all the entries</param>
/// <param name="rootEntries">A list of guides that should form the base of the table of contents. If not specified,
}
_guideWindow.UpdateGuides(guides, rootEntries, forceRoot, selected);
+
+ // Expand up to depth-2.
+ _guideWindow.Tree.SetAllExpanded(false);
+ _guideWindow.Tree.SetAllExpanded(true, 1);
+
_guideWindow.OpenCenteredRight();
}