[FR] About LnF


#1

Hi Jules,

 

Would it be possible to add some ref counting to the LookAndFeel at some point ?

Right now each time you want a widget with a custom look, you have to setup a new LnF class (so far no biggie) but you have to keep a reference of it somewhere and this is painfull.

 

Thanks,


#2

It's something I've thought about, but would probably break a few things, as everyone at the moment is deleting them manually, so if something began using a ref-count, that could cause a conflict. I've also found it annoying sometimes though, so would like to figure out some way of making it easier to do.


#3

Thanks !

Much appreciated.


#4

In my case I've made a LookAndFeelManager singleton class that holds some dedicated lookandfeel objects for the current project. The LnFs are created on it's first reference and deleted at shutdown.. Anywhere in my project where i need to set a lookandfeel  i can simply call something like popupMenu.setLookAndFeel (LookAndFeelManager::getInstance()->getDarkPopupMenu()); and don't worry about keeping a reference.. 


#5

You can also just use a SharedResourcePointer


#6

Well the point was not to keep any reference as the actual component could do it for me :)


#7

well if you change the signature of Component::setLookAndFeel then people will notice the difference :)

Not sure this is the kind of code which is used often in a projet though.