From ec82e6fe687ba1e302ffcf68cb8ea50ddf134407 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 7 May 2011 11:57:31 +1200 Subject: [PATCH] make ScrollPanelWidget mouse interaction cheaper --- OpenRA.Game/Widgets/ScrollPanelWidget.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Widgets/ScrollPanelWidget.cs b/OpenRA.Game/Widgets/ScrollPanelWidget.cs index 93d383ece7..a98188c69f 100644 --- a/OpenRA.Game/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Game/Widgets/ScrollPanelWidget.cs @@ -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;