ViewportSettings.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. namespace Terminal.Gui;
  2. /// <summary>
  3. /// Settings for how the <see cref="View.Viewport"/> behaves.
  4. /// </summary>
  5. /// <remarks>
  6. /// See the Layout Deep Dive for more information:
  7. /// <see href="https://gui-cs.github.io/Terminal.GuiV2Docs/docs/layout.html"/>
  8. /// </remarks>
  9. [Flags]
  10. public enum ViewportSettings
  11. {
  12. /// <summary>
  13. /// No settings.
  14. /// </summary>
  15. None = 0b_0000,
  16. /// <summary>
  17. /// If set, <see cref="View.Viewport"/><c>.X</c> can be set to negative values enabling scrolling beyond the left of
  18. /// the
  19. /// content area.
  20. /// <para>
  21. /// When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to positive values.
  22. /// </para>
  23. /// </summary>
  24. AllowNegativeX = 0b_0001,
  25. /// <summary>
  26. /// If set, <see cref="View.Viewport"/><c>.Y</c> can be set to negative values enabling scrolling beyond the top of the
  27. /// content area.
  28. /// <para>
  29. /// When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to positive values.
  30. /// </para>
  31. /// </summary>
  32. AllowNegativeY = 0b_0010,
  33. /// <summary>
  34. /// If set, <see cref="View.Viewport"/><c>.Size</c> can be set to negative coordinates enabling scrolling beyond the
  35. /// top-left of the
  36. /// content area.
  37. /// <para>
  38. /// When not set, <see cref="View.Viewport"/><c>.Size</c> is constrained to positive coordinates.
  39. /// </para>
  40. /// </summary>
  41. AllowNegativeLocation = AllowNegativeX | AllowNegativeY,
  42. /// <summary>
  43. /// If set, <see cref="View.Viewport"/><c>.X</c> can be set values greater than <see cref="View.GetContentSize ()"/>
  44. /// <c>.Width</c> enabling scrolling beyond the right
  45. /// of the content area.
  46. /// <para>
  47. /// When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to <see cref="View.GetContentSize ()"/>
  48. /// <c>.Width - 1</c>.
  49. /// This means the last column of the content will remain visible even if there is an attempt to scroll the
  50. /// Viewport past the last column.
  51. /// </para>
  52. /// <para>
  53. /// The practical effect of this is that the last column of the content will always be visible.
  54. /// </para>
  55. /// </summary>
  56. AllowXGreaterThanContentWidth = 0b_0100,
  57. /// <summary>
  58. /// If set, <see cref="View.Viewport"/><c>.Y</c> can be set values greater than <see cref="View.GetContentSize ()"/>
  59. /// <c>.Height</c> enabling scrolling beyond the right
  60. /// of the content area.
  61. /// <para>
  62. /// When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to <see cref="View.GetContentSize ()"/>
  63. /// <c>.Height - 1</c>.
  64. /// This means the last row of the content will remain visible even if there is an attempt to scroll the Viewport
  65. /// past the last row.
  66. /// </para>
  67. /// <para>
  68. /// The practical effect of this is that the last row of the content will always be visible.
  69. /// </para>
  70. /// </summary>
  71. AllowYGreaterThanContentHeight = 0b_1000,
  72. /// <summary>
  73. /// If set, <see cref="View.Viewport"/><c>.Location</c> can be set values greater than
  74. /// <see cref="View.GetContentSize ()"/>
  75. /// enabling scrolling beyond the bottom-right
  76. /// of the content area.
  77. /// <para>
  78. /// When not set, <see cref="View.Viewport"/> is constrained to <see cref="View.GetContentSize ()"/><c> -1</c>.
  79. /// This means the last column and row of the content will remain visible even if there is an attempt to
  80. /// scroll the Viewport past the last column or row.
  81. /// </para>
  82. /// </summary>
  83. AllowLocationGreaterThanContentSize = AllowXGreaterThanContentWidth | AllowYGreaterThanContentHeight,
  84. /// <summary>
  85. /// If set and <see cref="View.Viewport"/><c>.Width</c> is greater than <see cref="View.GetContentSize ()"/>
  86. /// <c>.Width</c> <see cref="View.Viewport"/><c>.X</c> can be negative.
  87. /// <para>
  88. /// When not set, <see cref="View.Viewport"/><c>.X</c> will be constrained to non-negative values when
  89. /// <see cref="View.Viewport"/><c>.Width</c> is greater than <see cref="View.GetContentSize ()"/>
  90. /// <c>.Width</c>, preventing
  91. /// scrolling beyond the left of the Viewport.
  92. /// </para>
  93. /// <para>
  94. /// This can be useful in infinite scrolling scenarios.
  95. /// </para>
  96. /// </summary>
  97. AllowNegativeXWhenWidthGreaterThanContentWidth = 0b_0001_0000,
  98. /// <summary>
  99. /// If set and <see cref="View.Viewport"/><c>.Height</c> is greater than <see cref="View.GetContentSize ()"/>
  100. /// <c>.Height</c> <see cref="View.Viewport"/><c>.Y</c> can be negative.
  101. /// <para>
  102. /// When not set, <see cref="View.Viewport"/><c>.Y</c> will be constrained to non-negative values when
  103. /// <see cref="View.Viewport"/><c>.Height</c> is greater than <see cref="View.GetContentSize ()"/>
  104. /// <c>.Height</c>, preventing
  105. /// scrolling above the top of the Viewport.
  106. /// </para>
  107. /// <para>
  108. /// This can be useful in infinite scrolling scenarios.
  109. /// </para>
  110. /// </summary>
  111. AllowNegativeYWhenHeightGreaterThanContentHeight = 0b_0010_0000,
  112. /// <summary>
  113. /// The combination of <see cref="AllowNegativeXWhenWidthGreaterThanContentWidth"/> and
  114. /// <see cref="AllowNegativeYWhenHeightGreaterThanContentHeight"/>.
  115. /// </summary>
  116. AllowNegativeLocationWhenSizeGreaterThanContentSize = AllowNegativeXWhenWidthGreaterThanContentWidth | AllowNegativeYWhenHeightGreaterThanContentHeight,
  117. /// <summary>
  118. /// By default, clipping is applied to the <see cref="View.Viewport"/>. Setting this flag will cause clipping to be
  119. /// applied to the visible content area.
  120. /// </summary>
  121. ClipContentOnly = 0b_0100_0000,
  122. /// <summary>
  123. /// If set <see cref="View.ClearViewport"/> will clear only the portion of the content
  124. /// area that is visible within the <see cref="View.Viewport"/>. This is useful for views that have a
  125. /// content area larger than the Viewport and want the area outside the content to be visually distinct.
  126. /// <see cref="ClipContentOnly"/> must be set for this setting to work (clipping beyond the visible area must be
  127. /// disabled).
  128. /// </summary>
  129. ClearContentOnly = 0b_1000_0000,
  130. /// <summary>
  131. /// If set the View will be transparent: The <see cref="View.Viewport"/> will not be cleared when the View is drawn and the clip region
  132. /// will be set to clip the View's <see cref="View.Text"/> and <see cref="View.SubViews"/>.
  133. /// <para>
  134. /// Only the topmost View in a SubView Hierarchy can be transparent. Any subviews of the topmost transparent view
  135. /// will have indeterminate draw behavior.
  136. /// </para>
  137. /// <para>
  138. /// Combine this with <see cref="TransparentMouse"/> to get a view that is both visually transparent and transparent to the mouse.
  139. /// </para>
  140. /// </summary>
  141. Transparent = 0b_0001_0000_0000,
  142. /// <summary>
  143. /// If set the View will be transparent to mouse events: Any mouse event that occurs over the View (and it's SubViews) will be passed to the
  144. /// Views below it.
  145. /// <para>
  146. /// Combine this with <see cref="Transparent"/> to get a view that is both visually transparent and transparent to the mouse.
  147. /// </para>
  148. /// </summary>
  149. TransparentMouse = 0b_0010_0000_0000,
  150. }