TableListBox uses wrong height for row-drawing


#1

The TableListBox, actually the TableListRowComp, calls the TableListBoxModel::paintCell(…) with the wrong value for the height-parameter. The row-height (default 22px) should be used for the draw/clipregion-height, but instead the header-height (default 28px) is used. You can see the effect of this i.e. in the TableListBox-part of the JUCE-demo, the text ins’t centered on the real row-height, it’s draw below the rows vertial-center.

TableListRowComp::paint(…) could be changed like this to solve this problem:

[code]const int columnId = header->getColumnIdOfIndex (i, true);
Rectangle columnRect (header->getColumnPosition (i));

columnRect.setSize (columnRect.getWidth(), owner.getRowHeight()); // added line

g.saveState();

g.reduceClipRegion (columnRect);
g.setOrigin (columnRect.getX(), 0);

model->paintCell (g, row, columnId, columnRect.getWidth(), columnRect.getHeight(), isSelected);

g.restoreState();[/code]


#2

Damn, I missed that one! Thanks for spotting it. An even simpler fix would be to change this line:

model->paintCell (g, row, columnId, columnRect.getWidth(), getHeight(), isSelected);


#3

Sorry, but your fix is to simple. With the default-values for row- and header-height (22px/28px) it’s fine, but if the header-height gets smaller than the row-height the clipregion will be to small and the content gets truncated, because you still use the header-height instead of the row-height for reduceClipRegion(…).


#4

You’re quite right. I’ve got a cold at the moment, so my thinking powers are suffering a bit… Thanks!


#5