Progress on scroll panel.

This commit is contained in:
Harrison Deng 2019-04-11 00:51:26 -05:00
parent d5c898d081
commit 91e005ea00
2 changed files with 15 additions and 5 deletions

View File

@ -48,7 +48,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// <summary> /// <summary>
/// The thickness of the scroll bars. /// The thickness of the scroll bars.
/// </summary> /// </summary>
int horizontalBarThickness, verticalBarThickness; int horizontalBarThickness = 8, verticalBarThickness = 8;
public int HorizontalBarThickness { get { return horizontalBarThickness; } set { horizontalBarThickness = value; HeightOrYChange(); } } public int HorizontalBarThickness { get { return horizontalBarThickness; } set { horizontalBarThickness = value; HeightOrYChange(); } }
public int VerticalBarThickness { get { return verticalBarThickness; } set { verticalBarThickness = value; WidthOrXChange(); } } public int VerticalBarThickness { get { return verticalBarThickness; } set { verticalBarThickness = value; WidthOrXChange(); } }
@ -135,9 +135,11 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
this.background = background; this.background = background;
group = new UIModuleGroup(new BasicScissor()); group = new UIModuleGroup(new BasicScissor());
HeightOrYChange();
WidthOrXChange();
} }
public UIScrollable(ISkin skin, string definition) : public UIScrollable(ISkin skin, string definition = null) :
this(skin.GetTextureAtlasRegion(skin.ObtainDefinition<UIScrollableSkinDefinition>().horizontalBar, true), this(skin.GetTextureAtlasRegion(skin.ObtainDefinition<UIScrollableSkinDefinition>().horizontalBar, true),
skin.GetTextureAtlasRegion(skin.ObtainDefinition<UIScrollableSkinDefinition>().verticalBar, true), skin.GetTextureAtlasRegion(skin.ObtainDefinition<UIScrollableSkinDefinition>().verticalBar, true),
skin.GetTextureAtlasRegion(skin.ObtainDefinition<UIScrollableSkinDefinition>().horizontalBarTrack), skin.GetTextureAtlasRegion(skin.ObtainDefinition<UIScrollableSkinDefinition>().horizontalBarTrack),
@ -178,7 +180,10 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
public override void Draw(ConsistentSpriteBatch spriteBatch) public override void Draw(ConsistentSpriteBatch spriteBatch)
{ {
background.Draw(spriteBatch, Boundaries, color, origin: origin); background?.Draw(spriteBatch, Boundaries, color, origin: origin);
group.Draw(spriteBatch);
if (horScrollAvailable) if (horScrollAvailable)
{ {
horizontalScrollBar.Draw(spriteBatch, horizontalScrollBarBounds, color); horizontalScrollBar.Draw(spriteBatch, horizontalScrollBarBounds, color);
@ -210,6 +215,9 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
furthestY = mFurthestY; furthestY = mFurthestY;
} }
} }
WidthOrXChange();
HeightOrYChange();
} }
public void RemoveModule(UIModule module) public void RemoveModule(UIModule module)
@ -285,7 +293,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
group.Height = Height - bottomPadding - topPadding; group.Height = Height - bottomPadding - topPadding;
if (Height < furthestY) if (Height < furthestY)
{ {
horScrollAvailable = true; vertScrollAvailable = true;
verticalScrollBarBounds.Height = (int)(Height * ((float)Height / furthestY)); verticalScrollBarBounds.Height = (int)(Height * ((float)Height / furthestY));
verticalScrollBarBounds.Height = Math.Max(verticalScrollBarBounds.Height, minimumBarLength); verticalScrollBarBounds.Height = Math.Max(verticalScrollBarBounds.Height, minimumBarLength);
} }

View File

@ -1,4 +1,5 @@
using System; using RecrownedAthenaeum.UI.Modular.Modules;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -25,6 +26,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
{ {
this.horizontalBar = horizontalBar; this.horizontalBar = horizontalBar;
this.verticalBar = verticalBar; this.verticalBar = verticalBar;
UIModuleType = typeof(UIScrollable);
} }
} }
} }