From f14441d2f4dc9acf1f5a8b3fb28030db6dec5133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 29 Apr 2013 09:39:46 +0200 Subject: [PATCH] added MinimumThumbSize to ScrollPanelWidget closes #2865 --- OpenRA.Game/Widgets/ScrollPanelWidget.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Widgets/ScrollPanelWidget.cs b/OpenRA.Game/Widgets/ScrollPanelWidget.cs index b227547bb2..b88c15b112 100644 --- a/OpenRA.Game/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Game/Widgets/ScrollPanelWidget.cs @@ -26,6 +26,7 @@ namespace OpenRA.Widgets public string Background = "scrollpanel-bg"; public int ContentHeight = 0; public ILayout Layout; + public int MinimumThumbSize = 10; protected float ListOffset = 0; protected bool UpPressed = false; protected bool DownPressed = false; @@ -79,7 +80,7 @@ namespace OpenRA.Widgets var ScrollbarHeight = rb.Height - 2 * ScrollbarWidth; - var thumbHeight = ContentHeight == 0 ? 0 : (int)(ScrollbarHeight*Math.Min(rb.Height*1f/ContentHeight, 1f)); + var thumbHeight = ContentHeight == 0 ? 0 : Math.Max(MinimumThumbSize, (int)(ScrollbarHeight*Math.Min(rb.Height*1f/ContentHeight, 1f))); var thumbOrigin = rb.Y + ScrollbarWidth + (int)((ScrollbarHeight - thumbHeight)*(-1f*ListOffset/(ContentHeight - rb.Height))); if (thumbHeight == ScrollbarHeight) thumbHeight = 0; @@ -206,7 +207,7 @@ namespace OpenRA.Widgets { var rb = RenderBounds; var ScrollbarHeight = rb.Height - 2 * ScrollbarWidth; - var thumbHeight = ContentHeight == 0 ? 0 : (int)(ScrollbarHeight*Math.Min(rb.Height*1f/ContentHeight, 1f)); + var thumbHeight = ContentHeight == 0 ? 0 : Math.Max(MinimumThumbSize, (int)(ScrollbarHeight*Math.Min(rb.Height*1f/ContentHeight, 1f))); var oldOffset = ListOffset; ListOffset += (int)((lastMouseLocation.Y - mi.Location.Y)*(ContentHeight - rb.Height)*1f/(ScrollbarHeight - thumbHeight)); ListOffset = Math.Min(0,Math.Max(rb.Height - ContentHeight, ListOffset));