The real juce function name is juce::TreeViewItem::paintItem (Graphics& g, int width, int height). My bad.
The issue here is that if you want to draw the whole line like fillAll will do when setDrawsInLeftMargin is true, there is no easy way
I finaly found a way by redefining
int GetIndentX() const noexcept
{
int x = getOwnerView()->isRootItemVisible() ? 1 : 0;
if (!getOwnerView()->areOpenCloseButtonsVisible())
--x;
for (juce::TreeViewItem* p = getParentItem(); p != nullptr; p = p->getParentItem())
++x;
return x * getOwnerView()->getIndentSize();
}
currently private and implement paintItem like that
void paintItem(Graphics &g, int width, int height)
{
g.setColour(juce::Colours::red);
g.drawRect(-GetIndentX(), 0, width + GetIndentX(), height);
}
Ah, I see what you mean now. Hmm.. Yeah, can't think of a better way than your workaround - I could add more parameters to the paintItem call, but that'd break a lot of code out there!
Maybe giving access to getIndentX() would lead to smaller code and add some doc regarding using this function to achieve this results could be of some help.
I had a hard time founding a way to make this work hence my try with the clipBounds :)