mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 14:38:34 +01:00
fixed up Element docs and added a return value to UpdateAreaIfDirty
This commit is contained in:
parent
f2939253b1
commit
149669df99
1 changed files with 13 additions and 6 deletions
|
@ -35,6 +35,11 @@ namespace MLEM.Ui.Elements {
|
||||||
this.Style = value?.Style;
|
this.Style = value?.Style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// This Element's current <see cref="UiStyle"/>.
|
||||||
|
/// When this value is changed, <see cref="InitStyle"/> is called.
|
||||||
|
/// Note that this value is automatically set to the <see cref="UiSystem"/>'s ui style when it is changed.
|
||||||
|
/// </summary>
|
||||||
public UiStyle Style {
|
public UiStyle Style {
|
||||||
get => this.style;
|
get => this.style;
|
||||||
set {
|
set {
|
||||||
|
@ -516,11 +521,15 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates this element's <see cref="Area"/> list if <see cref="areaDirty"/> is true.
|
/// Updates this element's <see cref="Area"/> and all of its <see cref="Children"/> by calling <see cref="ForceUpdateArea"/> if <see cref="areaDirty"/> is true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateAreaIfDirty() {
|
/// <returns>Whether <see cref="areaDirty"/> was true and <see cref="ForceUpdateArea"/> was called</returns>
|
||||||
if (this.areaDirty)
|
public bool UpdateAreaIfDirty() {
|
||||||
|
if (this.areaDirty) {
|
||||||
this.ForceUpdateArea();
|
this.ForceUpdateArea();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -533,10 +542,8 @@ namespace MLEM.Ui.Elements {
|
||||||
return;
|
return;
|
||||||
// if the parent's area is dirty, it would get updated anyway when querying its ChildPaddedArea,
|
// if the parent's area is dirty, it would get updated anyway when querying its ChildPaddedArea,
|
||||||
// which would cause our ForceUpdateArea code to be run twice, so we only update our parent instead
|
// which would cause our ForceUpdateArea code to be run twice, so we only update our parent instead
|
||||||
if (this.Parent != null && this.Parent.areaDirty) {
|
if (this.Parent != null && this.Parent.UpdateAreaIfDirty())
|
||||||
this.Parent.ForceUpdateArea();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var parentArea = this.Parent != null ? this.Parent.ChildPaddedArea : (RectangleF) this.system.Viewport;
|
var parentArea = this.Parent != null ? this.Parent.ChildPaddedArea : (RectangleF) this.system.Viewport;
|
||||||
var parentCenterX = parentArea.X + parentArea.Width / 2;
|
var parentCenterX = parentArea.X + parentArea.Width / 2;
|
||||||
|
|
Loading…
Reference in a new issue