Always show expansion icon for selection TreeView root nodes

This commit is contained in:
John Lewin 2018-06-23 07:12:41 -07:00
parent 77ba63fd82
commit 1c914e36a3
2 changed files with 27 additions and 1 deletions

View file

@ -35,6 +35,7 @@ using MatterHackers.Agg.Font;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.ImageProcessing;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.CustomWidgets
@ -160,6 +161,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
return content?.Children.Where((c) => c is TreeNode).Count() ?? 0;
}
public bool AlwaysExpandable
{
get => expandWidget.AlwaysExpandable;
set => expandWidget.AlwaysExpandable = value;
}
public override void OnDraw(Graphics2D graphics2D)
{
if (isDirty)
@ -421,10 +428,21 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.AddChild(imageButton);
}
private bool _alwaysExpandable;
public bool AlwaysExpandable
{
get => _alwaysExpandable;
set
{
imageButton.SetIcon((_expanded) ? arrowDown : arrowRight);
_alwaysExpandable = value;
}
}
private bool? _expandable = null;
public bool Expandable
{
get => _expandable == true;
get => _expandable == true || this.AlwaysExpandable;
set
{
if (_expandable != value)

View file

@ -198,6 +198,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
selectedObjectPanel.SetActiveItem((IObject3D)treeView.SelectedNode.Tag);
};
treeView.ScrollArea.ChildAdded += (s, e) =>
{
if (e is GuiWidgetEventArgs childEventArgs
&& childEventArgs.Child is TreeNode treeNode)
{
treeNode.AlwaysExpandable = true;
}
};
var treeSection = new ResizableSectionWidget("Design History".Localize(), sceneContext.ViewState.SceneTreeHeight, treeView, theme, expanded: false);
treeSection.Resized += (s, e) =>