ScrollView.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. namespace Terminal.Gui {
  3. /// <summary>
  4. ///
  5. /// </summary>
  6. /// <remarks>
  7. /// <para>
  8. /// The subviews that are added to this scrollview are offset by the
  9. /// ContentOffset property. The view itself is a window into the
  10. /// space represented by the ContentSize.
  11. /// </para>
  12. /// <para>
  13. ///
  14. /// </para>
  15. /// </remarks>
  16. public class ScrollView : View {
  17. public ScrollView (Rect frame) : base (frame)
  18. {
  19. }
  20. Rect contentSize;
  21. Point contentOffset;
  22. bool showHorizontalScrollIndicator;
  23. bool showVerticalScrollIndicator;
  24. /// <summary>
  25. /// Represents the contents of the data shown inside the scrolview
  26. /// </summary>
  27. /// <value>The size of the content.</value>
  28. public Rect ContentSize {
  29. get {
  30. return contentSize;
  31. }
  32. set {
  33. contentSize = value;
  34. }
  35. }
  36. /// <summary>
  37. /// Represents the top left corner coordinate that is displayed by the scrollview
  38. /// </summary>
  39. /// <value>The content offset.</value>
  40. public Point ContentOffset {
  41. get {
  42. return contentOffset;
  43. }
  44. set {
  45. contentOffset = value;
  46. }
  47. }
  48. /// <summary>
  49. /// Gets or sets the visibility for the horizontal scroll indicator.
  50. /// </summary>
  51. /// <value><c>true</c> if show vertical scroll indicator; otherwise, <c>false</c>.</value>
  52. public bool ShowHorizontalScrollIndicator {
  53. get => showHorizontalScrollIndicator;
  54. set {
  55. showHorizontalScrollIndicator = value;
  56. SetNeedsDisplay ();
  57. }
  58. }
  59. /// <summary>
  60. /// /// Gets or sets the visibility for the vertical scroll indicator.
  61. /// </summary>
  62. /// <value><c>true</c> if show vertical scroll indicator; otherwise, <c>false</c>.</value>
  63. public bool ShowVerticalScrollIndicator {
  64. get => showVerticalScrollIndicator;
  65. set {
  66. showVerticalScrollIndicator = value;
  67. SetNeedsDisplay ();
  68. }
  69. }
  70. /// <summary>
  71. /// This event is raised when the contents have scrolled
  72. /// </summary>
  73. public event Action<ScrollView> Scrolled;
  74. public override void Redraw(Rect region)
  75. {
  76. base.Redraw(region);
  77. }
  78. }
  79. }