diff --git a/Terminal.Gui/View/View.ScrollBars.cs b/Terminal.Gui/View/View.ScrollBars.cs
index e9945cf94..24192b303 100644
--- a/Terminal.Gui/View/View.ScrollBars.cs
+++ b/Terminal.Gui/View/View.ScrollBars.cs
@@ -45,7 +45,7 @@ public partial class View
var scrollBar = new ScrollBar
{
Orientation = orientation,
- AutoHide = true
+ Visible = false, // Initially hidden until needed
};
if (orientation == Orientation.Vertical)
@@ -207,16 +207,16 @@ public partial class View
}
else if (viewportSettings.HasFlag (ViewportSettings.AllowNegativeX))
{
- _horizontalScrollBar.Value.AutoHide = false;
+ _horizontalScrollBar.Value.AutoShow = false;
}
else if (viewportSettings.HasFlag (ViewportSettings.AllowNegativeY))
{
- _verticalScrollBar.Value.AutoHide = false;
+ _verticalScrollBar.Value.AutoShow = false;
}
else if (viewportSettings.HasFlag (ViewportSettings.AllowNegativeLocation))
{
- _horizontalScrollBar.Value.AutoHide = false;
- _verticalScrollBar.Value.AutoHide = false;
+ _horizontalScrollBar.Value.AutoShow = false;
+ _verticalScrollBar.Value.AutoShow = false;
}
else if (viewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
{
diff --git a/Terminal.Gui/Views/ScrollBar/ScrollBar.cs b/Terminal.Gui/Views/ScrollBar/ScrollBar.cs
index c73726048..dac1f1f0e 100644
--- a/Terminal.Gui/Views/ScrollBar/ScrollBar.cs
+++ b/Terminal.Gui/Views/ScrollBar/ScrollBar.cs
@@ -4,8 +4,6 @@ using System.ComponentModel;
namespace Terminal.Gui;
-// TODO: When scrollbars autohide, reset viewport to 0
-
///
/// Indicates the size of scrollable content and controls the position of the visible content, either vertically or
/// horizontally.
@@ -16,10 +14,11 @@ namespace Terminal.Gui;
///
///
///
-/// ScrollBars can be enabled on any View calling . By default, the built-in View scrollbars have
-/// see set to thus will only be visible if the content size (see is
-/// larger than see
-///
+/// By default, the built-in View scrollbars have both and set to
+/// .
+/// To enable them, either set set to or explictly set
+///
+/// to .
///
///
/// By default, this view cannot be focused and does not support keyboard input.
@@ -97,7 +96,7 @@ public class ScrollBar : View, IOrientation, IDesignable
private void ShowHide ()
{
- if (AutoHide)
+ if (AutoShow)
{
Visible = VisibleContentSize < ScrollableContentSize;
}
@@ -202,26 +201,27 @@ public class ScrollBar : View, IOrientation, IDesignable
///
public int Increment { get; set; } = 1;
- // AutoHide should be false by default. Views should not be hidden by default.
- private bool _autoHide;
+ // AutoShow should be false by default. Views should not be hidden by default.
+ private bool _autoShow;
///
- /// Gets or sets whether will be set to if the dimension of the
- /// scroll bar is greater than or equal to .
+ /// Gets or sets whether will be set to if the dimension of the
+ /// scroll bar is less than and if greater than or equal
+ /// to.
///
///
/// The default is .
///
- public bool AutoHide
+ public bool AutoShow
{
- get => _autoHide;
+ get => _autoShow;
set
{
- if (_autoHide != value)
+ if (_autoShow != value)
{
- _autoHide = value;
+ _autoShow = value;
- if (!AutoHide)
+ if (!AutoShow)
{
Visible = true;
}
diff --git a/UICatalog/Scenarios/AdvancedClipping.cs b/UICatalog/Scenarios/AdvancedClipping.cs
deleted file mode 100644
index 840886702..000000000
--- a/UICatalog/Scenarios/AdvancedClipping.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-using System.Text;
-using System.Timers;
-using Terminal.Gui;
-
-namespace UICatalog.Scenarios;
-
-[ScenarioMetadata ("AdvancedClipping", "AdvancedClipping Tester")]
-[ScenarioCategory ("AdvancedClipping")]
-public class AdvancedClipping : Scenario
-{
- private int _hotkeyCount;
-
- public override void Main ()
- {
- Application.Init ();
-
- Window app = new ()
- {
- Title = GetQuitKeyAndName (),
- //BorderStyle = LineStyle.None
- };
-
- app.DrawingContent += (s, e) =>
- {
- app!.FillRect (app!.Viewport, CM.Glyphs.Dot);
- e.Cancel = true;
- };
-
- var arrangementEditor = new ArrangementEditor ()
- {
- X = Pos.AnchorEnd (),
- Y = 0,
- AutoSelectViewToEdit = true,
- };
- app.Add (arrangementEditor);
-
- View tiledView1 = CreateTiledView (1, 0, 0);
-
- tiledView1.Width = 30;
-
- ProgressBar tiledProgressBar1 = new ()
- {
- X = 0,
- Y = Pos.AnchorEnd (),
- Width = Dim.Fill (),
- Id = "tiledProgressBar",
- BidirectionalMarquee = true,
- };
- tiledView1.Add (tiledProgressBar1);
-
- View tiledView2 = CreateTiledView (2, 4, 2);
-
- ProgressBar tiledProgressBar2 = new ()
- {
- X = 0,
- Y = Pos.AnchorEnd (),
- Width = Dim.Fill (),
- Id = "tiledProgressBar",
- BidirectionalMarquee = true,
- ProgressBarStyle = ProgressBarStyle.MarqueeBlocks
- // BorderStyle = LineStyle.Rounded
- };
- tiledView2.Add (tiledProgressBar2);
-
- app.Add (tiledView1);
- app.Add (tiledView2);
-
- View tiledView3 = CreateTiledView (3, 8, 4);
- app.Add (tiledView3);
-
- // View overlappedView1 = CreateOverlappedView (1, 30, 2);
-
- //ProgressBar progressBar = new ()
- //{
- // X = Pos.AnchorEnd (),
- // Y = Pos.AnchorEnd (),
- // Width = Dim.Fill (),
- // Id = "progressBar",
- // BorderStyle = LineStyle.Rounded
- //};
- //overlappedView1.Add (progressBar);
-
-
- //View overlappedView2 = CreateOverlappedView (2, 32, 4);
- //View overlappedView3 = CreateOverlappedView (3, 34, 6);
-
- //app.Add (overlappedView1);
- //app.Add (overlappedView2);
- //app.Add (overlappedView3);
-
- Timer progressTimer = new Timer (150)
- {
- AutoReset = true
- };
-
- progressTimer.Elapsed += (s, e) =>
- {
- tiledProgressBar1.Pulse ();
- tiledProgressBar2.Pulse ();
- Application.Wakeup ();
- };
-
- progressTimer.Start ();
- Application.Run (app);
- progressTimer.Stop ();
- app.Dispose ();
- Application.Shutdown ();
-
- return;
- }
-
- private View CreateOverlappedView (int id, Pos x, Pos y)
- {
- var overlapped = new View
- {
- X = x,
- Y = y,
- Height = Dim.Auto (minimumContentDim: 4),
- Width = Dim.Auto (minimumContentDim: 14),
- Title = $"Overlapped{id} _{GetNextHotKey ()}",
- ColorScheme = Colors.ColorSchemes ["Toplevel"],
- Id = $"Overlapped{id}",
- ShadowStyle = ShadowStyle.Transparent,
- BorderStyle = LineStyle.Double,
- CanFocus = true, // Can't drag without this? BUGBUG
- TabStop = TabBehavior.TabGroup,
- Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped | ViewArrangement.Resizable
- };
- return overlapped;
- }
-
- private View CreateTiledView (int id, Pos x, Pos y)
- {
- var tiled = new View
- {
- X = x,
- Y = y,
- Height = Dim.Auto (minimumContentDim: 8),
- Width = Dim.Auto (minimumContentDim: 15),
- Title = $"Tiled{id} _{GetNextHotKey ()}",
- Id = $"Tiled{id}",
- Text = $"Tiled{id}",
- BorderStyle = LineStyle.Single,
- CanFocus = true, // Can't drag without this? BUGBUG
- TabStop = TabBehavior.TabStop,
- Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable,
- ShadowStyle = ShadowStyle.Transparent,
- };
- //tiled.Padding.Thickness = new (1);
- //tiled.Padding.Diagnostics = ViewDiagnosticFlags.Thickness;
-
- //tiled.Margin.Thickness = new (1);
-
- FrameView fv = new ()
- {
- Title = "FrameView",
- Width = 15,
- Height = 3,
- };
- tiled.Add (fv);
-
- return tiled;
- }
-
- private char GetNextHotKey () { return (char)('A' + _hotkeyCount++); }
-}
diff --git a/UICatalog/Scenarios/CharacterMap/CharMap.cs b/UICatalog/Scenarios/CharacterMap/CharMap.cs
index 8fae22bf4..bcc20772d 100644
--- a/UICatalog/Scenarios/CharacterMap/CharMap.cs
+++ b/UICatalog/Scenarios/CharacterMap/CharMap.cs
@@ -144,7 +144,7 @@ public class CharMap : View, IDesignable
_hScrollBar = new ()
{
- AutoHide = false,
+ AutoShow = false,
X = RowLabelWidth,
Y = Pos.AnchorEnd (),
Orientation = Orientation.Horizontal,
@@ -155,7 +155,7 @@ public class CharMap : View, IDesignable
_vScrollBar = new ()
{
- AutoHide = false,
+ AutoShow = false,
X = Pos.AnchorEnd (),
Y = 1, // Header
Height = Dim.Fill (Dim.Func (() => Padding.Thickness.Bottom)),
diff --git a/UICatalog/Scenarios/Clipping.cs b/UICatalog/Scenarios/Clipping.cs
index b7f36f820..621bfc860 100644
--- a/UICatalog/Scenarios/Clipping.cs
+++ b/UICatalog/Scenarios/Clipping.cs
@@ -1,113 +1,169 @@
-using System.Collections.Generic;
+using System.Text;
+using System.Timers;
using Terminal.Gui;
namespace UICatalog.Scenarios;
-[ScenarioMetadata ("Clipping", "Used to test that things clip correctly")]
-[ScenarioCategory ("Tests")]
-[ScenarioCategory ("Drawing")]
+[ScenarioMetadata ("Clipping", "Demonstrates non-rectangular clip region support.")]
[ScenarioCategory ("Scrolling")]
+[ScenarioCategory ("Layout")]
+[ScenarioCategory ("Arrangement")]
+[ScenarioCategory ("Tests")]
public class Clipping : Scenario
{
+ private int _hotkeyCount;
+
public override void Main ()
{
Application.Init ();
- var win = new Window { Title = GetQuitKeyAndName () };
- var label = new Label
+ Window app = new ()
{
- X = 0, Y = 0, Text = "ScrollView (new Rectangle (3, 3, 50, 20)) with a 200, 100 GetContentSize ()..."
+ Title = GetQuitKeyAndName (),
+ //BorderStyle = LineStyle.None
};
- win.Add (label);
- //var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
- //scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
- //// BUGBUG: set_ContentSize is supposed to be `protected`.
- //scrollView.SetContentSize (new (200, 100));
+ app.DrawingContent += (s, e) =>
+ {
+ app!.FillRect (app!.Viewport, CM.Glyphs.Dot);
+ e.Cancel = true;
+ };
- ////ContentOffset = Point.Empty,
- //scrollView.AutoHideScrollBars = true;
- //scrollView.ShowVerticalScrollIndicator = true;
- //scrollView.ShowHorizontalScrollIndicator = true;
+ var arrangementEditor = new ArrangementEditor ()
+ {
+ X = Pos.AnchorEnd (),
+ Y = 0,
+ AutoSelectViewToEdit = true,
+ };
+ app.Add (arrangementEditor);
- //var embedded1 = new View
+ View tiledView1 = CreateTiledView (1, 0, 0);
+
+ tiledView1.Width = 30;
+
+ ProgressBar tiledProgressBar1 = new ()
+ {
+ X = 0,
+ Y = Pos.AnchorEnd (),
+ Width = Dim.Fill (),
+ Id = "tiledProgressBar",
+ BidirectionalMarquee = true,
+ };
+ tiledView1.Add (tiledProgressBar1);
+
+ View tiledView2 = CreateTiledView (2, 4, 2);
+
+ ProgressBar tiledProgressBar2 = new ()
+ {
+ X = 0,
+ Y = Pos.AnchorEnd (),
+ Width = Dim.Fill (),
+ Id = "tiledProgressBar",
+ BidirectionalMarquee = true,
+ ProgressBarStyle = ProgressBarStyle.MarqueeBlocks
+ // BorderStyle = LineStyle.Rounded
+ };
+ tiledView2.Add (tiledProgressBar2);
+
+ app.Add (tiledView1);
+ app.Add (tiledView2);
+
+ View tiledView3 = CreateTiledView (3, 8, 4);
+ app.Add (tiledView3);
+
+ // View overlappedView1 = CreateOverlappedView (1, 30, 2);
+
+ //ProgressBar progressBar = new ()
//{
- // Title = "1",
- // X = 3,
- // Y = 3,
- // Width = Dim.Fill (3),
- // Height = Dim.Fill (3),
- // ColorScheme = Colors.ColorSchemes ["Dialog"],
- // Id = "1",
- // BorderStyle = LineStyle.Rounded,
- // Arrangement = ViewArrangement.Movable
+ // X = Pos.AnchorEnd (),
+ // Y = Pos.AnchorEnd (),
+ // Width = Dim.Fill (),
+ // Id = "progressBar",
+ // BorderStyle = LineStyle.Rounded
//};
+ //overlappedView1.Add (progressBar);
- //var embedded2 = new View
- //{
- // Title = "2",
- // X = 3,
- // Y = 3,
- // Width = Dim.Fill (3),
- // Height = Dim.Fill (3),
- // ColorScheme = Colors.ColorSchemes ["Error"],
- // Id = "2",
- // BorderStyle = LineStyle.Rounded,
- // Arrangement = ViewArrangement.Movable
- //};
- //embedded1.Add (embedded2);
- //var embedded3 = new View
- //{
- // Title = "3",
- // X = 3,
- // Y = 3,
- // Width = Dim.Fill (3),
- // Height = Dim.Fill (3),
- // ColorScheme = Colors.ColorSchemes ["TopLevel"],
- // Id = "3",
- // BorderStyle = LineStyle.Rounded,
- // Arrangement = ViewArrangement.Movable
- //};
+ //View overlappedView2 = CreateOverlappedView (2, 32, 4);
+ //View overlappedView3 = CreateOverlappedView (3, 34, 6);
- //var testButton = new Button { X = 2, Y = 2, Text = "click me" };
- //testButton.Accepting += (s, e) => { MessageBox.Query (10, 5, "Test", "test message", "Ok"); };
- //embedded3.Add (testButton);
- //embedded2.Add (embedded3);
+ //app.Add (overlappedView1);
+ //app.Add (overlappedView2);
+ //app.Add (overlappedView3);
- //scrollView.Add (embedded1);
+ Timer progressTimer = new Timer (150)
+ {
+ AutoReset = true
+ };
- //win.Add (scrollView);
+ progressTimer.Elapsed += (s, e) =>
+ {
+ tiledProgressBar1.Pulse ();
+ tiledProgressBar2.Pulse ();
+ Application.Wakeup ();
+ };
- Application.Run (win);
- win.Dispose ();
+ progressTimer.Start ();
+ Application.Run (app);
+ progressTimer.Stop ();
+ app.Dispose ();
Application.Shutdown ();
+
+ return;
}
- public override List GetDemoKeyStrokes ()
+ private View CreateOverlappedView (int id, Pos x, Pos y)
{
- var keys = new List ();
-
- for (int i = 0; i < 25; i++)
+ var overlapped = new View
{
- keys.Add (Key.CursorDown);
- }
-
- for (int i = 0; i < 25; i++)
- {
- keys.Add (Key.CursorRight);
- }
-
- for (int i = 0; i < 25; i++)
- {
- keys.Add (Key.CursorLeft);
- }
-
- for (int i = 0; i < 25; i++)
- {
- keys.Add (Key.CursorUp);
- }
-
- return keys;
+ X = x,
+ Y = y,
+ Height = Dim.Auto (minimumContentDim: 4),
+ Width = Dim.Auto (minimumContentDim: 14),
+ Title = $"Overlapped{id} _{GetNextHotKey ()}",
+ ColorScheme = Colors.ColorSchemes ["Toplevel"],
+ Id = $"Overlapped{id}",
+ ShadowStyle = ShadowStyle.Transparent,
+ BorderStyle = LineStyle.Double,
+ CanFocus = true, // Can't drag without this? BUGBUG
+ TabStop = TabBehavior.TabGroup,
+ Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped | ViewArrangement.Resizable
+ };
+ return overlapped;
}
+
+ private View CreateTiledView (int id, Pos x, Pos y)
+ {
+ var tiled = new View
+ {
+ X = x,
+ Y = y,
+ Height = Dim.Auto (minimumContentDim: 8),
+ Width = Dim.Auto (minimumContentDim: 15),
+ Title = $"Tiled{id} _{GetNextHotKey ()}",
+ Id = $"Tiled{id}",
+ Text = $"Tiled{id}",
+ BorderStyle = LineStyle.Single,
+ CanFocus = true, // Can't drag without this? BUGBUG
+ TabStop = TabBehavior.TabStop,
+ Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable,
+ ShadowStyle = ShadowStyle.Transparent,
+ };
+ //tiled.Padding.Thickness = new (1);
+ //tiled.Padding.Diagnostics = ViewDiagnosticFlags.Thickness;
+
+ //tiled.Margin.Thickness = new (1);
+
+ FrameView fv = new ()
+ {
+ Title = "FrameView",
+ Width = 15,
+ Height = 3,
+ };
+ tiled.Add (fv);
+
+ return tiled;
+ }
+
+ private char GetNextHotKey () { return (char)('A' + _hotkeyCount++); }
}
diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs
index 16f3417dd..e0abc19b8 100644
--- a/UICatalog/Scenarios/Editor.cs
+++ b/UICatalog/Scenarios/Editor.cs
@@ -262,7 +262,7 @@ public class Editor : Scenario
AlignmentModes = AlignmentModes.StartToEnd | AlignmentModes.IgnoreFirstOrLast
};
- _textView.VerticalScrollBar.AutoHide = false;
+ _textView.VerticalScrollBar.AutoShow = false;
_textView.UnwrappedCursorPosition += (s, e) =>
{
siCursorPosition.Title = $"Ln {e.Point.Y + 1}, Col {e.Point.X + 1}";
diff --git a/UICatalog/Scenarios/Editors/EventLog.cs b/UICatalog/Scenarios/Editors/EventLog.cs
index 9e4307722..e9ce2efba 100644
--- a/UICatalog/Scenarios/Editors/EventLog.cs
+++ b/UICatalog/Scenarios/Editors/EventLog.cs
@@ -39,8 +39,8 @@ public class EventLog : ListView
Initialized += EventLog_Initialized;
- HorizontalScrollBar.AutoHide = true;
- VerticalScrollBar.AutoHide = true;
+ HorizontalScrollBar.AutoShow = true;
+ VerticalScrollBar.AutoShow = true;
AddCommand (Command.DeleteAll,
() =>
diff --git a/UICatalog/Scenarios/HexEditor.cs b/UICatalog/Scenarios/HexEditor.cs
index 74065ebf5..d7b722381 100644
--- a/UICatalog/Scenarios/HexEditor.cs
+++ b/UICatalog/Scenarios/HexEditor.cs
@@ -44,7 +44,7 @@ public class HexEditor : Scenario
_hexView.Arrangement = ViewArrangement.Resizable;
_hexView.Edited += _hexView_Edited;
_hexView.PositionChanged += _hexView_PositionChanged;
- _hexView.VerticalScrollBar.AutoHide = false;
+ _hexView.VerticalScrollBar.AutoShow = false;
app.Add (_hexView);
diff --git a/UICatalog/Scenarios/ListViewWithSelection.cs b/UICatalog/Scenarios/ListViewWithSelection.cs
index 46124ce06..e90080cb8 100644
--- a/UICatalog/Scenarios/ListViewWithSelection.cs
+++ b/UICatalog/Scenarios/ListViewWithSelection.cs
@@ -10,19 +10,20 @@ using Terminal.Gui;
namespace UICatalog.Scenarios;
-[ScenarioMetadata ("List View With Selection", "ListView with columns and selection")]
+[ScenarioMetadata ("List View With Selection", "ListView with custom rendering, columns, and selection")]
[ScenarioCategory ("Controls")]
[ScenarioCategory ("ListView")]
+[ScenarioCategory ("Scrolling")]
public class ListViewWithSelection : Scenario
{
- private CheckBox _allowMarkingCB;
- private CheckBox _allowMultipleCB;
- private CheckBox _customRenderCB;
+ private CheckBox _allowMarkingCb;
+ private CheckBox _allowMultipleCb;
+ private CheckBox _customRenderCb;
+ private CheckBox _keep;
private ListView _listView;
private ObservableCollection _scenarios;
private Window _appWindow;
-
private ObservableCollection _eventList = new ();
private ListView _eventListView;
@@ -38,90 +39,54 @@ public class ListViewWithSelection : Scenario
_scenarios = GetScenarios ();
- _customRenderCB = new CheckBox { X = 0, Y = 0, Text = "Use custom _rendering" };
- _appWindow.Add (_customRenderCB);
- _customRenderCB.CheckedStateChanging += _customRenderCB_Toggle;
+ _customRenderCb = new CheckBox { X = 0, Y = 0, Text = "Custom _Rendering" };
+ _appWindow.Add (_customRenderCb);
+ _customRenderCb.CheckedStateChanging += CustomRenderCB_Toggle;
- _allowMarkingCB = new CheckBox
+ _allowMarkingCb = new CheckBox
{
- X = Pos.Right (_customRenderCB) + 1, Y = 0, Text = "Allow _Marking", AllowCheckStateNone = false
- };
- _appWindow.Add (_allowMarkingCB);
- _allowMarkingCB.CheckedStateChanging += AllowMarkingCB_Toggle;
-
- _allowMultipleCB = new CheckBox
- {
- X = Pos.Right (_allowMarkingCB) + 1,
+ X = Pos.Right (_customRenderCb) + 1,
Y = 0,
- Visible = _allowMarkingCB.CheckedState == CheckState.Checked,
- Text = "Allow Multi-_Select"
+ Text = "Allows_Marking",
+ AllowCheckStateNone = false
};
- _appWindow.Add (_allowMultipleCB);
- _allowMultipleCB.CheckedStateChanging += AllowMultipleCB_Toggle;
+ _appWindow.Add (_allowMarkingCb);
+ _allowMarkingCb.CheckedStateChanging += AllowsMarkingCB_Toggle;
+
+ _allowMultipleCb = new CheckBox
+ {
+ X = Pos.Right (_allowMarkingCb) + 1,
+ Y = 0,
+ Enabled = _allowMarkingCb.CheckedState == CheckState.Checked,
+ Text = "AllowsMulti_Select"
+ };
+ _appWindow.Add (_allowMultipleCb);
+ _allowMultipleCb.CheckedStateChanging += AllowsMultipleSelectionCB_Toggle;
+
+ _keep = new CheckBox
+ {
+ X = Pos.Right (_allowMultipleCb) + 1,
+ Y = 0,
+ Text = "Allow_YGreaterThanContentHeight"
+ };
+ _appWindow.Add (_keep);
+ _keep.CheckedStateChanging += AllowYGreaterThanContentHeightCB_Toggle;
_listView = new ListView
{
Title = "_ListView",
X = 0,
- Y = Pos.Bottom(_allowMarkingCB),
+ Y = Pos.Bottom (_allowMarkingCb),
Width = Dim.Func (() => _listView?.MaxLength ?? 10),
Height = Dim.Fill (),
AllowsMarking = false,
AllowsMultipleSelection = false
};
- //_listView.Border.Thickness = new Thickness (0, 1, 0, 0);
_listView.RowRender += ListView_RowRender;
_appWindow.Add (_listView);
- //var scrollBar = new ScrollBarView (_listView, true);
-
- //scrollBar.ChangedPosition += (s, e) =>
- //{
- // _listView.TopItem = scrollBar.Position;
-
- // if (_listView.TopItem != scrollBar.Position)
- // {
- // scrollBar.Position = _listView.TopItem;
- // }
-
- // _listView.SetNeedsDraw ();
- //};
-
- //scrollBar.OtherScrollBarView.ChangedPosition += (s, e) =>
- //{
- // _listView.LeftItem = scrollBar.OtherScrollBarView.Position;
-
- // if (_listView.LeftItem != scrollBar.OtherScrollBarView.Position)
- // {
- // scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
- // }
-
- // _listView.SetNeedsDraw ();
- //};
-
- //_listView.DrawingContent += (s, e) =>
- //{
- // scrollBar.Size = _listView.Source.Count;
- // scrollBar.Position = _listView.TopItem;
- // scrollBar.OtherScrollBarView.Size = _listView.MaxLength;
- // scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
- // scrollBar.Refresh ();
- //};
-
_listView.SetSource (_scenarios);
- var k = "_Keep Content Always In Viewport";
-
- var keepCheckBox = new CheckBox
- {
- X = Pos.Right(_allowMultipleCB) + 1,
- Y = 0,
- Text = k,
- //CheckedState = scrollBar.AutoHideScrollBars ? CheckState.Checked : CheckState.UnChecked
- };
- //keepCheckBox.CheckedStateChanging += (s, e) => scrollBar.KeepContentAlwaysInViewport = e.NewValue == CheckState.Checked;
- _appWindow.Add (keepCheckBox);
-
_eventList = new ();
_eventListView = new ListView
@@ -140,6 +105,7 @@ public class ListViewWithSelection : Scenario
_listView.CollectionChanged += (s, a) => LogEvent (s as View, a, "CollectionChanged");
_listView.Accepting += (s, a) => LogEvent (s as View, a, "Accept");
_listView.Selecting += (s, a) => LogEvent (s as View, a, "Select");
+ _listView.VerticalScrollBar.AutoShow = true;
bool? LogEvent (View sender, EventArgs args, string message)
{
@@ -155,7 +121,7 @@ public class ListViewWithSelection : Scenario
Application.Shutdown ();
}
- private void _customRenderCB_Toggle (object sender, CancelEventArgs stateEventArgs)
+ private void CustomRenderCB_Toggle (object sender, CancelEventArgs stateEventArgs)
{
if (stateEventArgs.CurrentValue == CheckState.Checked)
{
@@ -169,19 +135,33 @@ public class ListViewWithSelection : Scenario
_appWindow.SetNeedsDraw ();
}
- private void AllowMarkingCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
+ private void AllowsMarkingCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
{
_listView.AllowsMarking = stateEventArgs.NewValue == CheckState.Checked;
- _allowMultipleCB.Visible = _listView.AllowsMarking;
+ _allowMultipleCb.Enabled = _listView.AllowsMarking;
_appWindow.SetNeedsDraw ();
}
- private void AllowMultipleCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
+ private void AllowsMultipleSelectionCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
{
_listView.AllowsMultipleSelection = stateEventArgs.NewValue == CheckState.Checked;
_appWindow.SetNeedsDraw ();
}
+
+ private void AllowYGreaterThanContentHeightCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
+ {
+ if (stateEventArgs.NewValue == CheckState.Checked)
+ {
+ _listView.ViewportSettings |= Terminal.Gui.ViewportSettings.AllowYGreaterThanContentHeight;
+ }
+ else
+ {
+ _listView.ViewportSettings &= ~Terminal.Gui.ViewportSettings.AllowYGreaterThanContentHeight;
+ }
+ _appWindow.SetNeedsDraw ();
+ }
+
private void ListView_RowRender (object sender, ListViewRowEventArgs obj)
{
if (obj.Row == _listView.SelectedItem)
diff --git a/UICatalog/Scenarios/ScrollBarDemo.cs b/UICatalog/Scenarios/ScrollBarDemo.cs
index e2eeb0747..b58f23d56 100644
--- a/UICatalog/Scenarios/ScrollBarDemo.cs
+++ b/UICatalog/Scenarios/ScrollBarDemo.cs
@@ -35,7 +35,7 @@ public class ScrollBarDemo : Scenario
var scrollBar = new ScrollBar
{
X = Pos.AnchorEnd () - 5,
- AutoHide = false,
+ AutoShow = false,
ScrollableContentSize = 100,
Height = Dim.Fill()
};
@@ -158,7 +158,7 @@ public class ScrollBarDemo : Scenario
var lblSize = new Label
{
- Text = "_Content Size:",
+ Text = "Scrollable_ContentSize:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
@@ -191,7 +191,7 @@ public class ScrollBarDemo : Scenario
var lblVisibleContentSize = new Label
{
- Text = "_VisibleContentSize::",
+ Text = "_VisibleContentSize:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
@@ -221,38 +221,6 @@ public class ScrollBarDemo : Scenario
}
};
- var lblSliderPosition = new Label
- {
- Text = "_SliderPosition:",
- TextAlignment = Alignment.End,
- Y = Pos.Align (Alignment.Start, groupId: 1),
- Width = Dim.Func (() => GetMaxLabelWidth (1))
- };
- demoFrame.Add (lblSliderPosition);
-
- Label scrollSliderPosition = new ()
- {
- Text = scrollBar.GetSliderPosition ().ToString (),
- X = Pos.Right (lblSliderPosition) + 1,
- Y = Pos.Top (lblSliderPosition)
- };
- demoFrame.Add (scrollSliderPosition);
-
- var lblScrolled = new Label
- {
- Text = "_Scrolled:",
- TextAlignment = Alignment.End,
- Y = Pos.Align (Alignment.Start, groupId: 1),
- Width = Dim.Func (() => GetMaxLabelWidth (1))
-
- };
- demoFrame.Add (lblScrolled);
- Label scrolled = new ()
- {
- X = Pos.Right (lblScrolled) + 1,
- Y = Pos.Top (lblScrolled)
- };
- demoFrame.Add (scrolled);
var lblPosition = new Label
{
@@ -294,35 +262,68 @@ public class ScrollBarDemo : Scenario
var lblOptions = new Label
{
- Text = "_Options:",
+ Text = "Options:",
TextAlignment = Alignment.End,
Y = Pos.Align (Alignment.Start, groupId: 1),
Width = Dim.Func (() => GetMaxLabelWidth (1))
};
demoFrame.Add (lblOptions);
- var ckbAutoHide = new CheckBox
+ var autoShow = new CheckBox
{
Y = Pos.Top (lblOptions),
X = Pos.Right (lblOptions) + 1,
- Text = $"Auto_Hide",
- CheckedState = scrollBar.AutoHide ? CheckState.Checked : CheckState.UnChecked
+ Text = $"_AutoShow",
+ CheckedState = scrollBar.AutoShow ? CheckState.Checked : CheckState.UnChecked
};
- ckbAutoHide.CheckedStateChanging += (s, e) => scrollBar.AutoHide = e.NewValue == CheckState.Checked;
- demoFrame.Add (ckbAutoHide);
+ autoShow.CheckedStateChanging += (s, e) => scrollBar.AutoShow = e.NewValue == CheckState.Checked;
+ demoFrame.Add (autoShow);
var ckbShowPercent = new CheckBox
{
Y = Pos.Top (lblOptions),
- X = Pos.Right (ckbAutoHide) + 1,
- Text = "Sho_wPercent",
+ X = Pos.Right (autoShow) + 1,
+ Text = "ShowP_ercent",
CheckedState = scrollBar.ShowPercent ? CheckState.Checked : CheckState.UnChecked
};
ckbShowPercent.CheckedStateChanging += (s, e) => scrollBar.ShowPercent = e.NewValue == CheckState.Checked;
demoFrame.Add (ckbShowPercent);
+ var lblSliderPosition = new Label
+ {
+ Text = "SliderPosition:",
+ TextAlignment = Alignment.End,
+ Y = Pos.Align (Alignment.Start, groupId: 1),
+ Width = Dim.Func (() => GetMaxLabelWidth (1))
+ };
+ demoFrame.Add (lblSliderPosition);
+
+ Label scrollSliderPosition = new ()
+ {
+ Text = scrollBar.GetSliderPosition ().ToString (),
+ X = Pos.Right (lblSliderPosition) + 1,
+ Y = Pos.Top (lblSliderPosition)
+ };
+ demoFrame.Add (scrollSliderPosition);
+
+ var lblScrolled = new Label
+ {
+ Text = "Scrolled:",
+ TextAlignment = Alignment.End,
+ Y = Pos.Align (Alignment.Start, groupId: 1),
+ Width = Dim.Func (() => GetMaxLabelWidth (1))
+
+ };
+ demoFrame.Add (lblScrolled);
+ Label scrolled = new ()
+ {
+ X = Pos.Right (lblScrolled) + 1,
+ Y = Pos.Top (lblScrolled)
+ };
+ demoFrame.Add (scrolled);
+
var lblScrollFrame = new Label
{
- Y = Pos.Bottom (lblOptions) + 1
+ Y = Pos.Bottom (lblScrolled) + 1
};
demoFrame.Add (lblScrollFrame);
diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs
index 37526a87b..ef79b7a67 100644
--- a/UICatalog/Scenarios/Scrolling.cs
+++ b/UICatalog/Scenarios/Scrolling.cs
@@ -50,7 +50,7 @@ public class Scrolling : Scenario
{
X = Pos.X (demoView),
Y = Pos.Bottom (demoView),
- Text = "Horizontal Scrollbar",
+ Text = "_HorizontalScrollBar.Visible",
CheckedState = demoView.HorizontalScrollBar.Visible ? CheckState.Checked : CheckState.UnChecked
};
app.Add (hCheckBox);
@@ -67,7 +67,7 @@ public class Scrolling : Scenario
{
X = Pos.Right (hCheckBox) + 3,
Y = Pos.Bottom (demoView),
- Text = "Vertical Scrollbar",
+ Text = "_VerticalScrollBar.Visible",
CheckedState = demoView.VerticalScrollBar.Visible ? CheckState.Checked : CheckState.UnChecked
};
app.Add (vCheckBox);
@@ -76,23 +76,31 @@ public class Scrolling : Scenario
demoView.VerticalScrollBar.Visible = args.CurrentValue == CheckState.Checked;
};
- var t = "Auto Hide Scrollbars";
-
var ahCheckBox = new CheckBox
{
- X = Pos.Left (demoView), Y = Pos.Bottom (hCheckBox), Text = t,
- CheckedState = demoView.HorizontalScrollBar.AutoHide ? CheckState.Checked : CheckState.UnChecked
+ X = Pos.Left (demoView),
+ Y = Pos.Bottom (hCheckBox),
+ Text = "_AutoHide (both)",
+ CheckedState = demoView.HorizontalScrollBar.AutoShow ? CheckState.Checked : CheckState.UnChecked
};
ahCheckBox.CheckedStateChanging += (s, e) =>
{
- demoView.HorizontalScrollBar.AutoHide = e.NewValue == CheckState.Checked;
- demoView.VerticalScrollBar.AutoHide = e.NewValue == CheckState.Checked;
- hCheckBox.CheckedState = CheckState.Checked;
- vCheckBox.CheckedState = CheckState.Checked;
+ demoView.HorizontalScrollBar.AutoShow = e.NewValue == CheckState.Checked;
+ demoView.VerticalScrollBar.AutoShow = e.NewValue == CheckState.Checked;
};
app.Add (ahCheckBox);
+ demoView.VerticalScrollBar.VisibleChanging += (sender, args) =>
+ {
+ vCheckBox.CheckedState = args.NewValue ? CheckState.Checked : CheckState.UnChecked;
+ };
+
+ demoView.HorizontalScrollBar.VisibleChanging += (sender, args) =>
+ {
+ hCheckBox.CheckedState = args.NewValue ? CheckState.Checked : CheckState.UnChecked;
+ };
+
var count = 0;
var mousePos = new Label
diff --git a/UICatalog/Scenarios/TreeViewFileSystem.cs b/UICatalog/Scenarios/TreeViewFileSystem.cs
index cce95fd84..f371a18f8 100644
--- a/UICatalog/Scenarios/TreeViewFileSystem.cs
+++ b/UICatalog/Scenarios/TreeViewFileSystem.cs
@@ -182,7 +182,7 @@ public class TreeViewFileSystem : Scenario
_treeViewFiles = new TreeView { X = 0, Y = 0, Width = Dim.Percent (50), Height = Dim.Fill () };
_treeViewFiles.DrawLine += TreeViewFiles_DrawLine;
- _treeViewFiles.VerticalScrollBar.AutoHide = false;
+ _treeViewFiles.VerticalScrollBar.AutoShow = false;
_detailsFrame = new DetailsFrame (_iconProvider)
{
diff --git a/UICatalog/Scenarios/ContentScrolling.cs b/UICatalog/Scenarios/ViewportSettings.cs
similarity index 62%
rename from UICatalog/Scenarios/ContentScrolling.cs
rename to UICatalog/Scenarios/ViewportSettings.cs
index dd65f84a7..4842f1529 100644
--- a/UICatalog/Scenarios/ContentScrolling.cs
+++ b/UICatalog/Scenarios/ViewportSettings.cs
@@ -5,14 +5,13 @@ using Terminal.Gui;
namespace UICatalog.Scenarios;
-[ScenarioMetadata ("Content Scrolling", "Demonstrates using View.Viewport and View.GetContentSize () to scroll content.")]
+[ScenarioMetadata ("ViewportSettings", "Demonstrates manipulating Viewport, ViewportSettings, and ContentSize to scroll content.")]
[ScenarioCategory ("Layout")]
[ScenarioCategory ("Drawing")]
[ScenarioCategory ("Scrolling")]
-public class ContentScrolling : Scenario
+[ScenarioCategory ("Adornments")]
+public class ViewportSettings : Scenario
{
- private ViewDiagnosticFlags _diagnosticFlags;
-
public class ScrollingDemoView : FrameView
{
public ScrollingDemoView ()
@@ -20,17 +19,17 @@ public class ContentScrolling : Scenario
Id = "ScrollingDemoView";
Width = Dim.Fill ();
Height = Dim.Fill ();
- ColorScheme = Colors.ColorSchemes ["Base"];
+ base.ColorScheme = Colors.ColorSchemes ["Base"];
- Text =
+ base.Text =
"Text (ScrollingDemoView.Text). This is long text.\nThe second line.\n3\n4\n5th line\nLine 6. This is a longer line that should wrap automatically.";
CanFocus = true;
BorderStyle = LineStyle.Rounded;
- Arrangement = ViewArrangement.Fixed;
+ Arrangement = ViewArrangement.Resizable;
SetContentSize (new (60, 40));
- ViewportSettings |= ViewportSettings.ClearContentOnly;
- ViewportSettings |= ViewportSettings.ClipContentOnly;
+ ViewportSettings |= Terminal.Gui.ViewportSettings.ClearContentOnly;
+ ViewportSettings |= Terminal.Gui.ViewportSettings.ClipContentOnly;
// Things this view knows how to do
AddCommand (Command.ScrollDown, () => ScrollVertical (1));
@@ -47,7 +46,8 @@ public class ContentScrolling : Scenario
// Add a status label to the border that shows Viewport and ContentSize values. Bit of a hack.
// TODO: Move to Padding with controls
- Border.Add (new Label { X = 20 });
+ Border?.Add (new Label { X = 20 });
+
ViewportChanged += VirtualDemoView_LayoutComplete;
MouseEvent += VirtualDemoView_MouseEvent;
@@ -84,7 +84,7 @@ public class ContentScrolling : Scenario
private void VirtualDemoView_LayoutComplete (object sender, DrawEventArgs drawEventArgs)
{
- Label frameLabel = Padding.Subviews.OfType