1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-06-25 06:10:03 +02:00

some panel improvements

- Added Panel.ScrollToTop and Panel.ScrollToBottom
- Fixed Panel.ScrollToElement not scrolling correctly when the panel's area is dirty
This commit is contained in:
Ell 2024-06-14 22:31:32 +02:00
parent 3a055129b5
commit bcc558f591
2 changed files with 19 additions and 0 deletions

View file

@ -28,6 +28,7 @@ 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 display tooltips using the auto-nav style even when using the mouse
- Added the ScissorGroup element, which applies a scissor rectangle when drawing its content
- Added Panel.ScrollToTop and Panel.ScrollToBottom
Improvements
- **Include the SpriteBatchContext in OnDrawn, OnElementDrawn and OnSelectedElementDrawn**
@ -39,6 +40,7 @@ Fixes
- Fixed hidden scroll bars inhibiting scrolling on their parent panel
- Fixed scroll bars doing unnecessary calculations when hidden
- Fixed auto-sized elements sometimes updating their location based on outdated parent positions
- Fixed Panel.ScrollToElement not scrolling correctly when the panel's area is dirty
## 6.3.1

View file

@ -236,9 +236,26 @@ namespace MLEM.Ui.Elements {
var highestValidChild = this.Children.FirstOrDefault(c => c != this.ScrollBar && !c.IsHidden);
if (highestValidChild == null)
return;
this.UpdateAreaIfDirty();
this.ScrollBar.CurrentValue = (elementY - this.Area.Height / 2 - highestValidChild.Area.Top) / this.Scale + this.ChildPadding.Value.Height / 2;
}
/// <summary>
/// Scrolls this panel's <see cref="ScrollBar"/> to the top, causing the top of this panel to be shown.
/// </summary>
public void ScrollToTop() {
this.UpdateAreaIfDirty();
this.ScrollBar.CurrentValue = 0;
}
/// <summary>
/// Scrolls this panel's <see cref="ScrollBar"/> to the bottom, causing the bottom of this panel to be shown.
/// </summary>
public void ScrollToBottom() {
this.UpdateAreaIfDirty();
this.ScrollBar.CurrentValue = this.ScrollBar.MaxValue;
}
/// <inheritdoc />
protected override void InitStyle(UiStyle style) {
base.InitStyle(style);