make ScrollPanelWidget mouse interaction cheaper

This commit is contained in:
Chris Forbes
2011-05-07 11:57:31 +12:00
committed by Paul Chote
parent 0c9a1a03ce
commit ec82e6fe68

View File

@@ -160,11 +160,12 @@ namespace OpenRA.Widgets
if (ThumbPressed && mi.Event == MouseInputEvent.Move)
{
var ScrollbarHeight = RenderBounds.Height - 2 * ScrollbarWidth;
var thumbHeight = ContentHeight == 0 ? 0 : (int)(ScrollbarHeight*Math.Min(RenderBounds.Height*1f/ContentHeight, 1f));
var rb = RenderBounds;
var ScrollbarHeight = rb.Height - 2 * ScrollbarWidth;
var thumbHeight = ContentHeight == 0 ? 0 : (int)(ScrollbarHeight*Math.Min(rb.Height*1f/ContentHeight, 1f));
var oldOffset = ListOffset;
ListOffset += (int)((lastMouseLocation.Y - mi.Location.Y)*(ContentHeight - RenderBounds.Height)*1f/(ScrollbarHeight - thumbHeight));
ListOffset = Math.Min(0,Math.Max(RenderBounds.Height - ContentHeight, ListOffset));
ListOffset += (int)((lastMouseLocation.Y - mi.Location.Y)*(ContentHeight - rb.Height)*1f/(ScrollbarHeight - thumbHeight));
ListOffset = Math.Min(0,Math.Max(rb.Height - ContentHeight, ListOffset));
if (oldOffset != ListOffset)
lastMouseLocation = mi.Location;