Revise treenode selection rect to exclude checkbox region

- MatterHackers/MCCentral#3495
This commit is contained in:
John Lewin 2018-06-01 08:54:15 -07:00
parent 5244025ae3
commit a382b26f4b
2 changed files with 19 additions and 6 deletions

View file

@ -90,10 +90,18 @@ namespace MatterHackers.MatterControl.CustomWidgets.TreeView
this.TitleBar.AddChild(expandCheckBox);
this.SelectionBar = new FlowLayoutWidget()
{
VAnchor = VAnchor.Fit,
HAnchor = HAnchor.Fit,
Selectable = false
};
this.TitleBar.AddChild(this.SelectionBar);
// add a check box
if (Image != null)
{
this.TitleBar.AddChild(imageWidget = new ImageWidget(this.Image)
this.SelectionBar.AddChild(imageWidget = new ImageWidget(this.Image)
{
VAnchor = VAnchor.Center,
BackgroundColor = new Color(theme.Colors.PrimaryTextColor, 12),
@ -101,7 +109,9 @@ namespace MatterHackers.MatterControl.CustomWidgets.TreeView
Selectable = false
});
};
this.TitleBar.AddChild(textWidget = new TextWidget(this.Text, pointSize: theme.DefaultFontSize, textColor: theme.Colors.PrimaryTextColor)
this.SelectionBar.AddChild(textWidget = new TextWidget(this.Text, pointSize: theme.DefaultFontSize, textColor: theme.Colors.PrimaryTextColor)
{
Selectable = false,
AutoExpandBoundsToText = true,
@ -122,6 +132,8 @@ namespace MatterHackers.MatterControl.CustomWidgets.TreeView
public FlowLayoutWidget TitleBar { get; }
public FlowLayoutWidget SelectionBar { get; }
public void BeginEdit()
{
throw new NotImplementedException();

View file

@ -196,19 +196,20 @@ namespace MatterHackers.MatterControl.CustomWidgets.TreeView
public TreeNode SelectedNode
{
get => _selectedNode; set
get => _selectedNode;
set
{
if (value != _selectedNode)
{
OnBeforeSelect(null);
foreach (var node in this.Descendants<TreeNode>().Where((c) => c != value))
if (_selectedNode != null)
{
node.TitleBar.BackgroundColor = Color.Transparent;
_selectedNode.SelectionBar.BackgroundColor = Color.Transparent;
}
_selectedNode = value;
_selectedNode.TitleBar.BackgroundColor = theme.AccentMimimalOverlay;
_selectedNode.SelectionBar.BackgroundColor = theme.AccentMimimalOverlay;
OnAfterSelect(null);
}
}