Bar or not to bar


#1

hello ! , i have found a fix for some code in juce slider , i d’ont know if i am in the good section but is just about the vertical bar (not working by default ) there only the horizontal bar progress

but if you want the code related to drawing a vertical bar with shinybuttonshape…

say it tom me , and i give you the code via paste bin.com
there only a smalls modifications , do not affect others things.

kamder.prod°


#2

Ok, thanks - I’m not sure exactly what problem you mean, but if you want to post some code, that’d probably make it clear!


#3

just added vertical to juce_LookAndFeel.cpp near line 1466 :

[code] if ( style == Slider::LinearBarVertical)
{
const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled();

    Colour baseColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId)
                                                                   .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f),
                                                             false, isMouseOver,
                                                             isMouseOver || slider.isMouseButtonDown()));

//KAMDERBAR FIND HOW TO CREATE A VERTICAL BAR WITH drawShinyButtonShape //

    drawShinyButtonShape (g,
                          (float) x, sliderPos*((float)height/(float)width), (float) width,  (float) height , 0.0f,
                          baseColour,
                          slider.isEnabled() ? 0.9f : 0.3f,
                          true, true, true, true);        

}

else if ( style == Slider::LinearBar)
{
    const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled();
    
    Colour baseColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId)
                                                             .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f),
                                                             false, isMouseOver,
                                                             isMouseOver || slider.isMouseButtonDown()));
    
   drawShinyButtonShape (g,
     (float) x, (float) y, sliderPos - (float) x, (float) height, 0.0f,
     baseColour,
     slider.isEnabled() ? 0.9f : 0.3f,
     true, true, true, true);

}[/code]

and in juce_Slider.cpp near line 1167 the value selection region size change to :

[code] if (style == LinearBar )
{
const int barIndent = 1;
sliderRegionStart = barIndent;
sliderRegionSize = localBounds.getWidth() - barIndent * 2;
sliderRect.setBounds (sliderRegionStart, barIndent,
sliderRegionSize, localBounds.getHeight() - barIndent * 2);

////KAMDERBAR REGION SIZE DEF SETTINGS SWITCH LINEARBAR TO VERTICAL////

    }
    else if (style == LinearBarVertical)
    {
        const int barIndent = 1;
        sliderRegionStart = barIndent;
        //////////////////////getWidth()///>>>TO>>>>>//getHeight()//////
        sliderRegionSize = localBounds.getHeight() - barIndent * 2;
        ////////////////////////////////////////////////////////////////
        sliderRect.setBounds (sliderRegionStart, barIndent,
                              sliderRegionSize, localBounds.getHeight() - barIndent * 2);

    }            

/////////****************/////////////////[/code]

and this in juce_Slider.cpp near line 1120 , optional , this is my setting , more easy to enter value , and double click default :

[code]//KAMDERBAR HAVE SET VALUE BOX TO BELOW THE BAR //

    if ((style == LinearBarVertical) && (textBoxPos != NoTextBox))
    {
        valueBox->setBounds ((localBounds.getWidth() - tbw) / 2, localBounds.getHeight() - tbh, tbw, tbh);
        sliderRect.setBounds (0, 0, localBounds.getWidth(), localBounds.getHeight() - tbh);
    }

//******************************************************************************************//

    else if (style == LinearBar)
    {
        if (valueBox != nullptr)
            valueBox->setBounds (localBounds);
    }[/code]

the bar works 100% , except if you resize the bar too big in width there is a limit… , but for a normal size bar no problem!

kamderbar.