mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
Made 'LeaveLastRow' optional as new property in TableStyle
This commit is contained in:
@@ -262,6 +262,12 @@ namespace Terminal.Gui {
|
||||
/// </summary>
|
||||
public bool InvertExpandSymbolColors {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// True to leave the last row of the control free for overwritting (e.g. by a scrollbar). When True scrolling will be triggered on the second last row of the control rather than the last.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public bool LeaveLastRow {get;set;}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -792,16 +798,17 @@ namespace Terminal.Gui {
|
||||
var newIdx = Math.Min(Math.Max(0,idx+offset),map.Length-1);
|
||||
SelectedObject = map[newIdx].Model;
|
||||
|
||||
/*this -1 allows for possible horizontal scroll bar in the last row of the control*/
|
||||
int leaveSpace = Style.LeaveLastRow ? 1 :0;
|
||||
|
||||
if(newIdx < ScrollOffsetVertical) {
|
||||
//if user has scrolled up too far to see their selection
|
||||
ScrollOffsetVertical = newIdx;
|
||||
}
|
||||
else if(newIdx >= ScrollOffsetVertical + Bounds.Height -1 /*this -1 allows for possible horizontal scroll bar*/){
|
||||
else if(newIdx >= ScrollOffsetVertical + Bounds.Height - leaveSpace){
|
||||
|
||||
//if user has scrolled off bottom of visible tree
|
||||
ScrollOffsetVertical = Math.Max(0,(newIdx+1) - (Bounds.Height-1));
|
||||
|
||||
ScrollOffsetVertical = Math.Max(0,(newIdx+1) - (Bounds.Height-leaveSpace));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,9 @@ namespace UICatalog.Scenarios {
|
||||
|
||||
private void SetupScrollBar ()
|
||||
{
|
||||
// When using scroll bar leave the last row of the control free (for over-rendering with scroll bar)
|
||||
treeViewFiles.Style.LeaveLastRow = true;
|
||||
|
||||
var _scrollBar = new ScrollBarView (treeViewFiles, true);
|
||||
|
||||
_scrollBar.ChangedPosition += () => {
|
||||
|
||||
Reference in New Issue
Block a user