Hardcoded colour in TreeViewItem::paintRecursively


#1

Drawing a TreeViewItem on a dark background, I noticed that I always got a dark arrow, which is because LookAndFeel_V3::drawTreeviewPlusMinusBox uses a contrasting colour to the tree view item, which is called only from LookAndFeel_V3::drawTreeviewPlusMinusBox with a hardcoded Colours::white, which will then only ever produce translucent black for the arrow. Could this be configurable in some way based on the TreeView item?

Perhaps a combination of a TreeViewItem::backgoundColourId or a functional equivalent and a virtual getPlusMinusBoxColour method (which defaults to contrasting with the background colour, but can be overriden if you want to specify it manually?


#2

I think the API documentation for paintOpenCloseButton give you a hint on how to solve your problem. Simply override paintOpenCloseButton and ignore the backroundColour, then pass a different backgroundColour to the base class implementation. For example:

 

class MyTreeViewItem : public TreeViewItem
{
public:
    void paintOpenCloseButton (Graphics& g, const Rectangle<float>& area, Colour backgroundColour, bool isMouseOver) override
    {
        ignoreUnused (backgroundColour);
        TreeViewItem::paintOpenCloseButton (g, area, Colours::black, isMouseOver);
    }
};

Does this make sense?


#3

D'oh, yes that makes sense! Thank you!