Slider listener and valueChanged

Hi Jules,

Current in slider, triggerChangeMessage is implemented like this

    void triggerChangeMessage (const NotificationType notification)
        if (notification != dontSendNotification)
            if (notification == sendNotificationSync)

Wouldn't it make more sense to have valueChanged called before listener are called ?

If Listener ask some value to the slider, then it would be one that matches the changed and it would have the same results

in synd and async notification.




Well... I guess it wouldn't do any harm.. I may change that.

But TBH if you have code which isn't robust enough to deal with the callbacks and listeners being called in a different order, then something is probably wrong!

Well the use case is pretty simple.

You have a Slider which change its color according to its value.

What you do is you subclass the Slider and override valueChanged to change its color.

Other widget swould like to be notified of this knob change and grab the new color in the callback.

I agree they could bind to the color change instead of the knob change, but this is not far fetched as well.


Hope it make sense.



If the colour depends on the slider's value, then why keep a redundant copy of it that can be out-of-sync with the real value?

Unless calculating that colour is incredibly slow and the result needs to be cached for performance, then it'd be a much better design to simply have a const method that calculates and returns the colour based on the slider's value, and to never actually store it anywhere. Less state is better!

Well my example was a dummy one, something to state the kind of use case I was thinking about :)


Understood. I changed the code yesterday anyway.

Thanks !