Problem with my horizontal bar

1

I'm having problems with my horizontal bar, the problem is that it is not increasing the value of the "iVar" variable from 1 to 1, it's increasing by 5 or even more depending on how much I spend in the iMax value, How do I fix this problem?

#define SLIDER_WIDTH        250
#define SLIDER_HEIGHT       8
#define MAX_SLIDERS     30

int SliderPos[MAX_SLIDERS] = { 0 };

int iNumSliders = 0;

void AddSliderBar(int iPosX, int iPosY, int iMinVal, int iMaxVal, std::string sText, int &iVar)
{
    Color SliderColor1 = Color(200, 000, 000);
    Color SliderColor2 = Color(200, 000, 000);

    SliderPos[qntSliders] = iPosX + (iVar - iMinVal) * SLIDER_WIDTH / (iMaxVal - iMinVal);

    if (bMouseInRegion(iPosX, iPosY + 11, SLIDER_WIDTH, SLIDER_HEIGHT) && bMouseClicked())
        iVar = (Cur.x - iPosX) * (iMaxVal - iMinVal) / SLIDER_WIDTH;

    (iVar > iMaxVal) ? iVar = iMaxVal : iVar = iVar;
    (iVar < iMinVal) ? iVar = iMinVal : iVar = iVar;

    PrintText(x, y - 3, SliderColor1, FL_RIGHT, "%s: %i", sText.c_str(), iVar);

    // Slider cursor
    Draw.FillRGB(SliderPos[qntSliders], iPosY + 8, 2, SLIDER_HEIGHT, SliderColor1);

    // Slider bar
    Draw.FillRGB(iPosX, iPosY + 11, SLIDER_WIDTH, 2, SliderColor2);

    iNumSliders++;
}
    
asked by anonymous 12.10.2017 / 02:28

0 answers