Implement a slider widget for volume control that returns an exponentially scaled value

This commit is contained in:
netnazgul
2018-01-09 23:37:47 +03:00
committed by Oliver Brakmann
parent 9c08e430e2
commit c195699476
10 changed files with 77 additions and 22 deletions

View File

@@ -84,12 +84,12 @@ namespace OpenRA.Mods.Common.Widgets
return ThumbRect.Contains(mi.Location);
}
float ValueFromPx(int x)
protected virtual float ValueFromPx(int x)
{
return MinimumValue + (MaximumValue - MinimumValue) * (x - 0.5f * RenderBounds.Height) / (RenderBounds.Width - RenderBounds.Height);
}
protected int PxFromValue(float x)
protected virtual int PxFromValue(float x)
{
return (int)(0.5f * RenderBounds.Height + (RenderBounds.Width - RenderBounds.Height) * (x - MinimumValue) / (MaximumValue - MinimumValue));
}