Making the scene tree view a bit better

This commit is contained in:
LarsBrubaker 2020-09-12 08:53:40 -07:00
parent 1dfe8b3ee5
commit 52df1380a7
11 changed files with 34 additions and 15 deletions

View file

@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (componentObject3D?.Finalized == false
|| !hideChildren)
{
foreach (var child in item.Children)
foreach (var child in item.Children.OrderBy(i => i.Name))
{
if (child != null
&& !child.GetType().GetCustomAttributes(typeof(HideFromTreeViewAttribute), true).Any())

View file

@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
@ -58,9 +57,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
private bool deferEditorTillMouseUp = false;
public readonly int EditButtonHeight = 44;
public int EditButtonHeight { get; set; } = 44;
private Color[] SelectionColors = new Color[] { new Color(131, 4, 66), new Color(227, 31, 61), new Color(255, 148, 1), new Color(247, 224, 23), new Color(143, 212, 1) };
private Color[] selectionColors = new Color[] { new Color(131, 4, 66), new Color(227, 31, 61), new Color(255, 148, 1), new Color(247, 224, 23), new Color(143, 212, 1) };
private Stopwatch timeSinceLastSpin = new Stopwatch();
private Stopwatch timeSinceReported = new Stopwatch();
@ -415,17 +414,33 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private Dictionary<IObject3D, TreeNode> treeNodesByObject = new Dictionary<IObject3D, TreeNode>();
private bool watingToScroll = false;
private void RebuildTree()
{
rebuildTreePending = false;
workspaceName.Text = sceneContext.Scene.Name ?? "";
if (!watingToScroll)
{
// This is a mess. The goal is that the tree view will not scroll as we add and remove items.
// This is better than always reseting to the top, but only a little.
watingToScroll = true;
beforeReubildScrollPosition = treeView.TopLeftOffset;
UiThread.RunOnIdle(() =>
{
treeView.TopLeftOffset = beforeReubildScrollPosition;
watingToScroll = false;
}, .5);
}
// Top level selection only - rebuild tree
treeNodeContainer.CloseAllChildren();
treeNodesByObject.Clear();
foreach (var child in sceneContext.Scene.Children)
foreach (var child in sceneContext.Scene.Children.OrderBy(i => i.Name))
{
if (child.GetType().GetCustomAttributes(typeof(HideFromTreeViewAttribute), true).Any())
{
@ -445,6 +460,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
treeView.SelectedNode = treeNode;
}
treeView.TopLeftOffset = beforeReubildScrollPosition;
Invalidate();
}
@ -1577,7 +1594,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private void Scene_Invalidated(object sender, InvalidateArgs e)
{
if (Scene.Descendants().Count() != lastSceneDescendantsCount)
if (Scene.Descendants().Count() != lastSceneDescendantsCount
&& !rebuildTreePending)
{
rebuildTreePending = true;
UiThread.RunOnIdle(this.RebuildTree);
@ -1675,6 +1693,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private InlineStringEdit workspaceName;
private int lastSceneDescendantsCount;
private Vector2 beforeReubildScrollPosition;
public InteractiveScene Scene => sceneContext.Scene;

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#404040",
"TabBarBackground": "#363636",
"InactiveTabColor": "#4E4E4E",
"InteractionLayerOverlayColor": "#404040F0",
"Object3DControlLayerOverlayColor": "#404040F0",
"SplitterBackground": "#383838",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#C4C4C4",
"TabBarBackground": "#A7A7A7",
"InactiveTabColor": "#D1D1D1",
"InteractionLayerOverlayColor": "#C4C4C4F0",
"Object3DControlLayerOverlayColor": "#C4C4C4F0",
"SplitterBackground": "#ABABAB",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#fff",
"TabBarBackground": "#F3F3F3",
"InactiveTabColor": "#E6E6E6",
"InteractionLayerOverlayColor": "#ffffffF0",
"Object3DControlLayerOverlayColor": "#ffffffF0",
"SplitterBackground": "#E1E1E1",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#F1F1F1",
"TabBarBackground": "#A7A7A7",
"InactiveTabColor": "#D1D1D1",
"InteractionLayerOverlayColor": "#C4C4C4F0",
"Object3DControlLayerOverlayColor": "#C4C4C4F0",
"SplitterBackground": "#ABABAB",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#404040",
"TabBarBackground": "#B1B1B1",
"InactiveTabColor": "#D0D0D0",
"InteractionLayerOverlayColor": "#D0D0D0F0",
"Object3DControlLayerOverlayColor": "#D0D0D0F0",
"SplitterBackground": "#B5B5B5",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#373737",
"TabBarBackground": "#282828",
"InactiveTabColor": "#404040",
"InteractionLayerOverlayColor": "#373737F0",
"Object3DControlLayerOverlayColor": "#373737F0",
"SplitterBackground": "#2C2C2C",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#002B36",
"TabBarBackground": "#001A20",
"InactiveTabColor": "#073642",
"InteractionLayerOverlayColor": "#002B36F0",
"Object3DControlLayerOverlayColor": "#002B36F0",
"SplitterBackground": "#073642",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#F1F1F1",
"TabBarBackground": "#B1B1B1",
"InactiveTabColor": "#D0D0D0",
"InteractionLayerOverlayColor": "#D0D0D0F0",
"Object3DControlLayerOverlayColor": "#D0D0D0F0",
"SplitterBackground": "#B5B5B5",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",

View file

@ -14,7 +14,7 @@
"BackgroundColor": "#FDF6E3",
"TabBarBackground": "#E4DDCC",
"InactiveTabColor": "#EEE8D5",
"InteractionLayerOverlayColor": "#FDF6E3F0",
"Object3DControlLayerOverlayColor": "#FDF6E3F0",
"SplitterBackground": "#EEE8D5",
"TabBodyBackground": "#00000000",
"ToolbarButtonBackground": "#00000000",