1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-28 15:28:34 +01:00

Compare commits

..

No commits in common. "ee2b0266aa65536357069a526915af4e1e89518c" and "85d20b64336da6b5a7de35b0dafd68be6d4cf88e" have entirely different histories.

4 changed files with 9 additions and 17 deletions

View file

@ -28,12 +28,6 @@ Additions
- Added the ability to set the anchor that should be used when a tooltip attaches to an element or the mouse - Added the ability to set the anchor that should be used when a tooltip attaches to an element or the mouse
- Added the ability to display tooltips using the auto-nav style even when using the mouse - Added the ability to display tooltips using the auto-nav style even when using the mouse
Improvements
- Allow scrolling panels to set height based on children by setting TreatSizeAsMaximum
Fixes
- Fixed hidden scroll bars inhibiting scrolling on their parent panel
## 6.3.1 ## 6.3.1
No code changes No code changes

View file

@ -223,15 +223,14 @@ namespace Demos {
PositionOffset = new Vector2(0, 1) PositionOffset = new Vector2(0, 1)
}); });
this.root.AddChild(new VerticalSpace(3)); var subPanel = this.root.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1, 25), Vector2.Zero, false, true) {
var dynamicSubPanel = this.root.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1, 50), Vector2.Zero, true, true) { PositionOffset = new Vector2(0, 1),
Texture = null, Texture = null,
ChildPadding = Padding.Empty ChildPadding = Padding.Empty
}); });
dynamicSubPanel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is a dynamic height nested panel with a maximum height, at which point it starts displaying a scroll bar instead!")); subPanel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is a nested scrolling panel!"));
dynamicSubPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), "Press to add more") { for (var i = 1; i <= 5; i++)
OnPressed = _ => dynamicSubPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), "I do nothing")) subPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), $"Button {i}") {PositionOffset = new Vector2(0, 1)});
});
const string alignText = "Paragraphs can have <l Left>left</l> aligned text, <l Right>right</l> aligned text and <l Center>center</l> aligned text."; const string alignText = "Paragraphs can have <l Left>left</l> aligned text, <l Right>right</l> aligned text and <l Center>center</l> aligned text.";
this.root.AddChild(new VerticalSpace(3)); this.root.AddChild(new VerticalSpace(3));

View file

@ -78,7 +78,6 @@ namespace MLEM.Ui.Elements {
public Panel(Anchor anchor, Vector2 size, Vector2 positionOffset, bool setHeightBasedOnChildren = false, bool scrollOverflow = false, bool autoHideScrollbar = true) : base(anchor, size) { public Panel(Anchor anchor, Vector2 size, Vector2 positionOffset, bool setHeightBasedOnChildren = false, bool scrollOverflow = false, bool autoHideScrollbar = true) : base(anchor, size) {
this.PositionOffset = positionOffset; this.PositionOffset = positionOffset;
this.SetHeightBasedOnChildren = setHeightBasedOnChildren; this.SetHeightBasedOnChildren = setHeightBasedOnChildren;
this.TreatSizeAsMaximum = setHeightBasedOnChildren && scrollOverflow;
this.scrollOverflow = scrollOverflow; this.scrollOverflow = scrollOverflow;
this.CanBeSelected = false; this.CanBeSelected = false;
@ -120,8 +119,8 @@ namespace MLEM.Ui.Elements {
public override void ForceUpdateArea() { public override void ForceUpdateArea() {
if (this.scrollOverflow) { if (this.scrollOverflow) {
// sanity check // sanity check
if (this.SetHeightBasedOnChildren && !this.TreatSizeAsMaximum) if (this.SetHeightBasedOnChildren)
throw new NotSupportedException("A panel can't both scroll overflow and set height based on children without a maximum"); throw new NotSupportedException("A panel can't both set height based on children and scroll overflow");
foreach (var child in this.Children) { foreach (var child in this.Children) {
if (child != this.ScrollBar && !child.Anchor.IsAuto()) if (child != this.ScrollBar && !child.Anchor.IsAuto())
throw new NotSupportedException($"A panel that handles overflow can't contain non-automatic anchors ({child})"); throw new NotSupportedException($"A panel that handles overflow can't contain non-automatic anchors ({child})");
@ -296,7 +295,7 @@ namespace MLEM.Ui.Elements {
if (this.Children.Count > 1) { if (this.Children.Count > 1) {
var highestValidChild = this.Children.FirstOrDefault(c => c != this.ScrollBar && !c.IsHidden); var highestValidChild = this.Children.FirstOrDefault(c => c != this.ScrollBar && !c.IsHidden);
var lowestChild = this.GetLowestChild(c => c != this.ScrollBar && !c.IsHidden, true); var lowestChild = this.GetLowestChild(c => c != this.ScrollBar && !c.IsHidden, true);
childrenHeight = lowestChild.GetTotalCoveredArea(true).Bottom - highestValidChild.UnscrolledArea.Top; childrenHeight = lowestChild.GetTotalCoveredArea(false).Bottom - highestValidChild.Area.Top;
} else { } else {
// if we only have one child (the scroll bar), then the children take up no visual height // if we only have one child (the scroll bar), then the children take up no visual height
childrenHeight = 0; childrenHeight = 0;

View file

@ -251,7 +251,7 @@ namespace MLEM.Ui.Elements {
var foundMe = false; var foundMe = false;
foreach (var child in this.Parent.GetChildren(regardGrandchildren: true)) { foreach (var child in this.Parent.GetChildren(regardGrandchildren: true)) {
if (foundMe) { if (foundMe) {
if (child is ScrollBar b && !b.IsHidden && !b.Horizontal && b.IsMousedForScrolling(moused)) if (child is ScrollBar b && !b.Horizontal && b.IsMousedForScrolling(moused))
return false; return false;
} else if (child == this) { } else if (child == this) {
// once we found ourselves, all subsequent children are deeper/older! // once we found ourselves, all subsequent children are deeper/older!