Fix and simplify ScrollPanelWidget thumb rect calculation.
This commit is contained in:
@@ -146,13 +146,16 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
UpdateSmoothScrolling();
|
||||
|
||||
var rb = RenderBounds;
|
||||
|
||||
var scrollbarHeight = rb.Height - 2 * ScrollbarWidth;
|
||||
|
||||
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 * currentListOffset / (ContentHeight - rb.Height)));
|
||||
if (thumbHeight == scrollbarHeight)
|
||||
thumbHeight = 0;
|
||||
// Scroll thumb is only visible if the content does not fit within the panel bounds
|
||||
var thumbHeight = 0;
|
||||
var thumbOrigin = rb.Y + ScrollbarWidth;
|
||||
if (ContentHeight > rb.Height)
|
||||
{
|
||||
thumbHeight = Math.Max(MinimumThumbSize, scrollbarHeight * rb.Height / ContentHeight);
|
||||
thumbOrigin += (int)((scrollbarHeight - thumbHeight) * currentListOffset / (rb.Height - ContentHeight));
|
||||
}
|
||||
|
||||
switch (ScrollBar)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user