|
@@ -412,6 +412,10 @@ namespace Terminal.Gui {
|
|
|
public Pos X {
|
|
|
get => x;
|
|
|
set {
|
|
|
+ if (!ValidatePosDim (x, value)) {
|
|
|
+ throw new ArgumentException ();
|
|
|
+ }
|
|
|
+
|
|
|
x = value;
|
|
|
SetNeedsLayout ();
|
|
|
SetNeedsDisplay (frame);
|
|
@@ -428,6 +432,10 @@ namespace Terminal.Gui {
|
|
|
public Pos Y {
|
|
|
get => y;
|
|
|
set {
|
|
|
+ if (!ValidatePosDim (y, value)) {
|
|
|
+ throw new ArgumentException ();
|
|
|
+ }
|
|
|
+
|
|
|
y = value;
|
|
|
SetNeedsLayout ();
|
|
|
SetNeedsDisplay (frame);
|
|
@@ -446,6 +454,10 @@ namespace Terminal.Gui {
|
|
|
public Dim Width {
|
|
|
get => width;
|
|
|
set {
|
|
|
+ if (!ValidatePosDim (width, value)) {
|
|
|
+ throw new ArgumentException ();
|
|
|
+ }
|
|
|
+
|
|
|
width = value;
|
|
|
SetNeedsLayout ();
|
|
|
SetNeedsDisplay (frame);
|
|
@@ -460,12 +472,29 @@ namespace Terminal.Gui {
|
|
|
public Dim Height {
|
|
|
get => height;
|
|
|
set {
|
|
|
+ if (!ValidatePosDim (height, value)) {
|
|
|
+ throw new ArgumentException ();
|
|
|
+ }
|
|
|
+
|
|
|
height = value;
|
|
|
SetNeedsLayout ();
|
|
|
SetNeedsDisplay (frame);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ bool ValidatePosDim (object oldvalue, object newValue)
|
|
|
+ {
|
|
|
+ if (!IsInitialized || layoutStyle == LayoutStyle.Absolute || oldvalue == null || oldvalue.GetType () == newValue.GetType () || this is Toplevel) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (layoutStyle == LayoutStyle.Computed) {
|
|
|
+ if (oldvalue.GetType () != newValue.GetType () && !(newValue is Pos.PosAbsolute || newValue is Dim.DimAbsolute)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Returns the container for this view, or null if this view has not been added to a container.
|
|
|
/// </summary>
|