SliderPropertyComponent & TwoValueHorizontal


#1

I’m trying to use a TwoValueHorizontal inside of a SliderPropertyComponent but I keep gettings lots of assertion failures.


SMTrackSlider (const juce::String &propertyName) : SliderPropertyComponent(propertyName,1,99,1)
	{
		slider->setSliderStyle(Slider::TwoValueHorizontal);
		slider->setMinValue(1);
		slider->setMaxValue(99);
		slider->setPopupDisplayEnabled(true,this);
	}[/code]

Assertions occur
[code]void Slider::setValue (double newValue,
                       const bool sendUpdateMessage,
                       const bool sendMessageSynchronously)
{
    // for a two-value style slider, you should use the setMinValue() and setMaxValue()
    // methods to set the two values.
    jassert (style != TwoValueHorizontal && style != TwoValueVertical);[/code]

and

[code]double Slider::getValue() const throw()
{
    // for a two-value style slider, you should use the getMinValue() and getMaxValue()
    // methods to get the two values.
    jassert (style != TwoValueHorizontal && style != TwoValueVertical);

Any chance of a MultiValueSliderPropertyComponent?

:smiley:


#2

Just a little note, nothing serious…

[code]void Slider::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY)
{
if (scrollWheelEnabled && isEnabled())
{
if (maximum > minimum && ! isMouseButtonDownAnywhere())
{
if (valueBox != 0)
valueBox->hideEditor (false);

        const double proportionDelta = (wheelIncrementX != 0 ? -wheelIncrementX : wheelIncrementY) * 0.15f;
        const double currentPos = valueToProportionOfLength (currentValue);
        const double newValue = proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta));

        double delta = (newValue != currentValue)
                        ? jmax (fabs (newValue - currentValue), interval) : 0;

        if (currentValue > newValue)
            delta = -delta;

        sendDragStart();
        setValue (snapValue (currentValue + delta, false), true, true);
        sendDragEnd();
    }
}
else
{
    Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY);
}

}[/code]

setValue creates an assertion on TwoValueHorizontal/Vertical

Not sure if the scrollwheel even makes sence for those slider types, i’ll let you decide…I’ll just setScrollWheelEnabled(false) myself for now…

But maybe a check for

if (style != TwoValueHorizontal && style != TwoValueVertical)

?


#3

Thanks for the heads-up about that wheel thing, I’ll put in some code to sort it out. A multi-slider property comp is a good idea, but low on my priority list!