|
@@ -346,7 +346,6 @@ namespace Terminal.Gui {
|
|
/// </summary>
|
|
/// </summary>
|
|
public int ContentHeight => BuildLineMap().Count();
|
|
public int ContentHeight => BuildLineMap().Count();
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Returns the string representation of model objects hosted in the tree. Default implementation is to call <see cref="object.ToString"/>
|
|
/// Returns the string representation of model objects hosted in the tree. Default implementation is to call <see cref="object.ToString"/>
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -523,6 +522,32 @@ namespace Terminal.Gui {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Returns the maximum width line in the tree including prefix and expansion symbols
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="visible">True to consider only rows currently visible (based on window bounds and <see cref="ScrollOffsetVertical"/>. False to calculate the width of every exposed branch in the tree</param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public int GetContentWidth(bool visible){
|
|
|
|
+
|
|
|
|
+ var map = BuildLineMap();
|
|
|
|
+
|
|
|
|
+ if(map.Length == 0)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ if(visible){
|
|
|
|
+
|
|
|
|
+ //Somehow we managed to scroll off the end of the control
|
|
|
|
+ if(ScrollOffsetVertical > map.Length)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ return map.Skip(ScrollOffsetVertical).Take(Bounds.Height).Max(b=>b.GetWidth(Driver));
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+
|
|
|
|
+ return map.Max(b=>b.GetWidth(Driver));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Calculates all currently visible/expanded branches (including leafs) and outputs them by index from the top of the screen
|
|
/// Calculates all currently visible/expanded branches (including leafs) and outputs them by index from the top of the screen
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -898,6 +923,18 @@ namespace Terminal.Gui {
|
|
this.ChildBranches = children.ToDictionary(k=>k,val=>new Branch<T>(tree,this,val));
|
|
this.ChildBranches = children.ToDictionary(k=>k,val=>new Branch<T>(tree,this,val));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Returns the width of the line including prefix and the results of <see cref="TreeView{T}.AspectGetter"/> (the line body).
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public virtual int GetWidth (ConsoleDriver driver)
|
|
|
|
+ {
|
|
|
|
+ return
|
|
|
|
+ GetLinePrefix(driver).Sum(Rune.ColumnWidth) +
|
|
|
|
+ Rune.ColumnWidth(GetExpandableSymbol(driver)) +
|
|
|
|
+ (tree.AspectGetter(Model) ?? "").Length;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Renders the current <see cref="Model"/> on the specified line <paramref name="y"/>
|
|
/// Renders the current <see cref="Model"/> on the specified line <paramref name="y"/>
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -1210,6 +1247,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|