diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs
index d825fb872..95689655e 100644
--- a/Terminal.Gui/Application.cs
+++ b/Terminal.Gui/Application.cs
@@ -526,11 +526,8 @@ public static partial class Application
MoveCurrent (Current);
}
- //if (Toplevel.LayoutStyle == LayoutStyle.Computed) {
toplevel.SetRelativeLayout (Driver.Screen.Size);
- //}
-
// BUGBUG: This call is likely not needed.
toplevel.LayoutSubviews ();
toplevel.PositionToplevels ();
diff --git a/Terminal.Gui/View/Layout/Dim.cs b/Terminal.Gui/View/Layout/Dim.cs
index cc31d41b1..411b0fded 100644
--- a/Terminal.Gui/View/Layout/Dim.cs
+++ b/Terminal.Gui/View/Layout/Dim.cs
@@ -7,7 +7,7 @@ namespace Terminal.Gui;
///
/// A Dim object describes the dimensions of a . Dim is the type of the
/// and properties of . Dim objects enable
-/// Computed Layout (see ) to automatically manage the dimensions of a view.
+/// automatic management of the dimensions of a view.
///
///
/// Integer values are implicitly convertible to an absolute . These objects are created using
diff --git a/Terminal.Gui/View/Layout/LayoutStyle.cs b/Terminal.Gui/View/Layout/LayoutStyle.cs
deleted file mode 100644
index 81883bfcc..000000000
--- a/Terminal.Gui/View/Layout/LayoutStyle.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using Terminal.Gui.Analyzers.Internal.Attributes;
-
-namespace Terminal.Gui;
-
-///
-/// Indicates the LayoutStyle for the .
-///
-/// If Absolute, the , , , and
-/// objects are all absolute values and are not relative. The position and size of the
-/// view is described by .
-///
-///
-/// If Computed, one or more of the , , , or
-/// objects are relative to the and are computed at layout
-/// time.
-///
-///
-[GenerateEnumExtensionMethods]
-public enum LayoutStyle
-{
- ///
- /// Indicates the , , , and
- /// objects are all absolute values and are not relative. The position and size of the view
- /// is described by .
- ///
- Absolute,
-
- ///
- /// Indicates one or more of the , , , or
- ///
- /// objects are relative to the and are computed at layout time. The position and size of
- /// the
- /// view
- /// will be computed based on these objects at layout time. will provide the absolute computed
- /// values.
- ///
- Computed
-}
\ No newline at end of file
diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs
index 94348fc75..020fa7211 100644
--- a/Terminal.Gui/View/Layout/ViewLayout.cs
+++ b/Terminal.Gui/View/Layout/ViewLayout.cs
@@ -20,7 +20,6 @@ public partial class View
///
/// Setting Frame will set , , , and to the
/// values of the corresponding properties of the parameter.
- /// This causes to be .
///
///
/// Altering the Frame will eventually (when the view hierarchy is next laid out via see
@@ -41,8 +40,7 @@ public partial class View
SetFrame (value with { Width = Math.Max (value.Width, 0), Height = Math.Max (value.Height, 0) });
- // If Frame gets set, by definition, the View is now LayoutStyle.Absolute, so
- // set all Pos/Dim to Absolute values.
+ // If Frame gets set, set all Pos/Dim to Absolute values.
_x = _frame.X;
_y = _frame.Y;
_width = _frame.Width;
@@ -148,8 +146,7 @@ public partial class View
/// and methods to be called.
///
///
- /// Changing this property will cause to be updated. If the new value is not of type
- /// the will change to .
+ /// Changing this property will cause to be updated.
///
/// The default value is Pos.At (0) .
///
@@ -187,8 +184,7 @@ public partial class View
/// and methods to be called.
///
///
- /// Changing this property will cause to be updated. If the new value is not of type
- /// the will change to .
+ /// Changing this property will cause to be updated.
///
/// The default value is Pos.At (0) .
///
@@ -226,8 +222,7 @@ public partial class View
/// and methods to be called.
///
///
- /// Changing this property will cause to be updated. If the new value is not of type
- /// the will change to .
+ /// Changing this property will cause to be updated.
///
/// The default value is Dim.Sized (0) .
///
@@ -272,8 +267,7 @@ public partial class View
/// and methods to be called.
///
///
- /// Changing this property will cause to be updated. If the new value is not of type
- /// the will change to .
+ /// Changing this property will cause to be updated.
///
/// The default value is Dim.Sized (0) .
///
@@ -303,55 +297,6 @@ public partial class View
#region Layout Engine
-
- // @tig Notes on layout flow. Ignore for now.
- // BeginLayout
- // If !LayoutNeeded return
- // If !SizeNeeded return
- // Call OnLayoutStarted
- // Views and subviews can update things
- //
-
-
- // EndLayout
-
- ///
- /// Controls how the View's is computed during . If the style is
- /// set to , LayoutSubviews does not change the . If the style is
- /// the is updated using the , ,
- /// , and properties.
- ///
- ///
- ///
- /// Setting this property to will cause to determine the
- /// size and position of the view. and will be set to
- /// using .
- ///
- ///
- /// Setting this property to will cause the view to use the
- /// method to size and position of the view. If either of the and
- /// properties are `null` they will be set to using the current value
- /// of . If either of the and properties are `null`
- /// they will be set to using .
- ///
- ///
- /// The layout style.
- public LayoutStyle LayoutStyle
- {
- get
- {
- if (_x is PosAbsolute
- && _y is PosAbsolute
- && _width is DimAbsolute
- && _height is DimAbsolute)
- {
- return LayoutStyle.Absolute;
- }
-
- return LayoutStyle.Computed;
- }
- }
-
#endregion Layout Engine
///
@@ -796,8 +741,7 @@ public partial class View
if (Frame != newFrame)
{
- // Set the frame. Do NOT use `Frame` as it overwrites X, Y, Width, and Height, making
- // the view LayoutStyle.Absolute.
+ // Set the frame. Do NOT use `Frame` as it overwrites X, Y, Width, and Height
SetFrame (newFrame);
if (_x is PosAbsolute)
@@ -836,10 +780,10 @@ public partial class View
{
nNodes.Add (v);
- if (v.LayoutStyle != LayoutStyle.Computed)
- {
- continue;
- }
+ //if (v.LayoutStyle != LayoutStyle.Computed)
+ //{
+ // continue;
+ //}
CollectPos (v.X, v, ref nNodes, ref nEdges);
CollectPos (v.Y, v, ref nNodes, ref nEdges);
diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs
index 1632eca2f..28ba6a27c 100644
--- a/Terminal.Gui/View/View.cs
+++ b/Terminal.Gui/View/View.cs
@@ -43,13 +43,6 @@ namespace Terminal.Gui;
/// more subviews, can respond to user input and render themselves on the screen.
///
///
-/// View supports two layout styles: or .
-/// The style is determined by the values of , , , and
-/// . If any of these is set to non-absolute or object,
-/// then the layout style is . Otherwise it is
-/// .
-///
-///
/// To create a View using Absolute layout, call a constructor that takes a Rect parameter to specify the
/// absolute position and size or simply set ). To create a View using Computed layout use
/// a constructor that does not take a Rect parameter and set the X, Y, Width and Height properties on the view to
@@ -79,9 +72,7 @@ namespace Terminal.Gui;
/// To flag the entire view for redraw call .
///
///
-/// The method is invoked when the size or layout of a view has changed. The default
-/// processing system will keep the size and dimensions for views that use the ,
-/// and will recompute the Adornments for the views that use .
+/// The method is invoked when the size or layout of a view has changed.
///
///
/// Views have a property that defines the default colors that subviews should use for
@@ -127,15 +118,7 @@ public partial class View : Responder, ISupportInitializeNotification
///
///
/// Use , , , and properties to dynamically
- /// control the size and location of the view. The will be created using
- /// coordinates. The initial size ( ) will be adjusted
- /// to fit the contents of , including newlines ('\n') for multiple lines.
- ///
- /// If is greater than one, word wrapping is provided.
- ///
- /// This constructor initialize a View with a of .
- /// Use , , , and properties to dynamically
- /// control the size and location of the view, changing it to .
+ /// control the size and location of the view.
///
///
public View ()
diff --git a/Terminal.Gui/View/ViewContent.cs b/Terminal.Gui/View/ViewContent.cs
index 7fa48ed38..cdba2aa09 100644
--- a/Terminal.Gui/View/ViewContent.cs
+++ b/Terminal.Gui/View/ViewContent.cs
@@ -183,11 +183,6 @@ public partial class View
/// The property controls how scrolling is handled.
///
///
- /// If is the value of Viewport is indeterminate until
- /// the view has been initialized ( is true) and has been
- /// called.
- ///
- ///
/// Updates to the Viewport Size updates , and has the same impact as updating the
/// .
///
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index 5b1cfcf3d..dffa7cb9f 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -33,8 +33,8 @@ public class Button : View
private readonly Rune _rightDefault;
private bool _isDefault;
- /// Initializes a new instance of using layout.
- /// The width of the is computed based on the text length. The height will always be 1.
+ /// Initializes a new instance of .
+ /// The width and height of the is computed based on the text.
public Button ()
{
TextAlignment = Alignment.Center;
diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs
index cf0adeefc..471ab5203 100644
--- a/Terminal.Gui/Views/CheckBox.cs
+++ b/Terminal.Gui/Views/CheckBox.cs
@@ -11,8 +11,7 @@ public class CheckBox : View
private bool? _checked = false;
///
- /// Initializes a new instance of based on the given text, using
- /// layout.
+ /// Initializes a new instance of .
///
public CheckBox ()
{
diff --git a/Terminal.Gui/Views/DateField.cs b/Terminal.Gui/Views/DateField.cs
index 5640e5b87..7a4797fb6 100644
--- a/Terminal.Gui/Views/DateField.cs
+++ b/Terminal.Gui/Views/DateField.cs
@@ -21,10 +21,10 @@ public class DateField : TextField
private string _format;
private string _separator;
- /// Initializes a new instance of using layout.
+ /// Initializes a new instance of .
public DateField () : this (DateTime.MinValue) { }
- /// Initializes a new instance of using layout.
+ /// Initializes a new instance of .
///
public DateField (DateTime date)
{
diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs
index d0376ca84..5ed0a4ef5 100644
--- a/Terminal.Gui/Views/Dialog.cs
+++ b/Terminal.Gui/Views/Dialog.cs
@@ -55,13 +55,11 @@ public class Dialog : Window
private readonly List _buttons = new ();
///
- /// Initializes a new instance of the class using
- /// positioning with no s.
+ /// Initializes a new instance of the class.
///
///
- /// By default, and are set to Pos.Center () and
- /// and are set to Width = Dim.Percent (85) , centering the
- /// Dialog vertically and horizontally.
+ /// By default, , , , and are set
+ /// such that the dialog will be centered and no larger than 90% of the container's width and height.
///
public Dialog ()
{
diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs
index a9208578d..ca08e45cd 100644
--- a/Terminal.Gui/Views/FrameView.cs
+++ b/Terminal.Gui/Views/FrameView.cs
@@ -3,13 +3,12 @@
namespace Terminal.Gui;
///
-/// The FrameView is a container frame that draws a frame around the contents. It is similar to a GroupBox in
-/// Windows.
+/// The FrameView is a container View with a border around it.
///
public class FrameView : View
{
///
- /// Initializes a new instance of the class using
+ /// Initializes a new instance of the class.
/// layout.
///
public FrameView ()
diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs
index 6123a2223..a55386413 100644
--- a/Terminal.Gui/Views/HexView.cs
+++ b/Terminal.Gui/Views/HexView.cs
@@ -38,7 +38,7 @@ public class HexView : View
private static readonly Rune SpaceCharRune = new (' ');
private static readonly Rune PeriodCharRune = new ('.');
- /// Initializes a class using layout.
+ /// Initializes a class.
///
/// The to view and edit as hex, this must support seeking,
/// or an exception will be thrown.
@@ -98,7 +98,7 @@ public class HexView : View
LayoutComplete += HexView_LayoutComplete;
}
- /// Initializes a class using layout.
+ /// Initializes a class.
public HexView () : this (new MemoryStream ()) { }
///
diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs
index a42f6d840..3ea85bbbe 100644
--- a/Terminal.Gui/Views/RadioGroup.cs
+++ b/Terminal.Gui/Views/RadioGroup.cs
@@ -11,8 +11,7 @@ public class RadioGroup : View
private int _selected;
///
- /// Initializes a new instance of the class using
- /// layout.
+ /// Initializes a new instance of the class.
///
public RadioGroup ()
{
diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs
index b30a39415..e8b5e487c 100644
--- a/Terminal.Gui/Views/ScrollBarView.cs
+++ b/Terminal.Gui/Views/ScrollBarView.cs
@@ -33,8 +33,7 @@ public class ScrollBarView : View
private bool _vertical;
///
- /// Initializes a new instance of the class using
- /// layout.
+ /// Initializes a new instance of the class.
///
public ScrollBarView ()
{
@@ -46,8 +45,7 @@ public class ScrollBarView : View
}
///
- /// Initializes a new instance of the class using
- /// layout.
+ /// Initializes a new instance of the class.
///
/// The view that will host this scrollbar.
/// If set to true this is a vertical scrollbar, otherwise, the scrollbar is horizontal.
diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs
index d62729223..00e1b1e3e 100644
--- a/Terminal.Gui/Views/ScrollView.cs
+++ b/Terminal.Gui/Views/ScrollView.cs
@@ -38,8 +38,7 @@ public class ScrollView : View
private bool _showVerticalScrollIndicator;
///
- /// Initializes a new instance of the class using
- /// positioning.
+ /// Initializes a new instance of the class.
///
public ScrollView ()
{
diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs
index 52036e1e9..068b8ff50 100644
--- a/Terminal.Gui/Views/TabView.cs
+++ b/Terminal.Gui/Views/TabView.cs
@@ -21,7 +21,7 @@ public class TabView : View
private TabToRender [] _tabLocations;
private int _tabScrollOffset;
- /// Initializes a class using layout.
+ /// Initializes a class.
public TabView ()
{
CanFocus = true;
diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs
index 5e8ed2d74..18c5088de 100644
--- a/Terminal.Gui/Views/TableView/TableView.cs
+++ b/Terminal.Gui/Views/TableView/TableView.cs
@@ -37,12 +37,12 @@ public class TableView : View
private TableStyle style = new ();
private ITableSource table;
- /// Initializes a class using layout.
+ /// Initializes a class.
/// The table to display in the control
public TableView (ITableSource table) : this () { Table = table; }
///
- /// Initializes a class using layout. Set the
+ /// Initializes a class. Set the
/// property to begin editing
///
public TableView ()
diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs
index b651703f3..3323e4541 100644
--- a/Terminal.Gui/Views/TextField.cs
+++ b/Terminal.Gui/Views/TextField.cs
@@ -21,8 +21,7 @@ public class TextField : View
private List _text;
///
- /// Initializes a new instance of the class using
- /// positioning.
+ /// Initializes a new instance of the class.
///
public TextField ()
{
diff --git a/Terminal.Gui/Views/TextValidateField.cs b/Terminal.Gui/Views/TextValidateField.cs
index 3aac68f09..0e36a80c2 100644
--- a/Terminal.Gui/Views/TextValidateField.cs
+++ b/Terminal.Gui/Views/TextValidateField.cs
@@ -392,8 +392,7 @@ namespace Terminal.Gui
private ITextValidateProvider _provider;
///
- /// Initializes a new instance of the class using
- /// positioning.
+ /// Initializes a new instance of the class.
///
public TextValidateField ()
{
diff --git a/Terminal.Gui/Views/TimeField.cs b/Terminal.Gui/Views/TimeField.cs
index 4550992c4..d1101c243 100644
--- a/Terminal.Gui/Views/TimeField.cs
+++ b/Terminal.Gui/Views/TimeField.cs
@@ -21,7 +21,7 @@ public class TimeField : TextField
private bool _isShort;
private TimeSpan _time;
- /// Initializes a new instance of using positioning.
+ /// Initializes a new instance of .
public TimeField ()
{
CultureInfo cultureInfo = CultureInfo.CurrentCulture;
diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs
index 0b5bd14ad..3cbfb6d58 100644
--- a/Terminal.Gui/Views/Toplevel.cs
+++ b/Terminal.Gui/Views/Toplevel.cs
@@ -23,7 +23,7 @@ namespace Terminal.Gui;
public partial class Toplevel : View
{
///
- /// Initializes a new instance of the class with layout,
+ /// Initializes a new instance of the class,
/// defaulting to full screen. The and properties will be set to the
/// dimensions of the terminal using .
///
@@ -397,9 +397,7 @@ public partial class Toplevel : View
}
if ((superView != top || top?.SuperView is { } || (top != Application.Top && top.Modal) || (top?.SuperView is null && top.IsOverlapped))
-
- // BUGBUG: Prevously PositionToplevel required LayotuStyle.Computed
- && (top.Frame.X + top.Frame.Width > maxWidth || ny > top.Frame.Y) /*&& top.LayoutStyle == LayoutStyle.Computed*/)
+ && (top.Frame.X + top.Frame.Width > maxWidth || ny > top.Frame.Y))
{
if ((top.X is null || top.X is PosAbsolute) && top.Frame.X != nx)
{
diff --git a/Terminal.Gui/Views/Window.cs b/Terminal.Gui/Views/Window.cs
index 8c2c6738b..0a1dfe32e 100644
--- a/Terminal.Gui/Views/Window.cs
+++ b/Terminal.Gui/Views/Window.cs
@@ -15,8 +15,7 @@ namespace Terminal.Gui;
public class Window : Toplevel
{
///
- /// Initializes a new instance of the class using
- /// positioning.
+ /// Initializes a new instance of the class.
///
public Window ()
{
diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs
index deeda162d..ab81e515a 100644
--- a/Terminal.Gui/Views/Wizard/Wizard.cs
+++ b/Terminal.Gui/Views/Wizard/Wizard.cs
@@ -57,8 +57,7 @@ public class Wizard : Dialog
private string _wizardTitle = string.Empty;
///
- /// Initializes a new instance of the class using
- /// positioning.
+ /// Initializes a new instance of the class.
///
///
/// The Wizard will be vertically and horizontally centered in the container. After initialization use X ,
diff --git a/Terminal.Gui/Views/Wizard/WizardStep.cs b/Terminal.Gui/Views/Wizard/WizardStep.cs
index 490307ee0..c28c3653c 100644
--- a/Terminal.Gui/Views/Wizard/WizardStep.cs
+++ b/Terminal.Gui/Views/Wizard/WizardStep.cs
@@ -40,8 +40,7 @@ public class WizardStep : FrameView
private readonly TextView _helpTextView = new ();
///
- /// Initializes a new instance of the class using
- /// positioning.
+ /// Initializes a new instance of the class.
///
public WizardStep ()
{
diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs
index fd76ed158..a95cd23ba 100644
--- a/UICatalog/Scenarios/AllViewsTester.cs
+++ b/UICatalog/Scenarios/AllViewsTester.cs
@@ -88,7 +88,7 @@ public class AllViewsTester : Scenario
.Select (t => new KeyValuePair (t.Name, t))
.ToDictionary (t => t.Key, t => t.Value);
- _leftPane = new FrameView
+ _leftPane = new()
{
X = 0,
Y = 0,
@@ -99,7 +99,7 @@ public class AllViewsTester : Scenario
Title = "Classes"
};
- _classListView = new ListView
+ _classListView = new()
{
X = 0,
Y = 0,
@@ -128,7 +128,7 @@ public class AllViewsTester : Scenario
};
_leftPane.Add (_classListView);
- _settingsPane = new FrameView
+ _settingsPane = new()
{
X = Pos.Right (_leftPane),
Y = 0, // for menu
@@ -141,7 +141,7 @@ public class AllViewsTester : Scenario
string [] radioItems = { "_Percent(x)", "_AnchorEnd", "_Center", "A_bsolute(x)" };
- _locationFrame = new FrameView
+ _locationFrame = new()
{
X = 0,
Y = 0,
@@ -153,9 +153,9 @@ public class AllViewsTester : Scenario
var label = new Label { X = 0, Y = 0, Text = "X:" };
_locationFrame.Add (label);
- _xRadioGroup = new RadioGroup { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
+ _xRadioGroup = new() { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
_xRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
- _xText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
+ _xText = new() { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
_xText.Accept += (s, args) =>
{
@@ -172,9 +172,9 @@ public class AllViewsTester : Scenario
_locationFrame.Add (_xRadioGroup);
radioItems = new [] { "P_ercent(y)", "A_nchorEnd", "C_enter", "Absolute(_y)" };
- label = new Label { X = Pos.Right (_xRadioGroup) + 1, Y = 0, Text = "Y:" };
+ label = new() { X = Pos.Right (_xRadioGroup) + 1, Y = 0, Text = "Y:" };
_locationFrame.Add (label);
- _yText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" };
+ _yText = new() { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" };
_yText.Accept += (s, args) =>
{
@@ -187,11 +187,11 @@ public class AllViewsTester : Scenario
{ }
};
_locationFrame.Add (_yText);
- _yRadioGroup = new RadioGroup { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
+ _yRadioGroup = new() { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
_yRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
_locationFrame.Add (_yRadioGroup);
- _sizeFrame = new FrameView
+ _sizeFrame = new()
{
X = Pos.Right (_locationFrame),
Y = Pos.Y (_locationFrame),
@@ -201,42 +201,42 @@ public class AllViewsTester : Scenario
};
radioItems = new [] { "Auto", "_Percent(width)", "_Fill(width)", "A_bsolute(width)" };
- label = new Label { X = 0, Y = 0, Text = "Width:" };
+ label = new() { X = 0, Y = 0, Text = "Width:" };
_sizeFrame.Add (label);
- _wRadioGroup = new RadioGroup { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
+ _wRadioGroup = new() { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
_wRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
- _wText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
+ _wText = new() { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
_wText.Accept += (s, args) =>
- {
- try
- {
- switch (_wRadioGroup.SelectedItem)
- {
- case 1:
- _wVal = Math.Min (int.Parse (_wText.Text), 100);
+ {
+ try
+ {
+ switch (_wRadioGroup.SelectedItem)
+ {
+ case 1:
+ _wVal = Math.Min (int.Parse (_wText.Text), 100);
- break;
- case 0:
- case 2:
- case 3:
- _wVal = int.Parse (_wText.Text);
+ break;
+ case 0:
+ case 2:
+ case 3:
+ _wVal = int.Parse (_wText.Text);
- break;
- }
+ break;
+ }
- DimPosChanged (_curView);
- }
- catch
- { }
- };
+ DimPosChanged (_curView);
+ }
+ catch
+ { }
+ };
_sizeFrame.Add (_wText);
_sizeFrame.Add (_wRadioGroup);
radioItems = new [] { "_Auto", "P_ercent(height)", "F_ill(height)", "Ab_solute(height)" };
- label = new Label { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "Height:" };
+ label = new() { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "Height:" };
_sizeFrame.Add (label);
- _hText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
+ _hText = new() { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
_hText.Accept += (s, args) =>
{
@@ -263,20 +263,22 @@ public class AllViewsTester : Scenario
};
_sizeFrame.Add (_hText);
- _hRadioGroup = new RadioGroup { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
+ _hRadioGroup = new() { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
_hRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
_sizeFrame.Add (_hRadioGroup);
_settingsPane.Add (_sizeFrame);
- label = new Label { X = 0, Y = Pos.Bottom (_sizeFrame), Text = "_Orientation:" };
- _orientation = new RadioGroup
+ label = new() { X = 0, Y = Pos.Bottom (_sizeFrame), Text = "_Orientation:" };
+
+ _orientation = new()
{
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
RadioLabels = new [] { "Horizontal", "Vertical" },
Orientation = Orientation.Horizontal
};
+
_orientation.SelectedItemChanged += (s, selected) =>
{
if (_curView?.GetType ().GetProperty ("Orientation") is { } prop)
@@ -286,7 +288,8 @@ public class AllViewsTester : Scenario
};
_settingsPane.Add (label, _orientation);
- label = new Label { X = 0, Y = Pos.Bottom (_orientation), Text = "_Text:" };
+ label = new() { X = 0, Y = Pos.Bottom (_orientation), Text = "_Text:" };
+
_demoTextView = new ()
{
X = Pos.Right (label) + 1,
@@ -295,15 +298,16 @@ public class AllViewsTester : Scenario
Height = Dim.Auto (minimumContentDim: 2),
Text = _demoText
};
+
_demoTextView.ContentsChanged += (s, e) =>
- {
- _demoText = _demoTextView.Text;
- _curView.Text = _demoText;
- };
+ {
+ _demoText = _demoTextView.Text;
+ _curView.Text = _demoText;
+ };
_settingsPane.Add (label, _demoTextView);
- _hostPane = new FrameView
+ _hostPane = new()
{
X = Pos.Right (_leftPane),
Y = Pos.Bottom (_settingsPane),
@@ -419,47 +423,43 @@ public class AllViewsTester : Scenario
return;
}
- LayoutStyle layout = view.LayoutStyle;
-
try
{
- //view.LayoutStyle = LayoutStyle.Absolute;
-
view.X = _xRadioGroup.SelectedItem switch
- {
- 0 => Pos.Percent (_xVal),
- 1 => Pos.AnchorEnd (),
- 2 => Pos.Center (),
- 3 => Pos.Absolute (_xVal),
- _ => view.X
- };
+ {
+ 0 => Pos.Percent (_xVal),
+ 1 => Pos.AnchorEnd (),
+ 2 => Pos.Center (),
+ 3 => Pos.Absolute (_xVal),
+ _ => view.X
+ };
view.Y = _yRadioGroup.SelectedItem switch
- {
- 0 => Pos.Percent (_yVal),
- 1 => Pos.AnchorEnd (),
- 2 => Pos.Center (),
- 3 => Pos.Absolute (_yVal),
- _ => view.Y
- };
+ {
+ 0 => Pos.Percent (_yVal),
+ 1 => Pos.AnchorEnd (),
+ 2 => Pos.Center (),
+ 3 => Pos.Absolute (_yVal),
+ _ => view.Y
+ };
view.Width = _wRadioGroup.SelectedItem switch
- {
- 0 => Dim.Auto (),
- 1 => Dim.Percent (_wVal),
- 2 => Dim.Fill (_wVal),
- 3 => Dim.Absolute (_wVal),
- _ => view.Width
- };
+ {
+ 0 => Dim.Auto (),
+ 1 => Dim.Percent (_wVal),
+ 2 => Dim.Fill (_wVal),
+ 3 => Dim.Absolute (_wVal),
+ _ => view.Width
+ };
view.Height = _hRadioGroup.SelectedItem switch
- {
- 0 => Dim.Auto (),
- 1 => Dim.Percent (_hVal),
- 2 => Dim.Fill (_hVal),
- 3 => Dim.Absolute (_hVal),
- _ => view.Height
- };
+ {
+ 0 => Dim.Auto (),
+ 1 => Dim.Percent (_hVal),
+ 2 => Dim.Fill (_hVal),
+ 3 => Dim.Absolute (_hVal),
+ _ => view.Height
+ };
}
catch (Exception e)
{
@@ -468,7 +468,7 @@ public class AllViewsTester : Scenario
if (view.Width is DimAuto)
{
- _wText.Text = $"Auto";
+ _wText.Text = "Auto";
_wText.Enabled = false;
}
else
@@ -479,7 +479,7 @@ public class AllViewsTester : Scenario
if (view.Height is DimAuto)
{
- _hText.Text = $"Auto";
+ _hText.Text = "Auto";
_hText.Enabled = false;
}
else
@@ -488,8 +488,6 @@ public class AllViewsTester : Scenario
_hText.Enabled = true;
}
-
-
UpdateTitle (view);
}
@@ -532,28 +530,28 @@ public class AllViewsTester : Scenario
var h = view.Height.ToString ();
_wRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => w.Contains (s)).First ());
_hRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => h.Contains (s)).First ());
+
if (view.Width is DimAuto)
{
- _wText.Text = $"Auto";
+ _wText.Text = "Auto";
_wText.Enabled = false;
}
else
{
- _wText.Text = $"100";
+ _wText.Text = "100";
_wText.Enabled = true;
}
if (view.Height is DimAuto)
{
- _hText.Text = $"Auto";
+ _hText.Text = "Auto";
_hText.Enabled = false;
}
else
{
- _hText.Text = $"100";
+ _hText.Text = "100";
_hText.Enabled = true;
}
-
}
private void UpdateTitle (View view) { _hostPane.Title = $"{view.GetType ().Name} - {view.X}, {view.Y}, {view.Width}, {view.Height}"; }
diff --git a/UnitTests/UICatalog/ScenarioTests.cs b/UnitTests/UICatalog/ScenarioTests.cs
index 580cfcaec..72ebb0834 100644
--- a/UnitTests/UICatalog/ScenarioTests.cs
+++ b/UnitTests/UICatalog/ScenarioTests.cs
@@ -106,7 +106,6 @@ public class ScenarioTests : TestsAllViews
// Settings
FrameView _settingsPane;
- CheckBox _computedCheckBox;
FrameView _locationFrame;
RadioGroup _xRadioGroup;
TextField _xText;
@@ -164,15 +163,13 @@ public class ScenarioTests : TestsAllViews
ColorScheme = Colors.ColorSchemes ["TopLevel"],
Title = "Settings"
};
- _computedCheckBox = new () { X = 0, Y = 0, Text = "Computed Layout", Checked = true };
- _settingsPane.Add (_computedCheckBox);
var radioItems = new [] { "Percent(x)", "AnchorEnd(x)", "Center", "Absolute(x)" };
_locationFrame = new ()
{
- X = Pos.Left (_computedCheckBox),
- Y = Pos.Bottom (_computedCheckBox),
+ X = 0,
+ Y = 0,
Height = 3 + radioItems.Length,
Width = 36,
Title = "Location (Pos)"
@@ -249,15 +246,6 @@ public class ScenarioTests : TestsAllViews
_curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
};
- _computedCheckBox.Toggled += (s, e) =>
- {
- if (_curView != null)
- {
- //_curView.LayoutStyle = e.OldValue == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
- _hostPane.LayoutSubviews ();
- }
- };
-
_xRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
_xText.TextChanged += (s, args) =>
@@ -351,11 +339,8 @@ public class ScenarioTests : TestsAllViews
return;
}
- LayoutStyle layout = view.LayoutStyle;
-
try
{
- //view.LayoutStyle = LayoutStyle.Absolute;
switch (_xRadioGroup.SelectedItem)
{
@@ -531,9 +516,6 @@ public class ScenarioTests : TestsAllViews
view?.GetType ().GetProperty ("Source")?.GetSetMethod ()?.Invoke (view, new [] { source });
}
- // Set Settings
- _computedCheckBox.Checked = view.LayoutStyle == LayoutStyle.Computed;
-
// Add
_hostPane.Add (view);
diff --git a/UnitTests/View/Layout/AbsoluteLayoutTests.cs b/UnitTests/View/Layout/AbsoluteLayoutTests.cs
index 677401dd5..1ed9fab03 100644
--- a/UnitTests/View/Layout/AbsoluteLayoutTests.cs
+++ b/UnitTests/View/Layout/AbsoluteLayoutTests.cs
@@ -1,16 +1,10 @@
using Xunit.Abstractions;
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
-
-// Alias Console to MockConsole so we don't accidentally use Console
-
namespace Terminal.Gui.LayoutTests;
-public class AbsoluteLayoutTests
+public class AbsoluteLayoutTests (ITestOutputHelper output)
{
- private readonly ITestOutputHelper _output;
- public AbsoluteLayoutTests (ITestOutputHelper output) { _output = output; }
-
+ private readonly ITestOutputHelper _output = output;
[Fact]
[TestRespondersDisposed]
@@ -22,11 +16,10 @@ public class AbsoluteLayoutTests
var v = new View { Frame = frame };
v.Height = newFrame.Height;
v.Width = newFrame.Width;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
- new Rectangle (0, 0, newFrame.Width, newFrame.Height),
+ new (0, 0, newFrame.Width, newFrame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
@@ -43,7 +36,6 @@ public class AbsoluteLayoutTests
var v = new View { Frame = Rectangle.Empty };
v.Height = Dim.Fill ();
v.Width = Dim.Fill ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Dispose ();
}
@@ -57,11 +49,10 @@ public class AbsoluteLayoutTests
var v = new View { Frame = frame };
v.X = newFrame.X;
v.Y = newFrame.Y;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
- new Rectangle (0, 0, newFrame.Width, newFrame.Height),
+ new (0, 0, newFrame.Width, newFrame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
@@ -78,7 +69,6 @@ public class AbsoluteLayoutTests
var v = new View { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Dispose ();
}
@@ -91,73 +81,61 @@ public class AbsoluteLayoutTests
v.Y = 2;
v.Height = 3;
v.Width = 4;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
v.Dispose ();
- v = new View { Frame = Rectangle.Empty };
+ v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Dispose ();
- v = new View { Frame = Rectangle.Empty };
+ v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.X = 1;
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Dispose ();
- v = new View { Frame = Rectangle.Empty };
+ v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Y = 2;
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Dispose ();
- v = new View { Frame = Rectangle.Empty };
+ v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Width = 3;
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Dispose ();
- v = new View { Frame = Rectangle.Empty };
+ v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Height = 3;
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.Dispose ();
- v = new View { Frame = Rectangle.Empty };
+ v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
- Assert.True (v.LayoutStyle == LayoutStyle.Computed);
v.X = 1;
v.Y = 2;
v.Height = 3;
v.Width = 4;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
v.Dispose ();
}
@@ -166,16 +144,14 @@ public class AbsoluteLayoutTests
public void AbsoluteLayout_Constructor ()
{
var v = new View ();
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
v.Dispose ();
var frame = Rectangle.Empty;
- v = new View { Frame = frame };
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+ v = new() { Frame = frame };
Assert.Equal (frame, v.Frame);
Assert.Equal (
- new Rectangle (0, 0, frame.Width, frame.Height),
+ new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
@@ -184,13 +160,12 @@ public class AbsoluteLayoutTests
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
- frame = new Rectangle (1, 2, 3, 4);
- v = new View { Frame = frame };
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+ frame = new (1, 2, 3, 4);
+ v = new() { Frame = frame };
Assert.Equal (frame, v.Frame);
Assert.Equal (
- new Rectangle (0, 0, frame.Width, frame.Height),
+ new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
@@ -199,12 +174,11 @@ public class AbsoluteLayoutTests
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
- v = new View { Frame = frame, Text = "v" };
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+ v = new() { Frame = frame, Text = "v" };
Assert.Equal (frame, v.Frame);
Assert.Equal (
- new Rectangle (0, 0, frame.Width, frame.Height),
+ new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
@@ -213,34 +187,28 @@ public class AbsoluteLayoutTests
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
- v = new View { X = frame.X, Y = frame.Y, Text = "v" };
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+ v = new() { X = frame.X, Y = frame.Y, Text = "v" };
- // BUGBUG: v2 - I think the default size should be 0,0 not 1,1
- // That is correct it should be 0,0 because AutoSize is false
- // and the size wasn't set on the initializer
- Assert.Equal (new Rectangle (frame.X, frame.Y, 0, 0), v.Frame);
- Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
+ Assert.Equal (new (frame.X, frame.Y, 0, 0), v.Frame);
+ Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
- v = new View ();
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
- Assert.Equal (new Rectangle (0, 0, 0, 0), v.Frame);
- Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
+ v = new ();
+ Assert.Equal (new (0, 0, 0, 0), v.Frame);
+ Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
Assert.Equal (Pos.Absolute (0), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
- v = new View { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height };
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
- Assert.Equal (new Rectangle (frame.X, frame.Y, 3, 4), v.Frame);
- Assert.Equal (new Rectangle (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
+ v = new() { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height };
+ Assert.Equal (new (frame.X, frame.Y, 3, 4), v.Frame);
+ Assert.Equal (new (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (3), v.Width);
@@ -254,20 +222,15 @@ public class AbsoluteLayoutTests
{
var superRect = new Rectangle (0, 0, 100, 100);
var super = new View { Frame = superRect, Text = "super" };
- Assert.True (super.LayoutStyle == LayoutStyle.Absolute);
var v1 = new View { X = 0, Y = 0, Width = 10, Height = 10 };
- Assert.True (v1.LayoutStyle == LayoutStyle.Absolute);
var v2 = new View { X = 10, Y = 10, Width = 10, Height = 10 };
- Assert.True (v2.LayoutStyle == LayoutStyle.Absolute);
super.Add (v1, v2);
- Assert.True (v1.LayoutStyle == LayoutStyle.Absolute);
- Assert.True (v2.LayoutStyle == LayoutStyle.Absolute);
super.LayoutSubviews ();
- Assert.Equal (new Rectangle (0, 0, 10, 10), v1.Frame);
- Assert.Equal (new Rectangle (10, 10, 10, 10), v2.Frame);
+ Assert.Equal (new (0, 0, 10, 10), v1.Frame);
+ Assert.Equal (new (10, 10, 10, 10), v2.Frame);
super.Dispose ();
}
}
diff --git a/UnitTests/View/Layout/Dim.Tests.cs b/UnitTests/View/Layout/Dim.Tests.cs
index 9a6ce3e03..c75cdca3a 100644
--- a/UnitTests/View/Layout/Dim.Tests.cs
+++ b/UnitTests/View/Layout/Dim.Tests.cs
@@ -146,39 +146,6 @@ public class DimTests
Assert.Equal (0, count);
}
- // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
- // TODO: A new test that calls SetRelativeLayout directly is needed.
- [Fact]
- [TestRespondersDisposed]
- public void
- Dim_Validation_Do_Not_Throws_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
- {
- var t = new View { Width = 80, Height = 25, Text = "top" };
-
- var w = new Window { Width = Dim.Fill (), Height = Dim.Absolute (10) };
- var v = new View { Width = Dim.Width (w) - 2, Height = Dim.Percent (10), Text = "v" };
-
- w.Add (v);
- t.Add (w);
-
- Assert.Equal (LayoutStyle.Absolute, t.LayoutStyle);
- Assert.Equal (LayoutStyle.Computed, w.LayoutStyle);
- Assert.Equal (LayoutStyle.Computed, v.LayoutStyle);
-
- t.LayoutSubviews ();
- Assert.Equal (2, v.Width = 2);
- Assert.Equal (2, v.Height = 2);
-
- // Force v to be LayoutStyle.Absolute;
- v.Frame = new Rectangle (0, 1, 3, 4);
- Assert.Equal (LayoutStyle.Absolute, v.LayoutStyle);
- t.LayoutSubviews ();
-
- Assert.Equal (2, v.Width = 2);
- Assert.Equal (2, v.Height = 2);
- t.Dispose ();
- }
-
// TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
// TODO: A new test that calls SetRelativeLayout directly is needed.
[Fact]
@@ -203,60 +170,6 @@ public class DimTests
t.Dispose ();
}
-
- // See #2461
- //[Fact]
- //public void Dim_Referencing_SuperView_Throws ()
- //{
- // var super = new View ("super") {
- // Width = 10,
- // Height = 10
- // };
- // var view = new View ("view") {
- // Width = Dim.Width (super), // this is not allowed
- // Height = Dim.Height (super), // this is not allowed
- // };
-
- // super.Add (view);
- // super.BeginInit ();
- // super.EndInit ();
- // Assert.Throws (() => super.LayoutSubviews ());
- //}
-
- // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
- // TODO: A new test that calls SetRelativeLayout directly is needed.
- [Fact]
- [TestRespondersDisposed]
- public void
- Dim_Validation_Does_Not_Throw_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
- {
- var t = new View { Width = 80, Height = 25, Text = "top" };
-
- var w = new Window { Width = Dim.Fill (), Height = Dim.Absolute (10) };
- var v = new View { Width = Dim.Width (w) - 2, Height = Dim.Percent (10), Text = "v" };
-
- w.Add (v);
- t.Add (w);
-
- Assert.Equal (LayoutStyle.Absolute, t.LayoutStyle);
- Assert.Equal (LayoutStyle.Computed, w.LayoutStyle);
- Assert.Equal (LayoutStyle.Computed, v.LayoutStyle);
-
- t.LayoutSubviews ();
- Assert.Equal (2, v.Width = 2);
- Assert.Equal (2, v.Height = 2);
-
- // Force v to be LayoutStyle.Absolute;
- v.Frame = new Rectangle (0, 1, 3, 4);
- Assert.Equal (LayoutStyle.Absolute, v.LayoutStyle);
- t.LayoutSubviews ();
-
- Assert.Equal (2, v.Width = 2);
- Assert.Equal (2, v.Height = 2);
- t.Dispose ();
- }
-
-
[Fact]
public void DimHeight_Set_To_Null_Throws ()
{
diff --git a/UnitTests/View/Layout/FrameTests.cs b/UnitTests/View/Layout/FrameTests.cs
index e1b94c7e5..326dd3370 100644
--- a/UnitTests/View/Layout/FrameTests.cs
+++ b/UnitTests/View/Layout/FrameTests.cs
@@ -40,14 +40,11 @@ public class FrameTests (ITestOutputHelper output)
var newFrame = new Rectangle (1, 2, 30, 40);
var v = new View ();
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
v.Dispose ();
v = new View { Frame = frame };
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
v.Frame = newFrame;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
@@ -62,7 +59,6 @@ public class FrameTests (ITestOutputHelper output)
v = new View { X = frame.X, Y = frame.Y, Text = "v" };
v.Frame = newFrame;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
@@ -78,7 +74,6 @@ public class FrameTests (ITestOutputHelper output)
newFrame = new Rectangle (10, 20, 30, 40);
v = new View { Frame = frame };
v.Frame = newFrame;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
@@ -93,7 +88,6 @@ public class FrameTests (ITestOutputHelper output)
v = new View { X = frame.X, Y = frame.Y, Text = "v" };
v.Frame = newFrame;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
diff --git a/UnitTests/View/Layout/ViewportTests.cs b/UnitTests/View/Layout/ViewportTests.cs
index 9559fd672..ff2b3be27 100644
--- a/UnitTests/View/Layout/ViewportTests.cs
+++ b/UnitTests/View/Layout/ViewportTests.cs
@@ -181,10 +181,8 @@ public class ViewportTests (ITestOutputHelper output)
var newViewport = new Rectangle (0, 0, 30, 40);
var v = new View { Frame = frame };
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
v.Viewport = newViewport;
- Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
Assert.Equal (newViewport, v.Viewport);
Assert.Equal (new Rectangle (1, 2, newViewport.Width, newViewport.Height), v.Frame);
Assert.Equal (new Rectangle (0, 0, newViewport.Width, newViewport.Height), v.Viewport);
diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs
index e7bb8666c..da658b99d 100644
--- a/UnitTests/View/ViewTests.cs
+++ b/UnitTests/View/ViewTests.cs
@@ -251,7 +251,6 @@ At 0,0
view.Frame = new Rectangle (3, 3, 10, 1);
Assert.Equal (new Rectangle (3, 3, 10, 1), view.Frame);
- Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle);
Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect);
top.Draw ();
@@ -347,7 +346,6 @@ At 0,0
view.Frame = new Rectangle (1, 1, 10, 1);
Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame);
- Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle);
Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect);
top.Draw ();
@@ -654,7 +652,6 @@ At 0,0
view.Frame = new Rectangle (1, 1, 10, 1);
Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame);
- Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle);
Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect);
view.Draw ();
@@ -751,7 +748,6 @@ At 0,0
Assert.True (r.Enabled);
Assert.True (r.Visible);
- Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
Assert.Equal ($"View(){r.Viewport}", r.ToString ());
Assert.False (r.CanFocus);
Assert.False (r.HasFocus);
@@ -776,7 +772,6 @@ At 0,0
// Empty Rect
r = new View { Frame = Rectangle.Empty };
Assert.NotNull (r);
- Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
Assert.Equal ($"View(){r.Viewport}", r.ToString ());
Assert.False (r.CanFocus);
Assert.False (r.HasFocus);
@@ -801,7 +796,6 @@ At 0,0
// Rect with values
r = new View { Frame = new Rectangle (1, 2, 3, 4) };
Assert.NotNull (r);
- Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
Assert.Equal ($"View(){r.Frame}", r.ToString ());
Assert.False (r.CanFocus);
Assert.False (r.HasFocus);
@@ -832,7 +826,6 @@ At 0,0
Height = Dim.Auto ()
}; // BUGBUG: AutoSize or Height need be set
Assert.NotNull (r);
- Assert.Equal (LayoutStyle.Computed, r.LayoutStyle);
// BUGBUG: IsInitialized must be true to process calculation
r.BeginInit ();
diff --git a/UnitTests/Views/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs
index 2e1b2ae2e..e41bc082d 100644
--- a/UnitTests/Views/ScrollViewTests.cs
+++ b/UnitTests/Views/ScrollViewTests.cs
@@ -341,7 +341,6 @@ public class ScrollViewTests
public void Constructors_Defaults ()
{
var sv = new ScrollView ();
- Assert.Equal (LayoutStyle.Absolute, sv.LayoutStyle);
Assert.True (sv.CanFocus);
Assert.Equal (new Rectangle (0, 0, 0, 0), sv.Frame);
Assert.Equal (Rectangle.Empty, sv.Frame);
@@ -351,7 +350,6 @@ public class ScrollViewTests
Assert.True (sv.KeepContentAlwaysInViewport);
sv = new ScrollView { X = 1, Y = 2, Width = 20, Height = 10 };
- Assert.Equal (LayoutStyle.Absolute, sv.LayoutStyle);
Assert.True (sv.CanFocus);
Assert.Equal (new Rectangle (1, 2, 20, 10), sv.Frame);
Assert.Equal (Point.Empty, sv.ContentOffset);
diff --git a/UnitTests/Views/WindowTests.cs b/UnitTests/Views/WindowTests.cs
index e3c39fa12..eeae82a90 100644
--- a/UnitTests/Views/WindowTests.cs
+++ b/UnitTests/Views/WindowTests.cs
@@ -130,7 +130,6 @@ public class WindowTests
Assert.Equal (string.Empty, defaultWindow.Title);
// Toplevels have Width/Height set to Dim.Fill
- Assert.Equal (LayoutStyle.Computed, defaultWindow.LayoutStyle);
// If there's no SuperView, Top, or Driver, the default Fill width is int.MaxValue
Assert.Equal ($"Window(){defaultWindow.Frame}", defaultWindow.ToString ());
@@ -156,17 +155,6 @@ public class WindowTests
using var windowWithFrameRectEmpty = new Window { Frame = Rectangle.Empty, Title = "title" };
Assert.NotNull (windowWithFrameRectEmpty);
Assert.Equal ("title", windowWithFrameRectEmpty.Title);
- Assert.Equal (LayoutStyle.Absolute, windowWithFrameRectEmpty.LayoutStyle);
- Assert.Equal ("title", windowWithFrameRectEmpty.Title);
- Assert.Equal (LayoutStyle.Absolute, windowWithFrameRectEmpty.LayoutStyle);
- // TODO: Fix things so that this works in release and debug
- // BUG: This also looks like it might be unintended behavior.
- // Can actually also be removed, since the tests below make it redundant.
- #if DEBUG
- Assert.Equal ($"Window(title){windowWithFrameRectEmpty.Frame}", windowWithFrameRectEmpty.ToString ());
- #else
- Assert.Equal ($"Window(){windowWithFrameRectEmpty.Frame}", windowWithFrameRectEmpty.ToString ());
- #endif
Assert.True (windowWithFrameRectEmpty.CanFocus);
Assert.False (windowWithFrameRectEmpty.HasFocus);
Assert.Equal (Rectangle.Empty, windowWithFrameRectEmpty.Viewport);
@@ -193,8 +181,6 @@ public class WindowTests
windowWithFrame1234.Title = "title";
Assert.Equal ("title", windowWithFrame1234.Title);
Assert.NotNull (windowWithFrame1234);
- Assert.Equal (LayoutStyle.Absolute, windowWithFrame1234.LayoutStyle);
- Assert.Equal (LayoutStyle.Absolute, windowWithFrame1234.LayoutStyle);
#if DEBUG
Assert.Equal ($"Window(title){windowWithFrame1234.Frame}", windowWithFrame1234.ToString ());
#else
diff --git a/docfx/docs/View.md b/docfx/docs/View.md
index f697261c9..ca1c733a2 100644
--- a/docfx/docs/View.md
+++ b/docfx/docs/View.md
@@ -29,7 +29,7 @@ This covers my thinking on how we will refactor `View` and the classes in the `V
* *Parent View* - A view that holds a reference to another view in a parent/child relationship, but is NOT a SuperView of the child.
* *Thickness* - A class describing a rectangle where each of the four sides can have a width. Valid width values are >= 0. The inner area of a Thickness is the sum of the widths of the four sides minus the size of the rectangle. The `Thickness` class has a `Draw` method that clears the rectangle.
* *Frame Class* - A `Frame` is a special form of `View` that appears outside of a normal `View`'s content area. Examples of `Frame`s are `Margin`, `Border`, and `Padding`. The `Frame` class is derived from `View` and uses a `Thickness` to hold the rectangle.
- * *Frame* - The `Rect` that defines the location and size of the `View` including all of the margin, border, adornments, padding, and content area. The coordinates are relative to the SuperView of the View (or, in the case of `Application.Top`, `ConsoleDriver.Row == 0; ConsoleDriver.Col == 0`). The Frame's location and size are controlled by either `Absolute` or `Computed` positioning via the `.X`, `.Y`, `.Height`, and `.Width` properties of the View.
+ * *Frame* - The `Rect` that defines the location and size of the `View` including all of the margin, border, adornments, padding, and content area. The coordinates are relative to the SuperView of the View (or, in the case of `Application.Top`, `ConsoleDriver.Row == 0; ConsoleDriver.Col == 0`). The Frame's location and size are controlled by the `.X`, `.Y`, `.Height`, and `.Width` properties of the View.
* In v2, `View.Frame.Size` is the size of the `View`'s `ContentArea` plus the `Thickness` of the `View`'s `Margin`, `Border`, and `Padding`.
* *Margin* - The `Frame` that separates a View from other SubViews of the same SuperView. The Margin is not part of the View's content and is not clipped by the View's `ClipArea`. By default `Margin` is `{0,0,0,0}`. `Margin` can be used instead of (or with) `Dim.Pos` to position a View relative to another View.
Eg.
diff --git a/docfx/docs/index.md b/docfx/docs/index.md
index 9ec7499d9..260033ea4 100644
--- a/docfx/docs/index.md
+++ b/docfx/docs/index.md
@@ -8,7 +8,7 @@
* **[Templates](getting-started.md)** - The `dotnet new` command can be used to create a new Terminal.Gui app.
* **[Keyboard](keyboard.md) and [Mouse](mouse.md) Input** - The library handles all the details of input processing and provides a simple event-based API for applications to consume.
* **[Extensible Widgets](https://gui-cs.github.io/Terminal.GuiV2Docs/api/Terminal.Gui.View.html)** - All visible UI elements are subclasses of the `View` class, and these in turn can contain an arbitrary number of sub-views. Dozens of [Built-in Views](views.md) are provided.
-* **[Flexible Layout](layout.md)** - *Computed Layout* makes it easy to lay out controls relative to each other and enables dynamic terminal UIs. *Absolute Layout* allows for precise control over the position and size of controls.
+* **[Powerful Layout Engine](layout.md)** - The layout engine makes it easy to lay out controls relative to each other and enables dynamic terminal UIs.
* **[Clipboard support](https://gui-cs.github.io/Terminal.GuiV2Docs/api/Terminal.Gui.Clipboard.html)** - Cut, Copy, and Paste is provided through the [`Clipboard`] class.
* **Multi-tasking** - The [Mainloop](https://gui-cs.github.io/Terminal.GuiV2Docs/api/Terminal.Gui.MainLoop.html) supports processing events, idle handlers, and timers. Most classes are safe for threading.
* **[Reactive Extensions](https://github.com/dotnet/reactive)** - Use reactive extensions and benefit from increased code readability, and the ability to apply the MVVM pattern and [ReactiveUI](https://www.reactiveui.net/) data bindings. See the [source code](https://github.com/gui-cs/Terminal.GuiV2Docs/tree/master/ReactiveExample) of a sample app.
diff --git a/docfx/docs/layout.md b/docfx/docs/layout.md
index 56c94b5d9..701584720 100644
--- a/docfx/docs/layout.md
+++ b/docfx/docs/layout.md
@@ -54,8 +54,6 @@ var label2 = new Label () {
The `Frame` property is a rectangle that provides the current location and size of the view relative to the View's `Superview`'s Content area.
-The `View.LayoutStyle` property can be used to determine how the View is treated. If the style is `Absolute`, the `X`, `Y`, `Width`, and `Height` objects are all absolute values. If the style is `Computed`, one or more of the `X`, `Y`, `Width`, and `Height` objects describe a computed value.
-
## The `Pos` Type
The [Pos](~/api/Terminal.Gui.Pos.yml) is the type of `View.X` and `View.Y` and supports the following sub-types:
diff --git a/docfx/docs/migratingfromv1.md b/docfx/docs/migratingfromv1.md
index 9e476aa36..f23da3039 100644
--- a/docfx/docs/migratingfromv1.md
+++ b/docfx/docs/migratingfromv1.md
@@ -37,7 +37,6 @@ Static class `Attribute.Make` has been removed. Use constructor instead
+ var c = Color.Yellow;
```
-
## Low-Level Type Changes
* `Rect` -> `Rectangle`
@@ -115,6 +114,7 @@ In v1, [Application.Init](~/api/Terminal.Gui./Terminal.Gui.Application.Init) aut
In v2, the layout system has been improved to make it easier to create complex user interfaces. If you are using custom layouts in your application, you may need to update them to use the new layout system.
+* The distinction between `Absoulte Layout` and `Computed Layout` has been removed, as has the `LayoutStyle` enum. v1 drew a false distinction between these styles.
* [View.Frame](~/api/Terminal.Gui.View.Frame.yml) now represents the position and size of the view in the superview's coordinate system. The `Frame` property is of type `Rectangle`.
* [View.Bounds](~/api/Terminal.Gui.View.Bounds.yml) has been replaced by [View.Viewport](~/api/Terminal.Gui.View.Viewport.yml). The `Viewport` property represents the visible area of the view in its own coordinate system. The `Viewport` property is of type `Rectangle`.
* [View.ContentSize](~/api/Terminal.Gui.View.ContentSize.yml) represents the size of the view's content. The `ContentSize` property is of type `Size`. This replaces `ScrollView` and `ScrollBarView` in v1. See more below.
@@ -123,6 +123,7 @@ In v2, the layout system has been improved to make it easier to create complex u
### `Bounds` -> `Viewport`
+* Remove all references ot `LayoutStyle`.
* Rename `Bounds` to `Viewport`. The `Location` property of `Bounds` can now have non-zero values.
* Update any code that assumed `Bounds.Location` was always `Point.Empty`.
* Update any code that used `Bounds` to refer to the size of the view's content. Use `ContentSize` instead.