mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 01:39:23 +01:00
added a style property for a panel's scroll bar offset
This commit is contained in:
parent
4e3d5705a4
commit
1fa9204680
2 changed files with 12 additions and 3 deletions
|
@ -43,6 +43,10 @@ namespace MLEM.Ui.Elements {
|
|||
/// The scroller size's height specified here is the minimum height, otherwise, it is automatically calculated based on panel content.
|
||||
/// </summary>
|
||||
public StyleProp<Vector2> ScrollerSize;
|
||||
/// <summary>
|
||||
/// The amount of pixels of room there should be between the <see cref="ScrollBar"/> and the rest of the content
|
||||
/// </summary>
|
||||
public StyleProp<float> ScrollBarOffset;
|
||||
|
||||
private readonly List<Element> relevantChildren = new List<Element>();
|
||||
private readonly bool scrollOverflow;
|
||||
|
@ -74,7 +78,7 @@ namespace MLEM.Ui.Elements {
|
|||
};
|
||||
if (autoHideScrollbar) {
|
||||
this.ScrollBar.OnAutoHide += e => {
|
||||
this.ChildPadding += new Padding(0, this.ScrollerSize.Value.X, 0, 0) * (e.IsHidden ? -1 : 1);
|
||||
this.ChildPadding += new Padding(0, this.ScrollerSize.Value.X + this.ScrollBarOffset, 0, 0) * (e.IsHidden ? -1 : 1);
|
||||
this.SetAreaDirty();
|
||||
};
|
||||
}
|
||||
|
@ -209,6 +213,7 @@ namespace MLEM.Ui.Elements {
|
|||
this.StepPerScroll.SetFromStyle(style.PanelStepPerScroll);
|
||||
this.ScrollerSize.SetFromStyle(style.PanelScrollerSize);
|
||||
this.ChildPadding.SetFromStyle(style.PanelChildPadding);
|
||||
this.ScrollBarOffset.SetFromStyle(style.PanelScrollBarOffset);
|
||||
this.SetScrollBarStyle();
|
||||
}
|
||||
|
||||
|
@ -264,7 +269,7 @@ namespace MLEM.Ui.Elements {
|
|||
return;
|
||||
this.ScrollBar.StepPerScroll = this.StepPerScroll;
|
||||
this.ScrollBar.Size = new Vector2(this.ScrollerSize.Value.X, 1);
|
||||
this.ScrollBar.PositionOffset = new Vector2(-this.ScrollerSize.Value.X - 1, 0);
|
||||
this.ScrollBar.PositionOffset = new Vector2(-this.ScrollerSize.Value.X - this.ScrollBarOffset, 0);
|
||||
}
|
||||
|
||||
private void ForceUpdateRelevantChildren() {
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace MLEM.Ui.Style {
|
|||
/// <summary>
|
||||
/// The style settings for a <see cref="UiSystem"/>.
|
||||
/// Each <see cref="Element"/> uses these style settings by default, however you can also change these settings per element using the elements' individual style settings.
|
||||
/// Note that this class is a <see cref="GenericDataHolder"/>, meaning additional styles for custom components can easily be added using <see cref="GenericDataHolder.SetData{T}"/>
|
||||
/// Note that this class is a <see cref="GenericDataHolder"/>, meaning additional styles for custom components can easily be added using <see cref="GenericDataHolder.SetData"/>
|
||||
/// </summary>
|
||||
public class UiStyle : GenericDataHolder {
|
||||
|
||||
|
@ -57,6 +57,10 @@ namespace MLEM.Ui.Style {
|
|||
/// </summary>
|
||||
public Vector2 PanelScrollerSize = new Vector2(5, 10);
|
||||
/// <summary>
|
||||
/// The amount of pixels of room there should be between a <see cref="Panel"/>'s scroll bar and the rest of its content
|
||||
/// </summary>
|
||||
public float PanelScrollBarOffset = 1;
|
||||
/// <summary>
|
||||
/// The texture that the <see cref="TextField"/> element uses
|
||||
/// </summary>
|
||||
public NinePatch TextFieldTexture;
|
||||
|
|
Loading…
Reference in a new issue