Hi,
Currently doing a 5mn work that ends as a half a day work, I’m wondering about few fixes that might simplify our work in similar case.
For example, I’m using a +/- slider where I’m changing the “interval” step. However, my specific problem requires that the value are kept full resolution (so “inc step” with an interval of 10 applied to a value of 5 should result in 15, not 20).
I’ve subclassed the slider class, but due to overzealous Pimpl protection, I can’t change anything here without rewriting the whole stuff (which is counter productive).
I think PImpl is good, and I don’t think exposing it would help much, but typically, the component introspection API should be complete, so I can “simulate” the interval myself.
It’s currently lacking listener manipulation.
So I’ve tried to remove the PImpl’s buttonListener to add my own, but even that, I can’t do it.
I’ve seen multiple change to the listener code in the past few month, but I wonder if a template would be more useful here, so every listener’s caller class have the same interface, something like this:
template <class BaseClass>
class ListenerAccepter
{
private:
// The actual listener list
ListenerList <Listener> listeners;
public:
// Inject the internal Listener class inside us, so we can use it directly
typedef BaseClass::Listener Listener;
void addListener (Listener* newListener);
void removeListener (Listener * newListener);
int getListenersCount(); // Added for introspection
Listener * getListener(int index); // Added for introspection
};
The pro, well, is obvious, the interface is the same, so you never have to check the doc to find out if a particular method is supported, and introspection will be possible completely at the “Component” level.
The con, is that the documentation will be less specific for each class, but since the class will derive from the ListenerAccepter, it’ll be visible in the documentation anyway.