Skip to content

Commit

Permalink
Merge pull request #197 from tig/BDisp-v2_2489_scroll-tig-builtin
Browse files Browse the repository at this point in the history
Tweaked `CharMap` based on your latest
  • Loading branch information
BDisp authored Sep 7, 2024
2 parents c5e886f + 03dac3e commit b19437d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
21 changes: 20 additions & 1 deletion Terminal.Gui/View/ViewportSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,24 @@ public enum ViewportSettings
/// <see cref="ClipContentOnly"/> must be set for this setting to work (clipping beyond the visible area must be
/// disabled).
/// </remarks>
ClearContentOnly = 32
ClearContentOnly = 32,

/// <summary>
/// If set, the vertical scroll bar (see <see cref="View.HorizontalScrollBar"/>) will be enabled and automatically made visible
/// when the dimension of the <see cref="View.Viewport"/> is smaller than the dimension of <see cref="View.GetContentSize()"/>.
/// </summary>
EnableHorizontalScrollBar = 64,

/// <summary>
/// If set, the vertical scroll bar (see <see cref="View.VerticalScrollBar"/>) will be enabled and automatically made visible
/// when the dimension of the <see cref="View.Viewport"/> is smaller than the dimension of <see cref="View.GetContentSize()"/>.
/// </summary>
EnableVerticalScrollBar = 128,

/// <summary>
/// If set, the horizontal and vertical scroll bars (see cref="View.HorizontalScrollBar"/> and <see cref="View.VerticalScrollBar"/>)
/// will be enabled and automatically made visible when the dimension of the <see cref="View.Viewport"/> is smaller than the
/// dimension of <see cref="View.GetContentSize()"/>.
/// </summary>
EnableScrollBars = EnableHorizontalScrollBar | EnableVerticalScrollBar
}
12 changes: 6 additions & 6 deletions UICatalog/Scenarios/CharacterMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ public CharMap ()

ScrollBar hScrollBar = new ()
{
X = 0,
X = RowLabelWidth + 1,
Y = Pos.AnchorEnd (),
Width = Dim.Fill (1),
Size = GetContentSize ().Width,
Size = COLUMN_WIDTH * 15,
Orientation = Orientation.Horizontal
};

Expand All @@ -476,10 +476,10 @@ public CharMap ()
ScrollBar vScrollBar = new ()
{
X = Pos.AnchorEnd (),
Y = 0,
Y = 1, // Header
Height = Dim.Fill (Dim.Func (() => hScrollBar.Visible ? 1 : 0)),
Orientation = Orientation.Vertical,
Size = GetContentSize ().Height
Size = GetContentSize ().Height - _rowHeight, // Minus one row so last row stays visible
};
vScrollBar.PositionChanged += (sender, args) => { Viewport = Viewport with { Y = args.CurrentValue }; };

Expand All @@ -488,7 +488,7 @@ public CharMap ()

ViewportChanged += (sender, args) =>
{
vScrollBar.Size = GetContentSize ().Height;
vScrollBar.Size = GetContentSize ().Height - _rowHeight; // Minus one row so last row stays visible
vScrollBar.Position = Viewport.Y;
};
}
Expand Down Expand Up @@ -970,7 +970,7 @@ private void ShowDetails ()
document.RootElement,
new
JsonSerializerOptions
{ WriteIndented = true }
{ WriteIndented = true }
);
}

Expand Down

0 comments on commit b19437d

Please sign in to comment.