SliderPopup Menu suggestion (set the current value as DoubleClickReturnValue)

Hi Jules,

what do you think about to add a menu item to the slider popupMenu to set the current value as DoubleClickReturnValue (if this mode is enabled)?

Like this (bold == newCode):

void showPopupMenu()
{
    PopupMenu m;
    m.setLookAndFeel (&owner.getLookAndFeel());
    m.addItem (1, TRANS ("Velocity-sensitive mode"), true, isVelocityBased);
    m.addSeparator();

    if (isRotary())
    {
        PopupMenu rotaryMenu;
        rotaryMenu.addItem (2, TRANS ("Use circular dragging"),           true, style == Rotary);
        rotaryMenu.addItem (3, TRANS ("Use left-right dragging"),         true, style == RotaryHorizontalDrag);
        rotaryMenu.addItem (4, TRANS ("Use up-down dragging"),            true, style == RotaryVerticalDrag);
        rotaryMenu.addItem (5, TRANS ("Use left-right/up-down dragging"), true, style == RotaryHorizontalVerticalDrag);

        m.addSubMenu (TRANS ("Rotary mode"), rotaryMenu);
    }

    if( doubleClickToValue ) {
        m.addSeparator();
        m.addItem (6, TRANS ("Set current value as new return"), true, lastCurrentValue == doubleClickReturnValue );
    }


    m.showMenuAsync (PopupMenu::Options(),
                     ModalCallbackFunction::forComponent (sliderMenuCallback, &owner));
}

static void sliderMenuCallback (const int result, Slider* slider)
{
    if (slider != nullptr)
    {
        switch (result)
        {
        case 1:
            slider->setVelocityBasedMode (! slider->getVelocityBasedMode());
            break;
        case 2:
            slider->setSliderStyle (Rotary);
            break;
        case 3:
            slider->setSliderStyle (RotaryHorizontalDrag);
            break;
        case 4:
            slider->setSliderStyle (RotaryVerticalDrag);
            break;
        case 5:
            slider->setSliderStyle (RotaryHorizontalVerticalDrag);
            break;
        case 6:
            slider->setDoubleClickReturnValue ( true, slider->getValue() );
            break;
        default:
            break;
        }
    }
}

Cheers

Hmm.. Maybe more something that you should add to your own Slider by overriding its menu methods?

Could be difficult, coz the methodes are declared in the cpp (Pimpl).

We only have this two methods in the slider interface:

void setPopupDisplayEnabled (bool isEnabled, Component* parentComponentToUse);

Component* getCurrentPopupDisplay() const noexcept;

But it's not a problem, was just thinking it could be useful in general.

Oh, I thought the menu stuff was overridable. (Maybe making it more customisable would be a good request!)