From 053f865a00d7ae47dadfe30d38dcb9a41bdd491a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 22 Aug 2019 23:44:26 +0200 Subject: [PATCH] made the scroll bar be grabbed in the center --- MLEM.Ui/Elements/ScrollBar.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MLEM.Ui/Elements/ScrollBar.cs b/MLEM.Ui/Elements/ScrollBar.cs index 544b6e0..0b6f6db 100644 --- a/MLEM.Ui/Elements/ScrollBar.cs +++ b/MLEM.Ui/Elements/ScrollBar.cs @@ -56,11 +56,11 @@ namespace MLEM.Ui.Elements { if (this.isMouseHeld) { if (this.Horizontal) { - var internalX = this.MousePos.X - this.Area.X; - this.CurrentValue = internalX / (float) this.Area.Width * this.MaxValue; + var internalX = this.MousePos.X - this.Area.X - this.ScrollerSize.X * this.Scale / 2; + this.CurrentValue = internalX / (this.Area.Width - this.ScrollerSize.X * this.Scale) * this.MaxValue; } else { - var internalY = this.MousePos.Y - this.Area.Y; - this.CurrentValue = internalY / (float) this.Area.Height * this.MaxValue; + var internalY = this.MousePos.Y - this.Area.Y - this.ScrollerSize.Y * this.Scale / 2; + this.CurrentValue = internalY / (this.Area.Height - this.ScrollerSize.Y * this.Scale) * this.MaxValue; } }