Browse Source

Revamped File Explorer to enable better Focus testing

Charlie Kindel 2 years ago
parent
commit
7a37111319
2 changed files with 15 additions and 47 deletions
  1. 6 2
      Terminal.Gui/Core/Trees/Branch.cs
  2. 9 45
      UICatalog/Scenarios/TreeViewFileSystem.cs

+ 6 - 2
Terminal.Gui/Core/Trees/Branch.cs

@@ -121,7 +121,11 @@ namespace Terminal.Gui.Trees {
 				Attribute color = symbolColor;
 				Attribute color = symbolColor;
 
 
 				if (tree.Style.ColorExpandSymbol) {
 				if (tree.Style.ColorExpandSymbol) {
-					color = isSelected ? (tree.Style.HighlightModelTextOnly ? colorScheme.HotNormal : tree.ColorScheme.HotFocus) : tree.ColorScheme.HotNormal;
+					if (isSelected) {
+						color = tree.Style.HighlightModelTextOnly ? colorScheme.HotNormal : (tree.HasFocus ? tree.ColorScheme.HotFocus : tree.ColorScheme.HotNormal);
+					} else {
+						color = tree.ColorScheme.HotNormal;
+					}
 				} else {
 				} else {
 					color = symbolColor;
 					color = symbolColor;
 				}
 				}
@@ -416,7 +420,7 @@ namespace Terminal.Gui.Trees {
 		/// Expands the current branch and all children branches.
 		/// Expands the current branch and all children branches.
 		/// </summary>
 		/// </summary>
 		internal void ExpandAll ()
 		internal void ExpandAll ()
-			{
+		{
 			Expand ();
 			Expand ();
 
 
 			if (ChildBranches != null) {
 			if (ChildBranches != null) {

+ 9 - 45
UICatalog/Scenarios/TreeViewFileSystem.cs

@@ -78,14 +78,13 @@ namespace UICatalog.Scenarios {
 			};
 			};
 
 
 			detailsFrame = new DetailsFrame () {
 			detailsFrame = new DetailsFrame () {
-				X = Pos.Right (treeViewFiles) + 1,
+				X = Pos.Right (treeViewFiles),
 				Y = 0,
 				Y = 0,
 				Width = Dim.Fill (),
 				Width = Dim.Fill (),
 				Height = Dim.Fill (),
 				Height = Dim.Fill (),
 			};
 			};
 
 
 			Win.Add (detailsFrame);
 			Win.Add (detailsFrame);
-			treeViewFiles.ObjectActivated += TreeViewFiles_ObjectActivated;
 			treeViewFiles.MouseClick += TreeViewFiles_MouseClick;
 			treeViewFiles.MouseClick += TreeViewFiles_MouseClick;
 			treeViewFiles.KeyPress += TreeViewFiles_KeyPress;
 			treeViewFiles.KeyPress += TreeViewFiles_KeyPress;
 			treeViewFiles.SelectionChanged += TreeViewFiles_SelectionChanged;
 			treeViewFiles.SelectionChanged += TreeViewFiles_SelectionChanged;
@@ -160,23 +159,12 @@ namespace UICatalog.Scenarios {
 
 
 		class DetailsFrame : FrameView {
 		class DetailsFrame : FrameView {
 			private FileSystemInfo fileInfo;
 			private FileSystemInfo fileInfo;
-			TextView details = new TextView () {
-				X = 1,
-				Y = 0,
-				Width = Dim.Fill (),
-				Height = Dim.Fill (),
-				ColorScheme = Colors.Base,
-				WordWrap = true,
-				ReadOnly = true
-			};
 
 
 			public DetailsFrame ()
 			public DetailsFrame ()
 			{
 			{
 				Title = "Details";
 				Title = "Details";
-				ColorScheme = Colors.Dialog;
 				Visible = true;
 				Visible = true;
 				CanFocus = true;				
 				CanFocus = true;				
-				Add (details);
 			}
 			}
 
 
 			public FileSystemInfo FileInfo {
 			public FileSystemInfo FileInfo {
@@ -186,20 +174,20 @@ namespace UICatalog.Scenarios {
 					if (fileInfo is FileInfo f) {
 					if (fileInfo is FileInfo f) {
 						Title = $"File: {f.Name}";
 						Title = $"File: {f.Name}";
 						sb = new System.Text.StringBuilder ();
 						sb = new System.Text.StringBuilder ();
-						sb.AppendLine ($"Path: {f.DirectoryName}");
-						sb.AppendLine ($"Size: {f.Length:N0} bytes");
-						sb.AppendLine ($"Modified: {f.LastWriteTime}");
-						sb.AppendLine ($"Created: {f.CreationTime}");
+						sb.AppendLine ($"Path:\n {f.FullName}\n");
+						sb.AppendLine ($"Size:\n {f.Length:N0} bytes\n");
+						sb.AppendLine ($"Modified:\n {f.LastWriteTime}\n");
+						sb.AppendLine ($"Created:\n {f.CreationTime}");
 					}
 					}
 
 
 					if (fileInfo is DirectoryInfo dir) {
 					if (fileInfo is DirectoryInfo dir) {
 						Title = $"Directory: {dir.Name}";
 						Title = $"Directory: {dir.Name}";
 						sb = new System.Text.StringBuilder ();
 						sb = new System.Text.StringBuilder ();
-						sb.AppendLine ($"Path: {dir?.FullName}");
-						sb.AppendLine ($"Modified: {dir.LastWriteTime}");
-						sb.AppendLine ($"Created: {dir.CreationTime}");
+						sb.AppendLine ($"Path:\n {dir?.FullName}\n");
+						sb.AppendLine ($"Modified:\n {dir.LastWriteTime}\n");
+						sb.AppendLine ($"Created:\n {dir.CreationTime}\n");
 					}
 					}
-					details.Text = sb.ToString ();
+					Text = sb.ToString ();
 				}
 				}
 			}
 			}
 		}
 		}
@@ -207,25 +195,6 @@ namespace UICatalog.Scenarios {
 		private void ShowPropertiesOf (FileSystemInfo fileSystemInfo)
 		private void ShowPropertiesOf (FileSystemInfo fileSystemInfo)
 		{
 		{
 			detailsFrame.FileInfo = fileSystemInfo;
 			detailsFrame.FileInfo = fileSystemInfo;
-			//if (fileSystemInfo is FileInfo f) {
-			//	System.Text.StringBuilder sb = new System.Text.StringBuilder ();
-			//	sb.AppendLine ($"Path:{f.DirectoryName}");
-			//	sb.AppendLine ($"Size:{f.Length:N0} bytes");
-			//	sb.AppendLine ($"Modified:{f.LastWriteTime}");
-			//	sb.AppendLine ($"Created:{f.CreationTime}");
-
-			//	MessageBox.Query (f.Name, sb.ToString (), "Close");
-			//}
-
-			//if (fileSystemInfo is DirectoryInfo dir) {
-
-			//	System.Text.StringBuilder sb = new System.Text.StringBuilder ();
-			//	sb.AppendLine ($"Path:{dir.Parent?.FullName}");
-			//	sb.AppendLine ($"Modified:{dir.LastWriteTime}");
-			//	sb.AppendLine ($"Created:{dir.CreationTime}");
-
-			//	MessageBox.Query (dir.Name, sb.ToString (), "Close");
-			//}
 		}
 		}
 
 
 		private void SetupScrollBar ()
 		private void SetupScrollBar ()
@@ -278,11 +247,6 @@ namespace UICatalog.Scenarios {
 			treeViewFiles.AddObjects (DriveInfo.GetDrives ().Select (d => d.RootDirectory));
 			treeViewFiles.AddObjects (DriveInfo.GetDrives ().Select (d => d.RootDirectory));
 		}
 		}
 
 
-		private void TreeViewFiles_ObjectActivated (ObjectActivatedEventArgs<FileSystemInfo> obj)
-		{
-			ShowPropertiesOf (obj.ActivatedObject);
-		}
-
 		private void ShowLines ()
 		private void ShowLines ()
 		{
 		{
 			miShowLines.Checked = !miShowLines.Checked;
 			miShowLines.Checked = !miShowLines.Checked;