From f82c6cb9e1e999d9c89c43fad2fc9a9ba095d054 Mon Sep 17 00:00:00 2001 From: Recrown Date: Fri, 12 Apr 2019 21:46:12 -0500 Subject: [PATCH] more progress on scroll system. --- .../UI/Modular/Modules/UIScrollable.cs | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs b/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs index 2bbbb85..ecd64ed 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs @@ -45,12 +45,9 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// The minimum bar length for the scroll bar. /// public int minimumBarLength = 16; - /// - /// The thickness of the scroll bars. - /// - int horizontalBarThickness = 8, verticalBarThickness = 8; - public int HorizontalBarThickness { get { return horizontalBarThickness; } set { horizontalBarThickness = value; HeightOrYChange(); } } - public int VerticalBarThickness { get { return verticalBarThickness; } set { verticalBarThickness = value; WidthOrXChange(); } } + + public int HorizontalBarThickness { get { return horizontalScrollBarBounds.Height; } set { horizontalScrollBarBounds.Height = value; HeightOrYChange(); } } + public int VerticalBarThickness { get { return verticalScrollBarBounds.Width; } set { verticalScrollBarBounds.Width = value; WidthOrXChange(); } } /// /// Whether or not to hide scroll bars. @@ -135,15 +132,15 @@ namespace RecrownedAthenaeum.UI.Modular.Modules this.background = background; group = new UIModuleGroup(new BasicScissor()); - HeightOrYChange(); - WidthOrXChange(); + HorizontalBarThickness = 12; + VerticalBarThickness = 12; } - public UIScrollable(ISkin skin, string definition = null) : - this(skin.GetTextureAtlasRegion(skin.ObtainDefinition().horizontalBar, true), - skin.GetTextureAtlasRegion(skin.ObtainDefinition().verticalBar, true), - skin.GetTextureAtlasRegion(skin.ObtainDefinition().horizontalBarTrack), - skin.GetTextureAtlasRegion(skin.ObtainDefinition().verticalBarTrack), + public UIScrollable(ISkin skin, string definition = null) : + this(skin.GetTextureAtlasRegion(skin.ObtainDefinition().horizontalBar, true), + skin.GetTextureAtlasRegion(skin.ObtainDefinition().verticalBar, true), + skin.GetTextureAtlasRegion(skin.ObtainDefinition().horizontalBarTrack), + skin.GetTextureAtlasRegion(skin.ObtainDefinition().verticalBarTrack), skin.GetTextureAtlasRegion(skin.ObtainDefinition().background)) { } @@ -275,12 +272,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules if (!hideScrollBars) { - if (verticalBarLeftPosition) + verticalScrollBarBounds.X = X; + if (!verticalBarLeftPosition) { - group.X += verticalBarThickness; - group.Width -= verticalBarThickness; + verticalScrollBarBounds.X += group.Width; } - group.Height -= verticalBarThickness; + group.Width -= VerticalBarThickness; } } } @@ -301,12 +298,16 @@ namespace RecrownedAthenaeum.UI.Modular.Modules if (!hideScrollBars) { + horizontalScrollBarBounds.Y = Y; + group.Height -= HorizontalBarThickness; if (!horizontalBarTopPosition) { - group.Y += horizontalBarThickness; - group.Height -= horizontalBarThickness; + horizontalScrollBarBounds.Y += group.Height; + } + else + { + group.Y += horizontalScrollBarBounds.Height; } - group.Height -= horizontalBarThickness; } } }