Scroll progress and cleanup.

This commit is contained in:
Harrison Deng 2019-05-29 22:19:17 -05:00
parent c52283295a
commit 9b05f5aedb
2 changed files with 11 additions and 7 deletions

View File

@ -19,8 +19,8 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
Rectangle viewport; Rectangle viewport;
UIModuleGroup group; UIModuleGroup group;
Color scrollBarColor; Color scrollBarColor = Color.White;
float opacityOfBar = 1; float opacityOfBar = 1f;
bool showingBars; bool showingBars;
private bool mouseWasPressed; private bool mouseWasPressed;
private bool horizontalSelected; private bool horizontalSelected;
@ -59,7 +59,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
value = Height - verticalScrollBarBounds.Height; value = Height - verticalScrollBarBounds.Height;
} }
if (value < 0) value = 0; if (value < 0) value = 0;
shiftY = -(group.Height - viewport.Height) * (value/(Height - verticalScrollBarBounds.Height)); shiftY = -(group.Height - viewport.Height) * (value / (Height - verticalScrollBarBounds.Height));
HeightOrYChange(true); HeightOrYChange(true);
} }
} }
@ -78,6 +78,10 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
ISpecialDrawable background, horizontalBarTrack, verticalBarTrack; ISpecialDrawable background, horizontalBarTrack, verticalBarTrack;
private int topPadding, bottomPadding, leftPadding, rightPadding; private int topPadding, bottomPadding, leftPadding, rightPadding;
/// <summary>
///
/// </summary>
public int PadTop { get { return topPadding; } set { topPadding = value; HeightOrYChange(); } } public int PadTop { get { return topPadding; } set { topPadding = value; HeightOrYChange(); } }
public int PadBottom { get { return bottomPadding; } set { bottomPadding = value; HeightOrYChange(); } } public int PadBottom { get { return bottomPadding; } set { bottomPadding = value; HeightOrYChange(); } }
public int PadLeft { get { return leftPadding; } set { leftPadding = value; WidthOrXChange(); } } public int PadLeft { get { return leftPadding; } set { leftPadding = value; WidthOrXChange(); } }
@ -91,6 +95,8 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
public int HorizontalBarThickness { get { return horizontalScrollBarBounds.Height; } set { horizontalScrollBarBounds.Height = value; HeightOrYChange(); } } public int HorizontalBarThickness { get { return horizontalScrollBarBounds.Height; } set { horizontalScrollBarBounds.Height = value; HeightOrYChange(); } }
public int VerticalBarThickness { get { return verticalScrollBarBounds.Width; } set { verticalScrollBarBounds.Width = value; WidthOrXChange(); } } public int VerticalBarThickness { get { return verticalScrollBarBounds.Width; } set { verticalScrollBarBounds.Width = value; WidthOrXChange(); } }
bool hideScrollBars;
/// <summary> /// <summary>
/// Whether or not to hide scroll bars. /// Whether or not to hide scroll bars.
/// </summary> /// </summary>
@ -105,11 +111,11 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
if (!value) if (!value)
{ {
opacityOfBar = 1f; opacityOfBar = 1f;
scrollBarColor = color * opacityOfBar;
} }
} }
} }
bool hideScrollBars = true;
/// <summary> /// <summary>
/// Set to true to change from the normal position to the new position. /// Set to true to change from the normal position to the new position.
@ -201,14 +207,13 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
if (opacityOfBar > 0f) if (opacityOfBar > 0f)
{ {
opacityOfBar -= (barFadeSpeed / 255f) * (float)gameTime.ElapsedGameTime.TotalSeconds; opacityOfBar -= (barFadeSpeed / 255f) * (float)gameTime.ElapsedGameTime.TotalSeconds;
scrollBarColor = color * opacityOfBar;
} }
} }
else else
{ {
opacityOfBar = 1f; opacityOfBar = 1f;
scrollBarColor = color * opacityOfBar;
} }
scrollBarColor = color * opacityOfBar;
} }
if (horScrollAvailable) if (horScrollAvailable)

View File

@ -64,7 +64,6 @@ namespace TestGame
uIScrollable = new UIScrollable(skin); uIScrollable = new UIScrollable(skin);
uIScrollable.Width = 256; uIScrollable.Width = 256;
uIScrollable.Height = 256; uIScrollable.Height = 256;
uIScrollable.HideScrollBars = true;
logoImage = new Image(logo); logoImage = new Image(logo);
uIScrollable.AddModules(logoImage); uIScrollable.AddModules(logoImage);