added MinimumThumbSize to ScrollPanelWidget

closes #2865
This commit is contained in:
Matthias Mailänder
2013-04-29 09:39:46 +02:00
parent 2762c245ee
commit f14441d2f4

View File

@@ -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));