TabbedButtonBar lookandFeel management needs a small change


#1


overriding drawTabButtonText() only have an effect if our lookAndFeel inherits LookAndFeel_V2.
This is because it is only called from within LookAndFeel_V2::drawTabButton(), while I think it should be called from the TabbedButtonBar::paint() function, just after the call to drawTabButton().
If you make that change, you will also have to override drawTabButtonText() in lookAndFeel_V3 (for now V3 draws the text directly in drawTabButton(), without any call to drawTabButtonText()).


Also, when you drawing the TabButton text in v3, it would be nice if you could change this code :

if (button.isFrontTab() && bar->isColourSpecified (TabbedButtonBar::frontTextColourId))
    col = bar->findColour (TabbedButtonBar::frontTextColourId);
else if (bar->isColourSpecified (TabbedButtonBar::tabTextColourId))
    col = bar->findColour (TabbedButtonBar::tabTextColourId);

to

if (button.isFrontTab() && (bar->isColourSpecified (TabbedButtonBar::frontTextColourId)
                            || isColourSpecified (TabbedButtonBar::frontTextColourId)))
    col = bar->findColour (TabbedButtonBar::frontTextColourId);
else if (bar->isColourSpecified (TabbedButtonBar::tabTextColourId) || isColourSpecified (TabbedButtonBar::tabTextColourId))
    col = bar->findColour (TabbedButtonBar::tabTextColourId);

to always take the TabbedButtonBar text colourIds into account.

Finally a more general question : LookAndFeel_V2 and LookAndFeel_V3 methods are not marked virtual.
I used to think that it was ok to inherit from them, but for sure if one day you make some big changes in there,
my lookAndFeels will change too..
So did you not marked them as virtual because of that?
Should we really avoid inheriting from them and only inherit from LookAndFeel, or would you say you won't make more lnf changes in them and it is ok if we inherit from them ?
 


#2

Thanks, I'll look at the colour thing.

I don't really understand your comment about 'virtual' though - obviously all the derived functions are still virtual, that's why they have the override keyword... Do you understand how the virtual keyword works?


#3


ahah, ok..! well I was asking because I was not sure… :)
I thought it was common to specify "virtual" even in sub-classes so that users know they can safely override it. I was not sure that it was safe to override it if they were not marked as virtual. But ok, if I got it right, the thing is that one does not need to specify 'virtual' again in sub-classes, as 'virtual' will automatically propagate in sub-classes (as long as they are not marked 'final').
thanks for the lesson leader!


#4


Thanks for the colour change.
but just in case you missed it in my rather long post, do also note that implementing TabbedButtonBar::LookAndFeelMethods::drawTabButtonText() does not have any effect.
drawTabButtonText() should be called from TabbedButtonBar::paint() and not from LookAndFeel_V2::drawTabButton().
and LookAndFeel_V3 should draw the text in a drawTabButtonText(), not in drawTabButton().
 


#5

Well, not really.. IIRC the V3 class is a bit different because its text layout can't easily be separated into that virtual method because it needs to know some other things about the layout. I agree it's not ideal though, and I'll take a look at some point to see if it could be rearranged better.