@@ -26,6 +26,7 @@ namespace OpenRA.Widgets
|
|||||||
public string Background = "scrollpanel-bg";
|
public string Background = "scrollpanel-bg";
|
||||||
public int ContentHeight = 0;
|
public int ContentHeight = 0;
|
||||||
public ILayout Layout;
|
public ILayout Layout;
|
||||||
|
public int MinimumThumbSize = 10;
|
||||||
protected float ListOffset = 0;
|
protected float ListOffset = 0;
|
||||||
protected bool UpPressed = false;
|
protected bool UpPressed = false;
|
||||||
protected bool DownPressed = false;
|
protected bool DownPressed = false;
|
||||||
@@ -79,7 +80,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
var ScrollbarHeight = rb.Height - 2 * ScrollbarWidth;
|
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)));
|
var thumbOrigin = rb.Y + ScrollbarWidth + (int)((ScrollbarHeight - thumbHeight)*(-1f*ListOffset/(ContentHeight - rb.Height)));
|
||||||
if (thumbHeight == ScrollbarHeight)
|
if (thumbHeight == ScrollbarHeight)
|
||||||
thumbHeight = 0;
|
thumbHeight = 0;
|
||||||
@@ -206,7 +207,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
var rb = RenderBounds;
|
var rb = RenderBounds;
|
||||||
var ScrollbarHeight = rb.Height - 2 * ScrollbarWidth;
|
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;
|
var oldOffset = ListOffset;
|
||||||
ListOffset += (int)((lastMouseLocation.Y - mi.Location.Y)*(ContentHeight - rb.Height)*1f/(ScrollbarHeight - thumbHeight));
|
ListOffset += (int)((lastMouseLocation.Y - mi.Location.Y)*(ContentHeight - rb.Height)*1f/(ScrollbarHeight - thumbHeight));
|
||||||
ListOffset = Math.Min(0,Math.Max(rb.Height - ContentHeight, ListOffset));
|
ListOffset = Math.Min(0,Math.Max(rb.Height - ContentHeight, ListOffset));
|
||||||
|
|||||||
Reference in New Issue
Block a user