diff --git a/.gitignore b/.gitignore index b46551486..1929d8960 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,7 @@ packages # User-specific files *.user -docfx/api \ No newline at end of file +docfx/api + +#git merge files +*.orig \ No newline at end of file diff --git a/Example/demo.cs b/Example/demo.cs index ed97a84b1..b1e7f8d58 100644 --- a/Example/demo.cs +++ b/Example/demo.cs @@ -508,7 +508,7 @@ static class Demo { //Application.UseSystemConsole = true; - Application.Init (); + Application.Init(); var top = Application.Top; diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs index 1526047bb..64197021d 100644 --- a/UICatalog/Scenarios/Scrolling.cs +++ b/UICatalog/Scenarios/Scrolling.cs @@ -7,6 +7,80 @@ namespace UICatalog { [ScenarioCategory ("Bug Repro")] class Scrolling : Scenario { + + //class Box10x : View, IScrollView { + class Box10x : View { + int w = 40; + int h = 50; + + public bool WantCursorPosition { get; set; } = false; + + public Box10x (int x, int y) : base (new Rect (x, y, 20, 10)) + { + } + + public Size GetContentSize () + { + return new Size (w, h); + } + + public void SetCursorPosition (Point pos) + { + throw new NotImplementedException (); + } + + public override void Redraw (Rect bounds) + { + //Point pos = new Point (region.X, region.Y); + Driver.SetAttribute (ColorScheme.Focus); + + for (int y = 0; y < h; y++) { + Move (0, y); + Driver.AddStr (y.ToString ()); + for (int x = 0; x < w - y.ToString ().Length; x++) { + //Driver.AddRune ((Rune)('0' + (x + y) % 10)); + if (y.ToString ().Length < w) + Driver.AddStr (" "); + } + } + //Move (pos.X, pos.Y); + } + } + + class Filler : View { + public Filler (Rect rect) : base (rect) + { + } + + public override void Redraw (Rect bounds) + { + Driver.SetAttribute (ColorScheme.Focus); + var f = Frame; + + for (int y = 0; y < f.Width; y++) { + Move (0, y); + for (int x = 0; x < f.Height; x++) { + Rune r; + switch (x % 3) { + case 0: + Driver.AddRune (y.ToString ().ToCharArray (0, 1) [0]); + if (y > 9) + Driver.AddRune (y.ToString ().ToCharArray (1, 1) [0]); + r = '.'; + break; + case 1: + r = 'o'; + break; + default: + r = 'O'; + break; + } + Driver.AddRune (r); + } + } + } + } + public override void Setup () { Win.X = 3; @@ -14,7 +88,8 @@ namespace UICatalog { Win.Width = Dim.Fill () - 3; Win.Height = Dim.Fill () - 3; var label = new Label ("ScrollView (new Rect (2, 2, 50, 20)) with a 200, 100 ContentSize...") { - X = 0, Y = 0, + X = 0, + Y = 0, ColorScheme = Colors.Dialog }; Win.Add (label); @@ -60,7 +135,7 @@ namespace UICatalog { scrollView.Add (new Button ("A very long button. Should be wide enough to demo clipping!") { X = 3, Y = 4, - Width = Dim.Fill(6), + Width = Dim.Fill (6), Clicked = () => MessageBox.Query (20, 7, "MessageBox", "Neat?", "Yes", "No") }); @@ -101,7 +176,44 @@ namespace UICatalog { }; scrollView.Add (anchorButton); - Win.Add (scrollView); + var scrollView2 = new ScrollView (new Rect (55, 2, 20, 8)) { + ContentSize = new Size (20, 50), + //ContentOffset = new Point (0, 0), + ShowVerticalScrollIndicator = true, + ShowHorizontalScrollIndicator = true + }; + scrollView2.Add (new Filler(new Rect (0, 0, 60, 40))); + + // This is just to debug the visuals of the scrollview when small + var scrollView3 = new ScrollView (new Rect (55, 15, 3, 3)) { + ContentSize = new Size (100, 100), + ShowVerticalScrollIndicator = true, + ShowHorizontalScrollIndicator = true + }; + scrollView3.Add (new Box10x (0, 0)); + + int count = 0; + var mousePos = new Label ("Mouse: "); + mousePos.X = Pos.Center (); + mousePos.Y = Pos.AnchorEnd (1); + mousePos.Width = 50; + Application.RootMouseEvent += delegate (MouseEvent me) { + mousePos.TextColor = Colors.TopLevel.Normal; + mousePos.Text = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count++}"; + }; + + var progress = new ProgressBar (); + progress.X = 5; + progress.Y = Pos.AnchorEnd (3); + progress.Width = 50; + bool timer (MainLoop caller) + { + progress.Pulse (); + return true; + } + Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (300), timer); + + Win.Add (scrollView, scrollView2, scrollView3, mousePos, progress); } } } \ No newline at end of file