AlphaTab.Rendering.Utils.StaveGroupBounds.FindBarAtPos C# (CSharp) Method

FindBarAtPos() public method

public FindBarAtPos ( float x ) : MasterBarBounds
x float
return MasterBarBounds
        public MasterBarBounds FindBarAtPos(float x)
        {
            MasterBarBounds b = null;
            // move from left to right as long we find bars that start before the clicked position
            for (int i = 0; i < Bars.Count; i++)
            {
                if (b == null || Bars[i].RealBounds.X < x)
                {
                    b = Bars[i];
                }
                else if (x > Bars[i].RealBounds.X + Bars[i].RealBounds.W)
                {
                    break;
                }
            }
            return b;
        }