mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 01:38:01 +01:00
Add equality comparison support for most common Dims (#278)
Specifically factor, fill and absolute now support making comparisons.
This commit is contained in:
committed by
Miguel de Icaza
parent
62f5a96553
commit
369e305871
@@ -311,6 +311,11 @@ namespace Terminal.Gui {
|
||||
{
|
||||
return $"Dim.Factor({factor})";
|
||||
}
|
||||
|
||||
public override int GetHashCode () => factor.GetHashCode();
|
||||
|
||||
public override bool Equals (object other) => other is DimFactor f && f.factor == factor;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -339,6 +344,11 @@ namespace Terminal.Gui {
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
public override int GetHashCode () => n.GetHashCode();
|
||||
|
||||
public override bool Equals (object other) => other is DimAbsolute abs && abs.n == n;
|
||||
|
||||
}
|
||||
|
||||
class DimFill : Dim {
|
||||
@@ -353,7 +363,11 @@ namespace Terminal.Gui {
|
||||
internal override int Anchor (int width)
|
||||
{
|
||||
return width-margin;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode () => margin.GetHashCode();
|
||||
|
||||
public override bool Equals (object other) => other is DimFill fill && fill.margin == margin;
|
||||
}
|
||||
|
||||
static DimFill zeroMargin;
|
||||
|
||||
Reference in New Issue
Block a user