mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
added TreatSizeAsMaximum to ui elements
This commit is contained in:
parent
705758090b
commit
1377941f1a
1 changed files with 12 additions and 3 deletions
|
@ -257,12 +257,12 @@ namespace MLEM.Ui.Elements {
|
||||||
public bool CanAutoAnchorsAttach = true;
|
public bool CanAutoAnchorsAttach = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this field to true to cause this element's width to be automatically calculated based on the area that its <see cref="Children"/> take up.
|
/// Set this field to true to cause this element's width to be automatically calculated based on the area that its <see cref="Children"/> take up.
|
||||||
/// To use this element's <see cref="Size"/>'s X coordinate as a minimum width rather than ignoring it, set <see cref="TreatSizeAsMinimum"/> to true.
|
/// To use this element's <see cref="Size"/>'s X coordinate as a minimum or maximum width rather than ignoring it, set <see cref="TreatSizeAsMinimum"/> or <see cref="TreatSizeAsMaximum"/> to true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SetWidthBasedOnChildren;
|
public bool SetWidthBasedOnChildren;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this field to true to cause this element's height to be automatically calculated based on the area that its <see cref="Children"/> take up.
|
/// Set this field to true to cause this element's height to be automatically calculated based on the area that its <see cref="Children"/> take up.
|
||||||
/// To use this element's <see cref="Size"/>'s Y coordinate as a minimum height rather than ignoring it, set <see cref="TreatSizeAsMinimum"/> to true.
|
/// To use this element's <see cref="Size"/>'s Y coordinate as a minimum or maximum height rather than ignoring it, set <see cref="TreatSizeAsMinimum"/> or <see cref="TreatSizeAsMaximum"/> to true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SetHeightBasedOnChildren;
|
public bool SetHeightBasedOnChildren;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -272,6 +272,11 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool TreatSizeAsMinimum;
|
public bool TreatSizeAsMinimum;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// If this field is set to true, and <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/>are enabled, the resulting width or height weill always be less than or equal to this element's <see cref="Size"/>.
|
||||||
|
/// Note that this value only has an effect if <see cref="SetWidthBasedOnChildren"/> or <see cref="SetHeightBasedOnChildren"/> are enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool TreatSizeAsMaximum;
|
||||||
|
/// <summary>
|
||||||
/// Set this field to true to cause this element's final display area to never exceed that of its <see cref="Parent"/>.
|
/// Set this field to true to cause this element's final display area to never exceed that of its <see cref="Parent"/>.
|
||||||
/// If the resulting area is too large, the size of this element is shrunk to fit the target area.
|
/// If the resulting area is too large, the size of this element is shrunk to fit the target area.
|
||||||
/// This can be useful if an element should fill the remaining area of a parent exactly.
|
/// This can be useful if an element should fill the remaining area of a parent exactly.
|
||||||
|
@ -661,8 +666,12 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.TreatSizeAsMinimum)
|
if (this.TreatSizeAsMinimum) {
|
||||||
autoSize = Vector2.Max(autoSize, actualSize);
|
autoSize = Vector2.Max(autoSize, actualSize);
|
||||||
|
} else if (this.TreatSizeAsMaximum) {
|
||||||
|
autoSize = Vector2.Min(autoSize, actualSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (!autoSize.Equals(this.UnscrolledArea.Size, 0.01F)) {
|
if (!autoSize.Equals(this.UnscrolledArea.Size, 0.01F)) {
|
||||||
recursion++;
|
recursion++;
|
||||||
if (recursion >= 16) {
|
if (recursion >= 16) {
|
||||||
|
|
Loading…
Reference in a new issue