|
@@ -1,5 +1,5 @@
|
|
//
|
|
//
|
|
-// ScrollView.cs: ScrollView and ScrollBarView views.
|
|
|
|
|
|
+// ScrollView.cs: ScrollView view.
|
|
//
|
|
//
|
|
// Authors:
|
|
// Authors:
|
|
// Miguel de Icaza ([email protected])
|
|
// Miguel de Icaza ([email protected])
|
|
@@ -15,345 +15,6 @@ using System;
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
|
|
|
|
namespace Terminal.Gui {
|
|
namespace Terminal.Gui {
|
|
- /// <summary>
|
|
|
|
- /// ScrollBarViews are views that display a 1-character scrollbar, either horizontal or vertical
|
|
|
|
- /// </summary>
|
|
|
|
- /// <remarks>
|
|
|
|
- /// <para>
|
|
|
|
- /// The scrollbar is drawn to be a representation of the Size, assuming that the
|
|
|
|
- /// scroll position is set at Position.
|
|
|
|
- /// </para>
|
|
|
|
- /// <para>
|
|
|
|
- /// If the region to display the scrollbar is larger than three characters,
|
|
|
|
- /// arrow indicators are drawn.
|
|
|
|
- /// </para>
|
|
|
|
- /// </remarks>
|
|
|
|
- public class ScrollBarView : View {
|
|
|
|
- bool vertical = false;
|
|
|
|
- int size = 0, position = 0;
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// If set to <c>true</c> this is a vertical scrollbar, otherwise, the scrollbar is horizontal.
|
|
|
|
- /// </summary>
|
|
|
|
- public bool IsVertical {
|
|
|
|
- get => vertical;
|
|
|
|
- set {
|
|
|
|
- vertical = value;
|
|
|
|
- SetNeedsDisplay ();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// The size of content the scrollbar represents.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <value>The size.</value>
|
|
|
|
- /// <remarks>The <see cref="Size"/> is typically the size of the virtual content. E.g. when a Scrollbar is
|
|
|
|
- /// part of a <see cref="ScrollView"/> the Size is set to the appropriate dimension of <see cref="ScrollView.ContentSize"/>.</remarks>
|
|
|
|
- public int Size {
|
|
|
|
- get => size;
|
|
|
|
- set {
|
|
|
|
- size = value;
|
|
|
|
- SetNeedsDisplay ();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// This event is raised when the position on the scrollbar has changed.
|
|
|
|
- /// </summary>
|
|
|
|
- public event Action ChangedPosition;
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// The position, relative to <see cref="Size"/>, to set the scrollbar at.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <value>The position.</value>
|
|
|
|
- public int Position {
|
|
|
|
- get => position;
|
|
|
|
- set {
|
|
|
|
- position = value;
|
|
|
|
- SetNeedsDisplay ();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Get or sets the view that host this <see cref="ScrollView"/>
|
|
|
|
- /// </summary>
|
|
|
|
- public ScrollView Host { get; internal set; }
|
|
|
|
-
|
|
|
|
- void SetPosition (int newPos)
|
|
|
|
- {
|
|
|
|
- Position = newPos;
|
|
|
|
- ChangedPosition?.Invoke ();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class using <see cref="LayoutStyle.Absolute"/> layout.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="rect">Frame for the scrollbar.</param>
|
|
|
|
- public ScrollBarView (Rect rect) : this (rect, 0, 0, false) { }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class using <see cref="LayoutStyle.Absolute"/> layout.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="rect">Frame for the scrollbar.</param>
|
|
|
|
- /// <param name="size">The size that this scrollbar represents. Sets the <see cref="Size"/> property.</param>
|
|
|
|
- /// <param name="position">The position within this scrollbar. Sets the <see cref="Position"/> property.</param>
|
|
|
|
- /// <param name="isVertical">If set to <c>true</c> this is a vertical scrollbar, otherwise, the scrollbar is horizontal. Sets the <see cref="IsVertical"/> property.</param>
|
|
|
|
- public ScrollBarView (Rect rect, int size, int position, bool isVertical) : base (rect)
|
|
|
|
- {
|
|
|
|
- Init (size, position, isVertical);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class using <see cref="LayoutStyle.Computed"/> layout.
|
|
|
|
- /// </summary>
|
|
|
|
- public ScrollBarView () : this (0, 0, false) { }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class using <see cref="LayoutStyle.Computed"/> layout.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="size">The size that this scrollbar represents.</param>
|
|
|
|
- /// <param name="position">The position within this scrollbar.</param>
|
|
|
|
- /// <param name="isVertical">If set to <c>true</c> this is a vertical scrollbar, otherwise, the scrollbar is horizontal.</param>
|
|
|
|
- public ScrollBarView (int size, int position, bool isVertical) : base ()
|
|
|
|
- {
|
|
|
|
- Init (size, position, isVertical);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void Init (int size, int position, bool isVertical)
|
|
|
|
- {
|
|
|
|
- vertical = isVertical;
|
|
|
|
- this.position = position;
|
|
|
|
- this.size = size;
|
|
|
|
- WantContinuousButtonPressed = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int posTopTee;
|
|
|
|
- int posLeftTee;
|
|
|
|
- int posBottomTee;
|
|
|
|
- int posRightTee;
|
|
|
|
-
|
|
|
|
- ///<inheritdoc/>
|
|
|
|
- public override void Redraw (Rect region)
|
|
|
|
- {
|
|
|
|
- if (ColorScheme == null || Size == 0)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- Driver.SetAttribute (ColorScheme.Normal);
|
|
|
|
-
|
|
|
|
- if (Bounds.Height == 0) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (vertical) {
|
|
|
|
- if (region.Right < Bounds.Width - 1)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- var col = Bounds.Width - 1;
|
|
|
|
- var bh = Bounds.Height;
|
|
|
|
- Rune special;
|
|
|
|
-
|
|
|
|
- if (bh < 4) {
|
|
|
|
- var by1 = position * bh / Size;
|
|
|
|
- var by2 = (position + bh) * bh / Size;
|
|
|
|
-
|
|
|
|
- Move (col, 0);
|
|
|
|
- if (Bounds.Height == 1) {
|
|
|
|
- Driver.AddRune (Driver.Diamond);
|
|
|
|
- } else {
|
|
|
|
- Driver.AddRune (Driver.UpArrow);
|
|
|
|
- }
|
|
|
|
- if (Bounds.Height == 3) {
|
|
|
|
- Move (col, 1);
|
|
|
|
- Driver.AddRune (Driver.Diamond);
|
|
|
|
- }
|
|
|
|
- if (Bounds.Height > 1) {
|
|
|
|
- Move (col, Bounds.Height - 1);
|
|
|
|
- Driver.AddRune (Driver.DownArrow);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- bh -= 2;
|
|
|
|
- var by1 = position * bh / Size;
|
|
|
|
- var by2 = Host.KeepContentAlwaysInViewport ? Math.Min (((position + bh) * bh / Size) + 1, bh - 1) : (position + bh) * bh / Size;
|
|
|
|
- if (Host.KeepContentAlwaysInViewport && by1 == by2) {
|
|
|
|
- by1 = Math.Max (by1 - 1, 0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Move (col, 0);
|
|
|
|
- Driver.AddRune (Driver.UpArrow);
|
|
|
|
- Move (col, Bounds.Height - 1);
|
|
|
|
- Driver.AddRune (Driver.DownArrow);
|
|
|
|
-
|
|
|
|
- bool hasTopTee = false;
|
|
|
|
- bool hasDiamond = false;
|
|
|
|
- bool hasBottomTee = false;
|
|
|
|
- for (int y = 0; y < bh; y++) {
|
|
|
|
- Move (col, y + 1);
|
|
|
|
- if ((y < by1 || y > by2) && ((position > 0 && !hasTopTee) || (hasTopTee && hasBottomTee))) {
|
|
|
|
- special = Driver.Stipple;
|
|
|
|
- } else {
|
|
|
|
- if (y != by2 && y > 1 && by2 - by1 == 0 && by1 < bh - 1 && hasTopTee && !hasDiamond) {
|
|
|
|
- hasDiamond = true;
|
|
|
|
- special = Driver.Diamond;
|
|
|
|
- } else {
|
|
|
|
- if (y == by1 && !hasTopTee) {
|
|
|
|
- hasTopTee = true;
|
|
|
|
- posTopTee = y;
|
|
|
|
- special = Driver.TopTee;
|
|
|
|
- } else if ((position == 0 && y == bh - 1 || y >= by2 || by2 == 0) && !hasBottomTee) {
|
|
|
|
- hasBottomTee = true;
|
|
|
|
- posBottomTee = y;
|
|
|
|
- special = Driver.BottomTee;
|
|
|
|
- } else {
|
|
|
|
- special = Driver.VLine;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Driver.AddRune (special);
|
|
|
|
- }
|
|
|
|
- if (!hasTopTee) {
|
|
|
|
- Move (col, Bounds.Height - 2);
|
|
|
|
- Driver.AddRune (Driver.TopTee);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (region.Bottom < Bounds.Height - 1)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- var row = Bounds.Height - 1;
|
|
|
|
- var bw = Bounds.Width;
|
|
|
|
- Rune special;
|
|
|
|
-
|
|
|
|
- if (bw < 4) {
|
|
|
|
- var bx1 = position * bw / Size;
|
|
|
|
- var bx2 = (position + bw) * bw / Size;
|
|
|
|
-
|
|
|
|
- Move (0, row);
|
|
|
|
- Driver.AddRune (Driver.LeftArrow);
|
|
|
|
- Driver.AddRune (Driver.RightArrow);
|
|
|
|
- } else {
|
|
|
|
- bw -= 2;
|
|
|
|
- var bx1 = position * bw / Size;
|
|
|
|
- var bx2 = Host.KeepContentAlwaysInViewport ? Math.Min (((position + bw) * bw / Size) + 1, bw - 1) : (position + bw) * bw / Size;
|
|
|
|
- if (Host.KeepContentAlwaysInViewport && bx1 == bx2) {
|
|
|
|
- bx1 = Math.Max (bx1 - 1, 0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Move (0, row);
|
|
|
|
- Driver.AddRune (Driver.LeftArrow);
|
|
|
|
-
|
|
|
|
- bool hasLeftTee = false;
|
|
|
|
- bool hasDiamond = false;
|
|
|
|
- bool hasRightTee = false;
|
|
|
|
- for (int x = 0; x < bw; x++) {
|
|
|
|
- if ((x < bx1 || x >= bx2 + 1) && ((position > 0 && !hasLeftTee) || (hasLeftTee && hasRightTee))) {
|
|
|
|
- special = Driver.Stipple;
|
|
|
|
- } else {
|
|
|
|
- if (x != bx2 && x > 1 && bx2 - bx1 == 0 && bx1 < bw - 1 && hasLeftTee && !hasDiamond) {
|
|
|
|
- hasDiamond = true;
|
|
|
|
- special = Driver.Diamond;
|
|
|
|
- } else {
|
|
|
|
- if (x == bx1 && !hasLeftTee) {
|
|
|
|
- hasLeftTee = true;
|
|
|
|
- posLeftTee = x;
|
|
|
|
- special = Driver.LeftTee;
|
|
|
|
- } else if ((position == 0 && x == bw - 1 || x >= bx2 || bx2 == 0) && !hasRightTee) {
|
|
|
|
- hasRightTee = true;
|
|
|
|
- posRightTee = x;
|
|
|
|
- special = Driver.RightTee;
|
|
|
|
- } else {
|
|
|
|
- special = Driver.HLine;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Driver.AddRune (special);
|
|
|
|
- }
|
|
|
|
- if (!hasLeftTee) {
|
|
|
|
- Move (Bounds.Width -2, row);
|
|
|
|
- Driver.AddRune (Driver.LeftTee);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Driver.AddRune (Driver.RightArrow);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int lastLocation = -1;
|
|
|
|
-
|
|
|
|
- ///<inheritdoc/>
|
|
|
|
- public override bool MouseEvent (MouseEvent me)
|
|
|
|
- {
|
|
|
|
- if (me.Flags != MouseFlags.Button1Pressed && me.Flags != MouseFlags.Button1Clicked &&
|
|
|
|
- !me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition)) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition)) {
|
|
|
|
- lastLocation = -1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int location = vertical ? me.Y : me.X;
|
|
|
|
- int barsize = vertical ? Bounds.Height : Bounds.Width;
|
|
|
|
- int posTopLeftTee = vertical ? posTopTee : posLeftTee;
|
|
|
|
- int posBottomRightTee = vertical ? posBottomTee : posRightTee;
|
|
|
|
-
|
|
|
|
- barsize -= 2;
|
|
|
|
- var pos = Position;
|
|
|
|
- if (location == 0) {
|
|
|
|
- if (pos > 0) {
|
|
|
|
- SetPosition (pos - 1);
|
|
|
|
- }
|
|
|
|
- } else if (location == barsize + 1) {
|
|
|
|
- if (Host.CanScroll (1, out _, vertical)) {
|
|
|
|
- SetPosition (pos + 1);
|
|
|
|
- }
|
|
|
|
- } else if (location > 0 && location < barsize + 1) {
|
|
|
|
- var b1 = pos * barsize / Size;
|
|
|
|
- var b2 = Host.KeepContentAlwaysInViewport ? Math.Min (((pos + barsize) * barsize / Size) + 1, barsize - 1) : (pos + barsize) * barsize / Size;
|
|
|
|
- if (Host.KeepContentAlwaysInViewport && b1 == b2) {
|
|
|
|
- b1 = Math.Max (b1 - 1, 0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (location > b1 && location <= b2 + 1) {
|
|
|
|
- if (me.Flags == MouseFlags.Button1Pressed || me.Flags == MouseFlags.Button1Clicked) {
|
|
|
|
- if (location == 1) {
|
|
|
|
- SetPosition (0);
|
|
|
|
- } else if (location == barsize) {
|
|
|
|
- Host.CanScroll (Size - pos, out int nv, vertical);
|
|
|
|
- if (nv > 0) {
|
|
|
|
- SetPosition (Math.Min (pos + nv, Size));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition)) {
|
|
|
|
- var mb = (b2 - b1) / 2;
|
|
|
|
- var ml = mb + b1 + (mb == 0 ? 1 : 0);
|
|
|
|
- if ((location >= b1 && location <= ml) || (location < lastLocation && lastLocation > -1)) {
|
|
|
|
- lastLocation = location;
|
|
|
|
- var np = b1 * Size / barsize;
|
|
|
|
- SetPosition (np);
|
|
|
|
- } else if (location > lastLocation) {
|
|
|
|
- var np = location * Size / barsize;
|
|
|
|
- Host.CanScroll (np - pos, out int nv, vertical);
|
|
|
|
- if (nv > 0) {
|
|
|
|
- SetPosition (pos + nv);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (location >= b2 + 1 && location > posTopLeftTee && location > b1 && location > posBottomRightTee && posBottomRightTee > 0) {
|
|
|
|
- Host.CanScroll (location, out int nv, vertical);
|
|
|
|
- if (nv > 0) {
|
|
|
|
- SetPosition (Math.Min (pos + nv, Size));
|
|
|
|
- }
|
|
|
|
- } else if (location <= b1) {
|
|
|
|
- SetPosition (Math.Max (pos - barsize - location, 0));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Scrollviews are views that present a window into a virtual space where subviews are added. Similar to the iOS UIScrollView.
|
|
/// Scrollviews are views that present a window into a virtual space where subviews are added. Similar to the iOS UIScrollView.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -483,6 +144,8 @@ namespace Terminal.Gui {
|
|
set {
|
|
set {
|
|
if (keepContentAlwaysInViewport != value) {
|
|
if (keepContentAlwaysInViewport != value) {
|
|
keepContentAlwaysInViewport = value;
|
|
keepContentAlwaysInViewport = value;
|
|
|
|
+ vertical.OtherScrollBarView.KeepContentAlwaysInViewport = value;
|
|
|
|
+ horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value;
|
|
Point p = default;
|
|
Point p = default;
|
|
if (value && -contentOffset.X + Bounds.Width > contentSize.Width) {
|
|
if (value && -contentOffset.X + Bounds.Width > contentSize.Width) {
|
|
p = new Point (contentSize.Width - Bounds.Width + (showVerticalScrollIndicator ? 1 : 0), -contentOffset.Y);
|
|
p = new Point (contentSize.Width - Bounds.Width + (showVerticalScrollIndicator ? 1 : 0), -contentOffset.Y);
|
|
@@ -540,17 +203,21 @@ namespace Terminal.Gui {
|
|
public bool ShowHorizontalScrollIndicator {
|
|
public bool ShowHorizontalScrollIndicator {
|
|
get => showHorizontalScrollIndicator;
|
|
get => showHorizontalScrollIndicator;
|
|
set {
|
|
set {
|
|
- if (value == showHorizontalScrollIndicator)
|
|
|
|
|
|
+ if (value == showHorizontalScrollIndicator) {
|
|
return;
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
showHorizontalScrollIndicator = value;
|
|
showHorizontalScrollIndicator = value;
|
|
SetNeedsLayout ();
|
|
SetNeedsLayout ();
|
|
if (value) {
|
|
if (value) {
|
|
base.Add (horizontal);
|
|
base.Add (horizontal);
|
|
|
|
+ horizontal.OtherScrollBarView = vertical;
|
|
|
|
+ horizontal.OtherScrollBarView.ShowScrollIndicator = value;
|
|
horizontal.MouseEnter += View_MouseEnter;
|
|
horizontal.MouseEnter += View_MouseEnter;
|
|
horizontal.MouseLeave += View_MouseLeave;
|
|
horizontal.MouseLeave += View_MouseLeave;
|
|
} else {
|
|
} else {
|
|
- Remove (horizontal);
|
|
|
|
|
|
+ base.Remove (horizontal);
|
|
|
|
+ horizontal.OtherScrollBarView = null;
|
|
horizontal.MouseEnter -= View_MouseEnter;
|
|
horizontal.MouseEnter -= View_MouseEnter;
|
|
horizontal.MouseLeave -= View_MouseLeave;
|
|
horizontal.MouseLeave -= View_MouseLeave;
|
|
}
|
|
}
|
|
@@ -575,17 +242,21 @@ namespace Terminal.Gui {
|
|
public bool ShowVerticalScrollIndicator {
|
|
public bool ShowVerticalScrollIndicator {
|
|
get => showVerticalScrollIndicator;
|
|
get => showVerticalScrollIndicator;
|
|
set {
|
|
set {
|
|
- if (value == showVerticalScrollIndicator)
|
|
|
|
|
|
+ if (value == showVerticalScrollIndicator) {
|
|
return;
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
showVerticalScrollIndicator = value;
|
|
showVerticalScrollIndicator = value;
|
|
SetNeedsLayout ();
|
|
SetNeedsLayout ();
|
|
if (value) {
|
|
if (value) {
|
|
base.Add (vertical);
|
|
base.Add (vertical);
|
|
|
|
+ vertical.OtherScrollBarView = horizontal;
|
|
|
|
+ vertical.OtherScrollBarView.ShowScrollIndicator = value;
|
|
vertical.MouseEnter += View_MouseEnter;
|
|
vertical.MouseEnter += View_MouseEnter;
|
|
vertical.MouseLeave += View_MouseLeave;
|
|
vertical.MouseLeave += View_MouseLeave;
|
|
} else {
|
|
} else {
|
|
Remove (vertical);
|
|
Remove (vertical);
|
|
|
|
+ vertical.OtherScrollBarView = null;
|
|
vertical.MouseEnter -= View_MouseEnter;
|
|
vertical.MouseEnter -= View_MouseEnter;
|
|
vertical.MouseLeave -= View_MouseLeave;
|
|
vertical.MouseLeave -= View_MouseLeave;
|
|
}
|
|
}
|
|
@@ -739,7 +410,7 @@ namespace Terminal.Gui {
|
|
/// <param name="lines">Number of lines to scroll.</param>
|
|
/// <param name="lines">Number of lines to scroll.</param>
|
|
public bool ScrollDown (int lines)
|
|
public bool ScrollDown (int lines)
|
|
{
|
|
{
|
|
- if (CanScroll (lines, out _, true)) {
|
|
|
|
|
|
+ if (vertical.CanScroll (lines, out _, true)) {
|
|
ContentOffset = new Point (contentOffset.X, contentOffset.Y - lines);
|
|
ContentOffset = new Point (contentOffset.X, contentOffset.Y - lines);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -753,28 +424,13 @@ namespace Terminal.Gui {
|
|
/// <param name="cols">Number of columns to scroll by.</param>
|
|
/// <param name="cols">Number of columns to scroll by.</param>
|
|
public bool ScrollRight (int cols)
|
|
public bool ScrollRight (int cols)
|
|
{
|
|
{
|
|
- if (CanScroll (cols, out _)) {
|
|
|
|
|
|
+ if (horizontal.CanScroll (cols, out _)) {
|
|
ContentOffset = new Point (contentOffset.X - cols, contentOffset.Y);
|
|
ContentOffset = new Point (contentOffset.X - cols, contentOffset.Y);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- internal bool CanScroll (int n, out int max, bool isVertical = false)
|
|
|
|
- {
|
|
|
|
- var size = isVertical ?
|
|
|
|
- (KeepContentAlwaysInViewport ? Bounds.Height + (showHorizontalScrollIndicator ? -2 : -1) : 0) :
|
|
|
|
- (KeepContentAlwaysInViewport ? Bounds.Width + (showVerticalScrollIndicator ? -2 : -1) : 0);
|
|
|
|
- var cSize = isVertical ? -contentSize.Height : -contentSize.Width;
|
|
|
|
- var cOffSet = isVertical ? contentOffset.Y : contentOffset.X;
|
|
|
|
- var newSize = Math.Max (cSize, cOffSet - n);
|
|
|
|
- max = cSize < newSize - size ? n : -cSize + (cOffSet - size) - 1;
|
|
|
|
- if (cSize < newSize - size) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
///<inheritdoc/>
|
|
///<inheritdoc/>
|
|
public override bool ProcessKey (KeyEvent kb)
|
|
public override bool ProcessKey (KeyEvent kb)
|
|
{
|
|
{
|