diff --git a/Terminal.Gui/View/ViewContent.cs b/Terminal.Gui/View/ViewContent.cs
index f3516fb58..412dbf22f 100644
--- a/Terminal.Gui/View/ViewContent.cs
+++ b/Terminal.Gui/View/ViewContent.cs
@@ -123,16 +123,64 @@ public partial class View
internal Size? _contentSize;
///
- /// Gets or sets the size of the View's content. If , the value will be the same as the size of ,
- /// and Viewport.Location will always be 0, 0.
+ /// Sets the size of the View's content.
///
///
///
- /// If a size is provided, describes the portion of the content currently visible
+ /// By default, the content size is set to .
+ ///
+ ///
+ ///
+ ///
+ /// If , and the View has no visible subviews, will track the size of .
+ ///
+ ///
+ /// If , and the View has visible subviews, will track the maximum position plus size of any
+ /// visible Subviews
+ /// and Viewport.Location will track the minimum position and size of any visible Subviews.
+ ///
+ ///
+ /// If not , is set to the passed value and describes the portion of the content currently visible
+ /// to the user. This enables virtual scrolling.
+ ///
+ ///
+ /// If not , is set to the passed value and the behavior of will be to use the ContentSize
+ /// to determine the size of the view.
+ ///
+ ///
+ /// Negative sizes are not supported.
+ ///
+ ///
+ public void SetContentSize (Size? contentSize)
+ {
+ if (contentSize?.Width < 0 || contentSize?.Height < 0)
+ {
+ throw new ArgumentException (@"ContentSize cannot be negative.", nameof (contentSize));
+ }
+
+ if (contentSize == _contentSize)
+ {
+ return;
+ }
+
+ _contentSize = contentSize;
+ OnContentSizeChanged (new (_contentSize));
+ }
+
+ ///
+ /// Gets or sets the size of the View's content.
+ ///
+ ///
+ ///
+ /// If set to , the value will be the same as the size of ,
+ /// and Viewport.Location will always be 0, 0.
+ ///
+ ///
+ /// If explicitly set, describes the portion of the content currently visible
/// to the view. This enables virtual scrolling.
///
///
- /// If a size is provided, the behavior of will be to use the ContentSize
+ /// If explicitly set, the behavior of will be to use the ContentSize
/// to determine the size of the view.
///
///
@@ -142,21 +190,21 @@ public partial class View
public Size? ContentSize
{
get => _contentSize ?? Viewport.Size;
- set
- {
- if (value?.Width < 0 || value?.Height < 0)
- {
- throw new ArgumentException (@"ContentSize cannot be negative.", nameof (value));
- }
+ //set
+ //{
+ // if (value?.Width < 0 || value?.Height < 0)
+ // {
+ // throw new ArgumentException (@"ContentSize cannot be negative.", nameof (value));
+ // }
- if (value == _contentSize)
- {
- return;
- }
+ // if (value == _contentSize)
+ // {
+ // return;
+ // }
- _contentSize = value;
- OnContentSizeChanged (new (_contentSize));
- }
+ // _contentSize = value;
+ // OnContentSizeChanged (new (_contentSize));
+ //}
}
///
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index f390552e3..725fe6bd8 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -264,7 +264,7 @@ public class ListView : View
}
_source = value;
- ContentSize = new Size (_source?.Length ?? Viewport.Width, _source?.Count ?? Viewport.Width);
+ SetContentSize (new Size (_source?.Length ?? Viewport.Width, _source?.Count ?? Viewport.Width));
if (IsInitialized)
{
Viewport = Viewport with { Y = 0 };
@@ -336,7 +336,7 @@ public class ListView : View
}
else if (Viewport.Height > 0 && _selected >= Viewport.Y + Viewport.Height)
{
- Viewport = Viewport with { Y = _selected - Viewport.Height + 1};
+ Viewport = Viewport with { Y = _selected - Viewport.Height + 1 };
}
LayoutStarted -= ListView_LayoutStarted;
@@ -408,7 +408,7 @@ public class ListView : View
if (me.Flags == MouseFlags.WheeledLeft)
{
- ScrollHorizontal(-1);
+ ScrollHorizontal (-1);
return true;
}
diff --git a/Terminal.Gui/Views/ProgressBar.cs b/Terminal.Gui/Views/ProgressBar.cs
index 01c43c3ac..7a0db915c 100644
--- a/Terminal.Gui/Views/ProgressBar.cs
+++ b/Terminal.Gui/Views/ProgressBar.cs
@@ -61,7 +61,7 @@ public class ProgressBar : View
set
{
_bidirectionalMarquee = value;
- ContentSize = Viewport.Size with { Height = 1 };
+ SetContentSize (Viewport.Size with { Height = 1 });
}
}
@@ -74,12 +74,22 @@ public class ProgressBar : View
{
_fraction = Math.Min (value, 1);
_isActivity = false;
- ContentSize = Viewport.Size with { Height = 1 };
+ SetContentSize (Viewport.Size with { Height = 1 });
}
}
+ private ProgressBarFormat _progressBarFormat;
+
/// Specifies the format that a uses to indicate the visual presentation.
- public ProgressBarFormat ProgressBarFormat { get; set; }
+ public ProgressBarFormat ProgressBarFormat
+ {
+ get => _progressBarFormat;
+ set
+ {
+ _progressBarFormat = value;
+ SetContentSize (Viewport.Size with { Height = 1 });
+ }
+ }
/// Gets/Sets the progress bar style based on the
public ProgressBarStyle ProgressBarStyle
@@ -109,7 +119,7 @@ public class ProgressBar : View
break;
}
- ContentSize = Viewport.Size with { Height = 1 };
+ SetContentSize (Viewport.Size with { Height = 1 });
}
}
@@ -120,7 +130,7 @@ public class ProgressBar : View
set
{
_segmentCharacter = value;
- ContentSize = Viewport.Size with { Height = 1 };
+ SetContentSize (Viewport.Size with { Height = 1 });
}
}
@@ -181,7 +191,7 @@ public class ProgressBar : View
if (ProgressBarFormat != ProgressBarFormat.Simple && !_isActivity)
{
- var tf = new TextFormatter { Alignment = TextAlignment.Centered, Text = Text, AutoSize = true};
+ var tf = new TextFormatter { Alignment = TextAlignment.Centered, Text = Text, AutoSize = true };
var attr = new Attribute (ColorScheme.HotNormal.Foreground, ColorScheme.HotNormal.Background);
if (_fraction > .5)
@@ -269,7 +279,7 @@ public class ProgressBar : View
private void ProgressBar_Initialized (object sender, EventArgs e)
{
- ContentSize = new (0, 1);
+ SetContentSize (Viewport.Size with { Height = 1 });
ColorScheme = new ColorScheme (ColorScheme ?? SuperView?.ColorScheme ?? Colors.ColorSchemes ["Base"])
{
diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs
index 84a8a50c3..3a28fd5c6 100644
--- a/Terminal.Gui/Views/Slider.cs
+++ b/Terminal.Gui/Views/Slider.cs
@@ -624,11 +624,11 @@ public class Slider : View
if (_config._sliderOrientation == Orientation.Horizontal)
{
- ContentSize = new (int.Min (svWidth, CalcBestLength ()), int.Min (svHeight, CalcThickness ()));
+ SetContentSize (new (int.Min (svWidth, CalcBestLength ()), int.Min (svHeight, CalcThickness ())));
}
else
{
- ContentSize = new (int.Min (svWidth, CalcThickness ()), int.Min (svHeight, CalcBestLength ()));
+ SetContentSize (new (int.Min (svWidth, CalcThickness ()), int.Min (svHeight, CalcBestLength ())));
}
return;
diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs
index edc6d1b5b..030e0a38c 100644
--- a/UICatalog/Scenarios/ASCIICustomButton.cs
+++ b/UICatalog/Scenarios/ASCIICustomButton.cs
@@ -235,7 +235,7 @@ public class ASCIICustomButtonTest : Scenario
pages++;
}
- _scrollView.ContentSize = new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT);
+ _scrollView.SetContentSize (new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT));
if (_smallerWindow)
{
diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs
index 8a656bda8..0a32490de 100644
--- a/UICatalog/Scenarios/CharacterMap.cs
+++ b/UICatalog/Scenarios/CharacterMap.cs
@@ -328,7 +328,7 @@ internal class CharMap : View
CanFocus = true;
CursorVisibility = CursorVisibility.Default;
- ContentSize = new (RowWidth, (MaxCodePoint / 16 + 2) * _rowHeight);
+ SetContentSize (new (RowWidth, (MaxCodePoint / 16 + 2) * _rowHeight));
AddCommand (
Command.ScrollUp,
diff --git a/UICatalog/Scenarios/Clipping.cs b/UICatalog/Scenarios/Clipping.cs
index 0aba6ece9..43d1d80ca 100644
--- a/UICatalog/Scenarios/Clipping.cs
+++ b/UICatalog/Scenarios/Clipping.cs
@@ -29,7 +29,7 @@ public class Clipping : Scenario
var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
- scrollView.ContentSize = new (200, 100);
+ scrollView.SetContentSize (new (200, 100));
//ContentOffset = Point.Empty,
scrollView.AutoHideScrollBars = true;
diff --git a/UICatalog/Scenarios/ContentScrolling.cs b/UICatalog/Scenarios/ContentScrolling.cs
index 8b7e9d9d8..fd2687e01 100644
--- a/UICatalog/Scenarios/ContentScrolling.cs
+++ b/UICatalog/Scenarios/ContentScrolling.cs
@@ -27,7 +27,7 @@ public class ContentScrolling : Scenario
BorderStyle = LineStyle.Rounded;
Arrangement = ViewArrangement.Fixed;
- ContentSize = new (60, 40);
+ SetContentSize (new (60, 40));
ViewportSettings |= ViewportSettings.ClearContentOnly;
ViewportSettings |= ViewportSettings.ClipContentOnly;
@@ -242,7 +242,7 @@ public class ContentScrolling : Scenario
return;
}
- view.ContentSize = view.ContentSize.GetValueOrDefault () with { Width = e.NewValue };
+ view.SetContentSize (view.ContentSize.GetValueOrDefault () with { Width = e.NewValue });
}
var labelComma = new Label
@@ -270,7 +270,7 @@ public class ContentScrolling : Scenario
return;
}
- view.ContentSize = view.ContentSize.GetValueOrDefault () with { Height = e.NewValue };
+ view.SetContentSize (view.ContentSize.GetValueOrDefault () with { Height = e.NewValue });
}
var cbClearOnlyVisible = new CheckBox
diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs
index 13b091b7a..daf9ee60e 100644
--- a/UICatalog/Scenarios/Scrolling.cs
+++ b/UICatalog/Scenarios/Scrolling.cs
@@ -39,12 +39,12 @@ public class Scrolling : Scenario
Width = 60,
Height = 20,
ColorScheme = Colors.ColorSchemes ["TopLevel"],
- ContentSize = new (120, 40),
//ContentOffset = Point.Empty,
ShowVerticalScrollIndicator = true,
ShowHorizontalScrollIndicator = true
};
+ scrollView.SetContentSize (new (120, 40));
scrollView.Padding.Thickness = new (1);
label.Text = $"{scrollView}\nContentSize: {scrollView.ContentSize}\nContentOffset: {scrollView.ContentOffset}";
diff --git a/UnitTests/Application/MouseTests.cs b/UnitTests/Application/MouseTests.cs
index 447761550..458689008 100644
--- a/UnitTests/Application/MouseTests.cs
+++ b/UnitTests/Application/MouseTests.cs
@@ -235,7 +235,8 @@ public class MouseTests
public void MouseGrabView_WithNullMouseEventView ()
{
var tf = new TextField { Width = 10 };
- var sv = new ScrollView { Width = Dim.Fill (), Height = Dim.Fill (), ContentSize = new (100, 100) };
+ var sv = new ScrollView { Width = Dim.Fill (), Height = Dim.Fill () };
+ sv.SetContentSize (new (100, 100));
sv.Add (tf);
var top = new Toplevel ();
@@ -252,7 +253,7 @@ public class MouseTests
Assert.True (tf.HasFocus);
Assert.Null (Application.MouseGrabView);
- Application.OnMouseEvent (new() { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
+ Application.OnMouseEvent (new () { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
Assert.Equal (sv, Application.MouseGrabView);
@@ -266,15 +267,15 @@ public class MouseTests
// another toplevel (Dialog) was opened
Assert.Null (Application.MouseGrabView);
- Application.OnMouseEvent (new() { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
+ Application.OnMouseEvent (new () { Position = new (5, 5), Flags = MouseFlags.ReportMousePosition });
Assert.Null (Application.MouseGrabView);
- Application.OnMouseEvent (new() { Position = new (40, 12), Flags = MouseFlags.ReportMousePosition });
+ Application.OnMouseEvent (new () { Position = new (40, 12), Flags = MouseFlags.ReportMousePosition });
Assert.Null (Application.MouseGrabView);
- Application.OnMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Pressed });
+ Application.OnMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Pressed });
Assert.Null (Application.MouseGrabView);
diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs
index 6d9c4b0af..48208bb8e 100644
--- a/UnitTests/View/DrawTests.cs
+++ b/UnitTests/View/DrawTests.cs
@@ -924,9 +924,9 @@ public class DrawTests (ITestOutputHelper _output)
{
Width = Dim.Fill (),
Height = Dim.Fill (),
- ContentSize = new Size (10, 10),
ViewportSettings = ViewportSettings.ClipContentOnly
};
+ view.SetContentSize (new Size (10, 10));
view.Border.Thickness = new Thickness (1);
view.BeginInit ();
view.EndInit ();
@@ -957,8 +957,8 @@ public class DrawTests (ITestOutputHelper _output)
{
Width = Dim.Fill (),
Height = Dim.Fill (),
- ContentSize = new Size (10, 10),
};
+ view.SetContentSize (new Size (10, 10));
view.Border.Thickness = new Thickness (1);
view.BeginInit ();
view.EndInit ();
diff --git a/UnitTests/View/FindDeepestViewTests.cs b/UnitTests/View/FindDeepestViewTests.cs
index 58d59e8d4..c6ea6fa06 100644
--- a/UnitTests/View/FindDeepestViewTests.cs
+++ b/UnitTests/View/FindDeepestViewTests.cs
@@ -470,7 +470,7 @@ public class FindDeepestViewTests ()
subview.Padding.Thickness = new (1);
// Scroll the subview
- subview.ContentSize = new Size (10, 10);
+ subview.SetContentSize (new (10, 10));
subview.Viewport = subview.Viewport with { Location = new (1, 1) };
// This subview will be at the bottom-right-corner of subview
diff --git a/UnitTests/View/Layout/Dim.AutoTests.cs b/UnitTests/View/Layout/Dim.AutoTests.cs
index f994e067f..3c9b58125 100644
--- a/UnitTests/View/Layout/Dim.AutoTests.cs
+++ b/UnitTests/View/Layout/Dim.AutoTests.cs
@@ -882,7 +882,9 @@ public class DimAutoTests (ITestOutputHelper output)
[Fact]
public void DimAutoStyle_Content_UsesContentSize_WhenSet ()
{
- var view = new View () { ContentSize = new Size (10, 5) };
+ var view = new View ();
+ view.SetContentSize (new (10, 5));
+
var dim = Dim.Auto (Dim.DimAutoStyle.Content);
int calculatedWidth = dim.Calculate (0, 100, view, Dim.Dimension.Width);
@@ -1220,7 +1222,7 @@ public class DimAutoTests (ITestOutputHelper output)
public void DimAutoStyle_Content_UsesContentSize_If_No_Subviews ()
{
DimAutoTestView view = new (Auto (DimAutoStyle.Content), Auto (DimAutoStyle.Content));
- view.ContentSize = new (5, 5);
+ view.SetContentSize (new (5, 5));
view.SetRelativeLayout (new (10, 10));
Assert.Equal (new (5, 5), view.Frame.Size);
diff --git a/UnitTests/View/Layout/LayoutTests.cs b/UnitTests/View/Layout/LayoutTests.cs
index 2f00865a0..d965e90e9 100644
--- a/UnitTests/View/Layout/LayoutTests.cs
+++ b/UnitTests/View/Layout/LayoutTests.cs
@@ -122,8 +122,8 @@ public class LayoutTests (ITestOutputHelper output)
{
Width = 5,
Height = 5,
- ContentSize = new (10, 10)
};
+ superView.SetContentSize (new (10, 10));
var view = new View ()
{
X = Pos.Center ()
diff --git a/UnitTests/View/Layout/ScreenToTests.cs b/UnitTests/View/Layout/ScreenToTests.cs
index c6d75e806..43b60ad99 100644
--- a/UnitTests/View/Layout/ScreenToTests.cs
+++ b/UnitTests/View/Layout/ScreenToTests.cs
@@ -108,7 +108,7 @@ public class ScreenToTests
BorderStyle = LineStyle.Single,
};
var view = new View { X = viewX, Y = viewY, Width = 5, Height = 5 };
- view.ContentSize = new (6, 6);
+ view.SetContentSize (new (6, 6));
super.Add (view);
view.Viewport = new (1, 1, 5, 5);
@@ -164,7 +164,7 @@ public class ScreenToTests
X = viewX, Y = viewY, Width = 5, Height = 5,
BorderStyle = LineStyle.Single,
};
- view.ContentSize = new (10, 10);
+ view.SetContentSize (new (10, 10));
super.Add (view);
view.Viewport = view.Viewport with { Location = new (1, 1) };
diff --git a/UnitTests/View/Layout/ToScreenTests.cs b/UnitTests/View/Layout/ToScreenTests.cs
index d6314a38b..2524b0727 100644
--- a/UnitTests/View/Layout/ToScreenTests.cs
+++ b/UnitTests/View/Layout/ToScreenTests.cs
@@ -334,9 +334,9 @@ public class ToScreenTests (ITestOutputHelper output)
X = 1,
Y = 1,
Width = 10,
- Height = 10,
- ContentSize = new (20, 20)
+ Height = 10
};
+ view.SetContentSize (new (20, 20));
Point testPoint = new (0, 0);
Assert.Equal (new Point (1, 1), view.ContentToScreen (testPoint));
@@ -362,7 +362,7 @@ public class ToScreenTests (ITestOutputHelper output)
var view = new View ();
view.Frame = frame;
- view.ContentSize = new (20, 20);
+ view.SetContentSize (new (20, 20));
view.BorderStyle = LineStyle.Single;
// Act
@@ -403,7 +403,7 @@ public class ToScreenTests (ITestOutputHelper output)
var view = new View ();
view.Frame = frame;
- view.ContentSize = new (20, 20);
+ view.SetContentSize (new (20, 20));
superView.Add (view);
superView.LayoutSubviews ();
@@ -608,7 +608,7 @@ public class ToScreenTests (ITestOutputHelper output)
// var view = new View ();
// view.Frame = frame;
- // view.ContentSize = new (11, 11);
+ // view.SetContentSize (new (11, 11));
// view.Content = view.Content with { Location = new (1, 1) };
// superView.Add (view);
@@ -928,7 +928,7 @@ public class ToScreenTests (ITestOutputHelper output)
var view = new View ();
view.Frame = frame;
- view.ContentSize = new (11, 11);
+ view.SetContentSize (new (11, 11));
view.Viewport = view.Viewport with { Location = new (1, 1) };
superView.Add (view);
diff --git a/UnitTests/View/Layout/ViewportTests.cs b/UnitTests/View/Layout/ViewportTests.cs
index a4fa24c26..d9a379e2f 100644
--- a/UnitTests/View/Layout/ViewportTests.cs
+++ b/UnitTests/View/Layout/ViewportTests.cs
@@ -279,7 +279,7 @@ public class ViewportTests (ITestOutputHelper output)
{
// Arrange
var view = new View ();
- view.ContentSize = new Size (100, 100);
+ view.SetContentSize (new (100, 100));
var newViewport = new Rectangle (0, 0, 200, 200);
view.ViewportSettings = ViewportSettings.AllowLocationGreaterThanContentSize;
diff --git a/UnitTests/Views/ProgressBarTests.cs b/UnitTests/Views/ProgressBarTests.cs
index 64aee8b3c..4ff1d23a5 100644
--- a/UnitTests/Views/ProgressBarTests.cs
+++ b/UnitTests/Views/ProgressBarTests.cs
@@ -20,7 +20,7 @@ public class ProgressBarTests
new Attribute (pb.ColorScheme.HotNormal.Foreground, pb.ColorScheme.HotNormal.Background)
);
Assert.Equal (Colors.ColorSchemes ["Base"].Normal, pb.ColorScheme.Normal);
- Assert.Equal (1, pb.Height);
+ Assert.Equal (1, pb.Frame.Height);
Assert.Equal (ProgressBarStyle.Blocks, pb.ProgressBarStyle);
Assert.Equal (ProgressBarFormat.Simple, pb.ProgressBarFormat);
Assert.Equal (CM.Glyphs.BlocksMeterSegment, pb.SegmentCharacter);
@@ -111,17 +111,17 @@ public class ProgressBarTests
pb1.ProgressBarFormat = ProgressBarFormat.Simple;
Assert.Equal (ProgressBarFormat.Simple, pb1.ProgressBarFormat);
- Assert.Equal (1, pb1.Height);
+ Assert.Equal (1, pb1.Frame.Height);
pb2.ProgressBarFormat = ProgressBarFormat.Simple;
Assert.Equal (ProgressBarFormat.Simple, pb2.ProgressBarFormat);
- Assert.Equal (1, pb2.Height);
+ Assert.Equal (1, pb2.Frame.Height);
pb1.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb1.ProgressBarFormat);
- Assert.Equal (1, pb1.Height);
+ Assert.Equal (1, pb1.Frame.Height);
pb2.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb2.ProgressBarFormat);
- Assert.Equal (1, pb2.Height);
+ Assert.Equal (1, pb2.Frame.Height);
}
[Fact]
@@ -131,10 +131,10 @@ public class ProgressBarTests
var pb = new ProgressBar ();
pb.ProgressBarFormat = ProgressBarFormat.Simple;
- Assert.Equal (1, pb.Height);
+ Assert.Equal (1, pb.Frame.Height);
pb.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
- Assert.Equal (1, pb.Height);
+ Assert.Equal (1, pb.Frame.Height);
}
[Fact]
diff --git a/UnitTests/Views/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs
index f1563e696..e0f131dcd 100644
--- a/UnitTests/Views/ScrollViewTests.cs
+++ b/UnitTests/Views/ScrollViewTests.cs
@@ -11,7 +11,8 @@ public class ScrollViewTests
[Fact]
public void Adding_Views ()
{
- var sv = new ScrollView { Width = 20, Height = 10, ContentSize = new (30, 20) };
+ var sv = new ScrollView { Width = 20, Height = 10 };
+ sv.SetContentSize (new (30, 20));
sv.Add (
new View { Width = 10, Height = 5 },
@@ -184,9 +185,9 @@ public class ScrollViewTests
Y = 3,
Width = 10,
Height = 10,
- ContentSize = new (23, 23),
KeepContentAlwaysInViewport = false
};
+ sv.SetContentSize (new (23, 23));
var bottomLabel = new Label { X = 15, Y = 15, Text = "At 15,15" };
var top = new Toplevel ();
top.Add (topLabel, sv, bottomLabel);
@@ -375,9 +376,9 @@ public class ScrollViewTests
Y = 1,
Width = 10,
Height = 5,
- ContentSize = size,
ColorScheme = new ColorScheme { Normal = new Attribute (Color.Red, Color.Green) }
};
+ sv.SetContentSize (size);
string text = null;
for (var i = 0; i < size.Height; i++)
@@ -444,15 +445,17 @@ public class ScrollViewTests
{
var sv = new ScrollView
{
- Width = 10, Height = 10, ContentSize = new (50, 50), ContentOffset = new (25, 25)
+ Width = 10, Height = 10,
};
+ sv.SetContentSize (new (50, 50));
+ sv.ContentOffset = new (25, 25);
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
- Assert.Equal(new(-25,-25),sv.ContentOffset);
- Assert.Equal(new(50,50),sv.ContentSize);
+ Assert.Equal (new (-25, -25), sv.ContentOffset);
+ Assert.Equal (new (50, 50), sv.ContentSize);
Assert.True (sv.AutoHideScrollBars);
Assert.True (sv.ShowHorizontalScrollIndicator);
Assert.True (sv.ShowVerticalScrollIndicator);
@@ -478,7 +481,8 @@ public class ScrollViewTests
[AutoInitShutdown]
public void ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
{
- var sv = new ScrollView { Width = 10, Height = 10, ContentSize = new (50, 50) };
+ var sv = new ScrollView { Width = 10, Height = 10, };
+ sv.SetContentSize (new (50, 50));
var top = new Toplevel ();
top.Add (sv);
@@ -539,10 +543,10 @@ public class ScrollViewTests
Y = 1,
Width = 15,
Height = 10,
- ContentSize = size,
ShowHorizontalScrollIndicator = true,
ShowVerticalScrollIndicator = true
};
+ scrollView.SetContentSize (size);
scrollView.Add (view);
var win = new Window { X = 1, Y = 1, Width = 20, Height = 14 };
win.Add (scrollView);
@@ -866,8 +870,8 @@ public class ScrollViewTests
Y = 3,
Width = 10,
Height = 10,
- ContentSize = new (50, 50)
};
+ sv.SetContentSize (new (50, 50));
for (var i = 0; i < 8; i++)
{
@@ -916,7 +920,8 @@ public class ScrollViewTests
[Fact]
public void KeyBindings_Command ()
{
- var sv = new ScrollView { Width = 20, Height = 10, ContentSize = new (40, 20) };
+ var sv = new ScrollView { Width = 20, Height = 10, };
+ sv.SetContentSize (new (40, 20));
sv.Add (
new View { Width = 20, Height = 5 },
@@ -1050,7 +1055,8 @@ public class ScrollViewTests
[AutoInitShutdown]
public void Remove_Added_View_Is_Allowed ()
{
- var sv = new ScrollView { Width = 20, Height = 20, ContentSize = new (100, 100) };
+ var sv = new ScrollView { Width = 20, Height = 20, };
+ sv.SetContentSize (new (100, 100));
sv.Add (
new View { Width = Dim.Fill (), Height = Dim.Fill (50), Id = "View1" },
diff --git a/UnitTests/Views/SliderTests.cs b/UnitTests/Views/SliderTests.cs
index 4420eea97..5bbe631e1 100644
--- a/UnitTests/Views/SliderTests.cs
+++ b/UnitTests/Views/SliderTests.cs
@@ -514,7 +514,7 @@ public class SliderTests
Assert.Equal (new (6, 2), expectedSize);
- view.ContentSize = new (1, 1);
+ view.SetContentSize (new (1, 1));
view.LayoutSubviews ();
slider.SetRelativeLayout (view.Viewport.Size);
@@ -548,7 +548,7 @@ public class SliderTests
Assert.Equal (new (6, 10), expectedSize);
- view.ContentSize = new (1, 1);
+ view.SetContentSize (new (1, 1));
view.LayoutSubviews ();
slider.SetRelativeLayout (view.Viewport.Size);
@@ -582,7 +582,7 @@ public class SliderTests
Assert.Equal (new (10, 2), expectedSize);
- view.ContentSize = new (1, 1);
+ view.SetContentSize (new (1, 1));
view.LayoutSubviews ();
slider.SetRelativeLayout (view.Viewport.Size);
diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs
index 6e31fb55b..e6e66586a 100644
--- a/UnitTests/Views/ToplevelTests.cs
+++ b/UnitTests/Views/ToplevelTests.cs
@@ -1320,8 +1320,8 @@ public class ToplevelTests
Y = 3,
Width = 40,
Height = 16,
- ContentSize = new (200, 100)
};
+ scrollView.SetContentSize (new (200, 100));
var win = new Window { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), Arrangement = ViewArrangement.Movable };
scrollView.Add (win);
Toplevel top = new ();