|
@@ -88,10 +88,10 @@ public class ScrollView : View
|
|
|
AddCommand (Command.PageDown, () => ScrollDown (Viewport.Height));
|
|
|
AddCommand (Command.PageLeft, () => ScrollLeft (Viewport.Width));
|
|
|
AddCommand (Command.PageRight, () => ScrollRight (Viewport.Width));
|
|
|
- AddCommand (Command.TopHome, () => ScrollUp (ContentSize.Height));
|
|
|
- AddCommand (Command.BottomEnd, () => ScrollDown (ContentSize.Height));
|
|
|
- AddCommand (Command.LeftHome, () => ScrollLeft (ContentSize.Width));
|
|
|
- AddCommand (Command.RightEnd, () => ScrollRight (ContentSize.Width));
|
|
|
+ AddCommand (Command.TopHome, () => ScrollUp (ContentSize.Value.Height));
|
|
|
+ AddCommand (Command.BottomEnd, () => ScrollDown (ContentSize.Value.Height));
|
|
|
+ AddCommand (Command.LeftHome, () => ScrollLeft (ContentSize.Value.Width));
|
|
|
+ AddCommand (Command.RightEnd, () => ScrollRight (ContentSize.Value.Width));
|
|
|
|
|
|
// Default keybindings for this view
|
|
|
KeyBindings.Add (Key.CursorUp, Command.ScrollUp);
|
|
@@ -127,7 +127,7 @@ public class ScrollView : View
|
|
|
}
|
|
|
|
|
|
SetContentOffset (_contentOffset);
|
|
|
- _contentView.Frame = new Rectangle (ContentOffset, ContentSize);
|
|
|
+ _contentView.Frame = new Rectangle (ContentOffset, ContentSize.GetValueOrDefault ());
|
|
|
|
|
|
// PERF: How about calls to Point.Offset instead?
|
|
|
_vertical.ChangedPosition += delegate { ContentOffset = new Point (ContentOffset.X, _vertical.Position); };
|
|
@@ -138,9 +138,13 @@ public class ScrollView : View
|
|
|
|
|
|
private void ScrollViewContentSizeChanged (object sender, SizeChangedEventArgs e)
|
|
|
{
|
|
|
- _contentView.Frame = new Rectangle (ContentOffset, e.Size with {Width = e.Size.Width-1, Height = e.Size.Height-1});
|
|
|
- _vertical.Size = e.Size.Height;
|
|
|
- _horizontal.Size = e.Size.Width;
|
|
|
+ if (e.Size is null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _contentView.Frame = new Rectangle (ContentOffset, e.Size.Value with { Width = e.Size.Value.Width - 1, Height = e.Size.Value.Height - 1 });
|
|
|
+ _vertical.Size = e.Size.Value.Height;
|
|
|
+ _horizontal.Size = e.Size.Value.Width;
|
|
|
}
|
|
|
|
|
|
private void Application_UnGrabbedMouse (object sender, ViewEventArgs e)
|
|
@@ -240,26 +244,26 @@ public class ScrollView : View
|
|
|
_horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value;
|
|
|
Point p = default;
|
|
|
|
|
|
- if (value && -_contentOffset.X + Viewport.Width > ContentSize.Width)
|
|
|
+ if (value && -_contentOffset.X + Viewport.Width > ContentSize.GetValueOrDefault ().Width)
|
|
|
{
|
|
|
p = new Point (
|
|
|
- ContentSize.Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
|
|
|
+ ContentSize.GetValueOrDefault ().Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
|
|
|
-_contentOffset.Y
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- if (value && -_contentOffset.Y + Viewport.Height > ContentSize.Height)
|
|
|
+ if (value && -_contentOffset.Y + Viewport.Height > ContentSize.GetValueOrDefault ().Height)
|
|
|
{
|
|
|
if (p == default (Point))
|
|
|
{
|
|
|
p = new Point (
|
|
|
-_contentOffset.X,
|
|
|
- ContentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
|
|
|
+ ContentSize.GetValueOrDefault ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
|
|
|
);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- p.Y = ContentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0);
|
|
|
+ p.Y = ContentSize.GetValueOrDefault ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -410,7 +414,7 @@ public class ScrollView : View
|
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
- protected internal override bool OnMouseEvent (MouseEvent me)
|
|
|
+ protected internal override bool OnMouseEvent (MouseEvent me)
|
|
|
{
|
|
|
if (!Enabled)
|
|
|
{
|
|
@@ -447,7 +451,7 @@ public class ScrollView : View
|
|
|
Application.UngrabMouse ();
|
|
|
}
|
|
|
|
|
|
- return base.OnMouseEvent(me);
|
|
|
+ return base.OnMouseEvent (me);
|
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
@@ -615,7 +619,7 @@ public class ScrollView : View
|
|
|
{
|
|
|
// INTENT: Unclear intent. How about a call to Offset?
|
|
|
_contentOffset = new Point (-Math.Abs (offset.X), -Math.Abs (offset.Y));
|
|
|
- _contentView.Frame = new Rectangle (_contentOffset, ContentSize);
|
|
|
+ _contentView.Frame = new Rectangle (_contentOffset, ContentSize.GetValueOrDefault ());
|
|
|
int p = Math.Max (0, -_contentOffset.Y);
|
|
|
|
|
|
if (_vertical.Position != p)
|
|
@@ -646,7 +650,7 @@ public class ScrollView : View
|
|
|
bool v = false, h = false;
|
|
|
var p = false;
|
|
|
|
|
|
- if (Viewport.Height == 0 || Viewport.Height > ContentSize.Height)
|
|
|
+ if (ContentSize is { } && (Viewport.Height == 0 || Viewport.Height > ContentSize.Value.Height))
|
|
|
{
|
|
|
if (ShowVerticalScrollIndicator)
|
|
|
{
|
|
@@ -655,7 +659,7 @@ public class ScrollView : View
|
|
|
|
|
|
v = false;
|
|
|
}
|
|
|
- else if (Viewport.Height > 0 && Viewport.Height == ContentSize.Height)
|
|
|
+ else if (ContentSize is { } && Viewport.Height > 0 && Viewport.Height == ContentSize.Value.Height)
|
|
|
{
|
|
|
p = true;
|
|
|
}
|
|
@@ -669,7 +673,7 @@ public class ScrollView : View
|
|
|
v = true;
|
|
|
}
|
|
|
|
|
|
- if (Viewport.Width == 0 || Viewport.Width > ContentSize.Width)
|
|
|
+ if (ContentSize is { } && (Viewport.Width == 0 || Viewport.Width > ContentSize.Value.Width))
|
|
|
{
|
|
|
if (ShowHorizontalScrollIndicator)
|
|
|
{
|
|
@@ -678,7 +682,7 @@ public class ScrollView : View
|
|
|
|
|
|
h = false;
|
|
|
}
|
|
|
- else if (Viewport.Width > 0 && Viewport.Width == ContentSize.Width && p)
|
|
|
+ else if (ContentSize is { } && Viewport.Width > 0 && Viewport.Width == ContentSize.Value.Width && p)
|
|
|
{
|
|
|
if (ShowHorizontalScrollIndicator)
|
|
|
{
|